T
tony_lincoln
Dear Friends,
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
//**************************** ****************************** *****
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
//**************************** ****************************** *****