single document interface, start a new JFrame in a new thread

i decided to have my java application use the single document interface (SDI) approach. my problem is how to start a new JFrame application from an existing one. below is some simple code that does NOT work. please help.

public class MyGuiForm extends JFrame implements ActionListener {

private JButton _btnNew;

public MyGuiForm() {

_btnNew = new JButton("New");

this.getContentPane().setLayout(new BorderLayout());

this.getContentPane().add(_btnNew);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.pack();

this.show();

}

public void actionPerformed(ActionEvent ae) {

Object source = ae.getSource();

if(null == source) return;

if(_btnNew == source) {

new MyGuiForm();

}

}

/**

* @param args

*/

public static void main(String[] args) {

SwingUtilities.invokeLater(new Runnable() {

public void run() {

JFrame.setDefaultLookAndFeelDecorated(true);

new MyGuiForm();

}

});

}

}

[1063 byte] By [jakestera] at [2007-11-26 23:40:25]
# 1
Include_btnNew.addActionListener(this);
it_senthilkumara at 2007-7-11 15:06:59 > top of Java-index,Desktop,Developing for the Desktop...
# 2
sorry about that. after adding the JFrame as an action listener to the JButton, i am creating new JFrames. however, when i close the first JFrame, all other JFrames closes.how do i prevent this problem from happening?
jakestera at 2007-7-11 15:06:59 > top of Java-index,Desktop,Developing for the Desktop...
# 3

When you add this

frame.setDefaultCloseOperation(EXIT_ON_CLOSE);

//then it will exit when close 1 frame

//insted that use

frame.setDefaultCloseOperation(HIDE_ON_CLOSE);

//this will just hide the frame

//add your exiting code to the menu which you want.

Sachin

student@sunDNa at 2007-7-11 15:06:59 > top of Java-index,Desktop,Developing for the Desktop...