When I just call a dispose(); I still am getting run time errors. Here is the code I have in my actionEvent when the button is pushed.
public void actionPerformed(ActionEvent evt) {
try {
Object source = evt.getSource();
if (source == _dialogButton) {
System.out.println("Dialog Button was pressed");
//_dialogWindow.hide();
//this.hide();
_dialogWindow.dispose();
//this.dispose();
}
}
I eventually get the following runtime error.
Exception occurred during event dispatching:
java.lang.IllegalArgumentException: adding a window to a container
at java.awt.Container.addImpl(Container.java:339)
at java.awt.Container.add(Container.java:231)
at frameApplet.buildGui(frameApplet.java:40)
at frameApplet.<init>(frameApplet.java:17)
at buttonApplet.actionPerformed(buttonApplet.java:23)
at java.awt.Button.processActionEvent(Button.java:329)
at java.awt.Button.processEvent(Button.java:302)
at java.awt.Component.dispatchEventImpl(Component.java:2595)
at java.awt.Component.dispatchEvent(Component.java:2499)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:336)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:134)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:96)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:88)
I don't quite understand why I am getting this runtime error. Any help would be appreciated.
I got rid of the run time problem. Instead of using dispose() I ended up using show() and hide(). When the initial GUI came up I had the hide() method called and when the button was pushed to bring up the dialog box show() was called. I then called hide() again when the ok button was pushed. This called no run -time error.