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.

SCJP 1.4 (90%)<br />SCWCD 1.4 (88%)

Sham Usha
Greenhorn

Joined: Jul 22, 2001
Posts: 11

posted May 26, 2005 23:43:00

0

Hi Swati

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.

Swati Udas
Ranch Hand

Joined: Aug 18, 2004
Posts: 121

posted May 26, 2005 23:52:00

0

Hi Sham Usha,

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.

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.