In the following codes, windows "normal frame1" and "normal frame2"
produced
by JFrame can be closed without stopping the whole program, but when I
closed window produced by MainFrame, the whole program was stopped as
well.
How to close window produced by MainFrame, without stopping the whole
program?
Thank you very much.
tony
//**************************** ****************************** *****
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.applet.Applet;
import com.sun.j3d.utils.applet.MainF rame;
public class JFrame2 implements ActionListener
{
public JFrame2()
{
JFrame f = new JFrame("JFrameDemo");
Container contentPane = f.getContentPane();
JButton b = new JButton("Click me to get new Window");
b.addActionListener(this);
contentPane.add(b);
f.pack();
f.show();
}
public void actionPerformed(ActionEvent e)
{
JFrame newf = new JFrame("normal frame1");
newf.setSize(200,200);
newf.show();
Frame newf4 = new MainFrame(new Applet(), 256, 256);
JFrame newf2 = new JFrame("normal frame2");
newf2.setSize(200,200);
newf2.show();
}
public static void main(String[] arg)
{
new JFrame2();
}
}// end JFrame2
//**************************** ****************************** *****
> How to close window produced by MainFrame, without stopping the whole
> program?
Check the javadocs for JFrame, setDefaultCloseOperation(int operation)
might be the answer. If you have a "normal" Frame, you might use another
WindowListener, or something similar.
--
You can't run away forever,
But there's nothing wrong with getting a good head start.
--- Jim Steinman, "Rock and Roll Dreams Come Through"
No, he's posted this same question in another newsgroup. The issue is
that he's using a class "com.sun.j3d.utils.applet.MainFrame" which does not
extend JFrame and which doesn't have a setDefaultCloaseOperation() method.
- Oliver