Dearest Java3D,
 
I am currently re-vamping a program I wrote in java3d. This time I want the product to be equally 'at home' in either applet or stand alone form. I think that I have resolved most of the simple issues now, however it is not clear how it is best to handle the creation of frames. Below is the code that I use to create a frame upon request for the stand alone application.
 
What is the best way to write a class that caters for apps and applets? I dont really want to just get rid of this stuff and add a "new Mainframe (new blah)" in my main() method. That would seem totally backward and un-elegant.
 
At the moment when running as an applet two (??haha) detatched frames appear that I can move about etc, I suppoes I dont really mind this, but I think it would be more conventional just to use the frame or whatever comes with the applet....
 
Surely there is a way that makes sense??? Your thoughts please!
 
Nathan
 
 
 
public Frame createFrame (GraphicsConfiguration grxc) {
        
 // Construct the new frame with the correct graphics configuration
  
 String frameText = "DTV " + VERSION;
 Frame frame = new Frame (frameText, grxc);
 frame.setLocation(100, 75);
 frame.setSize(512, 384);
 
 
 // load the image to be used as an icon
 
 try {
     URL icon_url = getClass().getResource("/other/ico4.jpg");    
     ImageIcon iicon = new ImageIcon(icon_url);
     Image icon = iicon.getImage (); 
     frame.setIconImage (icon);
 }
 catch (Exception e) {
     System.out.println ("Icon image couldnt be found :" + e);
 }
 
 
 // kill the window on close
 
 frame.addWindowListener ( new WindowAdapter() {
  public void windowClosing(WindowEvent winEvent) {
      System.exit(0);
          }
     }
 );
 
  
 // Send the frame back
 
 return (frame);
}
   

Reply via email to