Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Java 3D / September 2005

Tip: Looking for answers? Try searching our database.

class MainFrame: window closed, but whole program stopped

Thread view: 
tony_lincoln@yahoo.com - 31 Aug 2005 08:38 GMT
Dear Friends,

I have one question about closing windows produced by mainFrame. 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.MainFrame;

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

//***************************************************************
Oliver Wong - 31 Aug 2005 15:45 GMT
> I have one question about closing windows produced by mainFrame. In the
> following codes, windows "normal frame1" and "normal frame2" produced
[quoted text clipped - 47 lines]
>
> //***************************************************************

   Well, I don't have "com.sun.j3d" so I couldn't actually run your
example, but I just wanted to comment that your code is pretty confusing.
For example, why did you name your main class "JFrame2" if it is not, in
fact, a JFrame? It would probably be better to name it "JFrameDemo" or even
"Test". With "Test", you don't get much information, but no information is
better than misleading information.

   As for your actual question, I don't know. If MainFrame is an instance
of JFrame, did you try setDefaultCloseOperation() ?

   - Oliver
tony_lincoln@yahoo.com - 31 Aug 2005 20:07 GMT
Thanks for your words. As shown in codes:
Frame newf4 = new MainFrame(new Applet(), 256, 256);

so MainFrame is an instance of Frame, but not JFrame.
setDefaultCloseOperation() is a method in JFrame, it can not work for
MainFrame: I tried
newf4.setDefaultCloseOperation();
Javac can not resolve the symbol setDefaultCloseOperation in class
java.awt.Frame.

At the same time, windows "normal frame1" and "normal frame2" produced
by JFrame can be closed without stopping the whole program. So it is
not necessary to do more things about JFrame instance.
THe only thing to do with is MainFrame. But how? :-(
Oliver Wong - 31 Aug 2005 21:06 GMT
> Thanks for your words. As shown in codes:
> Frame newf4 = new MainFrame(new Applet(), 256, 256);
[quoted text clipped - 10 lines]
> not necessary to do more things about JFrame instance.
> THe only thing to do with is MainFrame. But how? :-(

   I don't have access to the code for MainFrame, nor its documentation, so
I can't really help you with its behaviour. The only way I think I could
help you from here on is if you switch from using MainFrame to JFrame.

   - Oliver
tony_lincoln@yahoo.com - 01 Sep 2005 09:01 GMT
MainFrame is to show 3D objects for users, JFrame has no this function.
So it seems that I have to use MainFrame. :-(
tony


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.