Who knows Class MainFrame?

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

//**************************** ****************************** *****
 
S

Stefan Schulz

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.
 
O

Oliver Wong

Stefan Schulz said:
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.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top