-
JInternalFrames
Right now, I am using NetBeans 5.5 and I am confused about the internal frames. I have a main frame that has a JDesktopPane inside of it. Inside this JDesktopPane I have one JInternalFrame. This JInternalFrame is supposed to be used for order entry so once the user clicks the Submit Order button, the screen should clear and dispose. When the user wants to enter a new order it should instantiate a new internal frame so the old data is cleared out of the box and a fresh form is available to the user. How can I do this so that when the user wants to enter a new order, a new instance of the internal frame is available to the user instead of just setting the internal frame from visible = false to visible = true where the data is still there? Do I just have to clear all of the fields when the user hits the submit button and set the form visibility to false once they submit the order?
-
Re: JInternalFrames
That's one way. Another way is to dispose() the old internal frame and actually create a new instance when a new one is needed.
Clearing out is faster. Disposing and recreating is easier to implement and easier to maintain. For example, if you dispose and recreate, all fields will be cleared. If you manually clear all fields, and later add a new field, you'll have to remember to clear that, too.
-
Re: JInternalFrames
Well, I dragged and dropped the JInternalFrame into the JDesktopPane but the JInternalFrame (called AccountUpdate) isnt a class, it looks like NetBeans makes it an object of the MainFrame.java class that I have which has the JDesktopFrame dropped on the main JFrame (MainFrame.java class). It looks like it makes it an object of the JDesktopFrame... so how would I create a new instance of that object if it is part of another object? Since its an object of that JDesktopFrame and I can't instantiate it (as i know of) the dispose method isnt in the list of available methods for that object. I just have the setVisible method.
The reason I am saying this is because on the left where it has the Method Navigator and the Inspector... in the Inspector tab it has a list of all of the object associated with that JFrame. Under the JDesktopPane in this list is the JInternalFrame (AccountUpdate).