In my JFrame main menu I have opened a JInternalFrame. Within the JInternalFrame I have opend many JFrames. I have closed button in the JInternalFrame only. There I can close only JInternalFrame. But I need to close all the opened JFrames as well other than the Menu.
If you want to close all the existing windows you can add systen.exit(); to the actionlistener for the close button.. else add appropriate listener from outer most frame and selectively close the required windows.
Once I used System.exit() then close the main menu also. I need to close only the internal frame and the opened Jframes only.
To selectively close the required windows, how I can identify what are the opened jframes objects. Since there are several menues in the Main menu. and user can open only one internalfame at a time. There he may or may not be open jframes. If there are opened Jframes once he exit from that menu option all the opened Jframe and internal frame need to be closed other than main menu.
As far as I understand U have a close button in JInternalFrame. Also u are instantiating the internal JFrames from the JInternal frame. I think u should be able to check from the JInternalFrame for open JFrames and close them . Can you paste some part of the code, that will give a clearer idea about your problem.
Class clsOption = Class.forName("class name depend on option"); JInternalFrame jplOption = (JInternalFrame)clsOption.newInstance(); setInternalFrame(jplOption,jplOption.getWidth(),jplOption.getHeight()); this.getContentPane().add(jplOption); jplOption.setVisible(true);
Hi Sham Usha, I read through your code.. I am not very sure how Jframes are created in side an JInternalFrame. However I have a suggestion.. U have added a mouse listener to your close button.. U can also add actionlistener..
cmdclose.addActionListener(this);
Also go to you actionperformed function and recognise this event
public void actionPerformed(ActionEvent e){ if(e.getsource==cmdclose){ //write the code to close all the frames and internal Jframe //I am not sure if u can catch the open frames at this point. }
//Let ur existing code be as it is here }
I have another suggestion too: override the internalframe.dispose method and add lines to close all Frames from there- I havent worked with JInternalFrame..so i am not sure how JFrames are opened from here and if can access them from this dispose function.
Hope i have not confused you!!Let me know if this helps!
SCJP 1.4 (90%)<br />SCWCD 1.4 (88%)
When people don’t understand what you are doing they call you crazy. But this tiny ad just doesn't care:
a bit of art, as a gift, that will fit in a stocking