Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Who knows Class MainFrame?

0 views
Skip to first unread message

tony_l...@yahoo.com

unread,
Aug 31, 2005, 3:21:25 PM8/31/05
to
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

//**************************** ****************************** *****

Stefan Schulz

unread,
Aug 31, 2005, 4:48:54 PM8/31/05
to
On Wed, 31 Aug 2005 12:21:25 -0700, tony_lincoln wrote:

> 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"

Oliver Wong

unread,
Aug 31, 2005, 5:08:53 PM8/31/05
to

"Stefan Schulz" <te...@spacetime.de> wrote in message
news:pan.2005.08.31...@spacetime.de...

> On Wed, 31 Aug 2005 12:21:25 -0700, tony_lincoln wrote:
>
>> 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.

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


0 new messages