Results 1 to 3 of 3
  1. #1
    Swankee is offline Member
    Join Date
    Sep 2009
    Posts
    14
    Rep Power
    0

    Default Do I make a new JFrame every time?

    I have my main JFrame with all of my controls. When a user chooses File-> Open I'm opening a dialog window open that has ~5tb's, ddl's, JFileChooser and a few other controls. right now I have them mounted on a panel in a dialog window.

    What is the correct way to do this in JAVA. Do I continue using the dialog box or do I create a new JFrame since there is a great amount of user input required on the newly opened window.
    thanks!

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    5

    Default

    you should be ok to reuse the same instance of the dialog. just use the setVisible() to hide the dialog when it is not in use. Might also need some kind of cleanup or reset of some of the properties on the dialog. I usually invent a doDisplayDialog() and a doHideDialog() methods, which internally the doDisplayDialog() can do what ever resetting or clearing of variables I expect to be blank every time the dialog is shown.

  3. #3
    Swankee is offline Member
    Join Date
    Sep 2009
    Posts
    14
    Rep Power
    0

    Default

    Quote Originally Posted by travishein View Post
    you should be ok to reuse the same instance of the dialog. just use the setVisible() to hide the dialog when it is not in use. Might also need some kind of cleanup or reset of some of the properties on the dialog. I usually invent a doDisplayDialog() and a doHideDialog() methods, which internally the doDisplayDialog() can do what ever resetting or clearing of variables I expect to be blank every time the dialog is shown.
    very cool, thanks for the clarification

Similar Threads

  1. how to make a loading bar in jframe
    By arunkumarinfo in forum NetBeans
    Replies: 3
    Last Post: 12-28-2013, 05:45 PM
  2. How to make a modal JFrame?
    By surot in forum New To Java
    Replies: 20
    Last Post: 06-11-2011, 11:31 PM
  3. Make multiple JTextFields focus at the same time.
    By toymachiner62 in forum AWT / Swing
    Replies: 6
    Last Post: 10-09-2009, 02:59 AM
  4. Replies: 4
    Last Post: 04-22-2009, 11:02 PM
  5. Class Time - represents time of day
    By verbazon in forum New To Java
    Replies: 1
    Last Post: 04-13-2009, 01:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •