Currently showing ../JWS/Xith3D/framework/source/Xith3DFrame.java
                  /*--.          .-"-.
                 /   o_O        / O o \
                 \_  (__\       \_ v _/
                 //   \\        //   \\
                ((     ))      ((     ))
 いいいいいいい--""---""--いい--""---""--いいいいいいいいいいいいい
                  |||            |||                             
                   |              |                              
                                                                 
  Programmer:Abdul Bezrati                                       
  Program   :Xith3D basic frame                                  
  Comments  :None                                                
     _______                                                     
   /` _____ `\;,    abezrati@hotmail.com                         
  (__(^===^)__)';,                                 ___           
    /  :::  \   ,;                               /^   ^\         
   |   :::   | ,;'                              (     )        
 い'._______.'`いいいいいいいいいいいいい --oOo--(_)--oOo--い*/

import com.xith3d.loaders.texture.TextureLoader;
import com.xith3d.render.jogl.RenderPeerImpl;
import com.xith3d.scenegraph.*;
import display.DisplayOptions;
import com.xith3d.render.*;
import java.awt.event.*;
import javax.vecmath.*;
import sun.misc.Perf;
import javax.swing.*;
import java.awt.*;
import Input.*;

public class Xith3DFrame
{

  private boolean fullScreen  =        false,
                  runDemo     =         true;

  private JFrame  parentFrame = new JFrame();

  private View     view       =   new View();

  public static void main(String []args) {
    Xith3DFrame test = new Xith3DFrame();
  }

  Xith3DFrame(){
    try{
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }
    catch(Exception a){}

    int parameters[]    =        new int[7];
        //screenWidth   =     parameters[0];

        //screenHeight  =     parameters[1];

        //canvasWidth   =     parameters[2];

        //canvasHeight  =     parameters[3];

        //refreshRate   =     parameters[4];

        //bitDepth      =     parameters[5];

        //fullScreen    = parameters[6]== 1;


    DisplayOptions.showSettingsSelector("Select Screen Mode",
                                        DisplayOptions.USE_XITH3D_ENGINE,
                                        parameters);

    VirtualUniverse virtualUniverse   = new VirtualUniverse();
    RenderPeer      renderPeer        = new RenderPeerImpl();
    CanvasPeer      canvasPeer        = null;
    Canvas3D        canvas            = new Canvas3D();
    Locale          locale            = new Locale();

    virtualUniverse.addLocale(locale);
    locale.addBranchGraph(scene());
    virtualUniverse.addView(view);

    canvasPeer   = renderPeer.makeCanvas(parentFrame.getContentPane(),
                                         parameters[2],parameters[3],parameters[5],false);

    canvasPeer.getComponent().requestFocus();

    canvas.set3DPeer(canvasPeer);
    view.addCanvas3D(canvas);

    if(fullScreen = (parameters[6] == 1)){
      parentFrame.setUndecorated(true);
      GraphicsEnvironment.getLocalGraphicsEnvironment().
      getDefaultScreenDevice().setFullScreenWindow(parentFrame);
      GraphicsEnvironment.getLocalGraphicsEnvironment().
      getDefaultScreenDevice().setDisplayMode((new DisplayMode(parameters[2], parameters[3],
                                                               parameters[5], parameters[4])));
    }
    else{
      int xLocation = (parameters[0] - parameters[2])/2,
          yLocation = (parameters[1] - parameters[3])/2;

      xLocation = (xLocation < 0)? 0: xLocation;
      yLocation = (yLocation < 0)? 0: yLocation;

      parentFrame.setSize(parameters[2],parameters[3]);
      parentFrame.setLocation(xLocation, yLocation );
      parentFrame.addWindowListener(new shutDownWindow());
    }

    parentFrame.setVisible(true);
    run();
  }

  private BranchGroup scene(){

    BranchGroup scene = new BranchGroup();

    scene.addChild(new Background(new Color3f(1,1,1)));
    scene.addChild(getSingleQuad());
    scene.compile();

    return  scene;
  }

  private Shape3D getSingleQuad(){

    float depth  = -2.5f,
          width  =  1.5f,
          height =  1.0f;

    int   flag   = GeometryArray.TEXTURE_COORDINATE_2 |
                   GeometryArray.COORDINATES;

    TriangleStripArray geometry              = new TriangleStripArray(4,flag, new int[]{4});

    Appearance         appearance            =   new Appearance();

    TexCoord2f         textureCoordinates[]  = { new TexCoord2f(0,0),
                                                 new TexCoord2f(1,0),
                                                 new TexCoord2f(0,1),
                                                 new TexCoord2f(1,1)};

    Point3f            vertices[]            = { new Point3f(-width,-height, depth),
                                                 new Point3f( width,-height, depth),
                                                 new Point3f(-width, height, depth),
                                                 new Point3f( width, height, depth)};

    appearance.setTexture(TextureLoader.tf.getTexture("Data/xith3d.gif"));

    geometry.setCoordinates(0, vertices);
    geometry.setTextureCoordinates(0, 0, textureCoordinates);

    return new Shape3D(geometry, appearance);
  }

  private void run(){

    Perf  timer           = sun.misc.Perf.getPerf();

    float frameInterval   = 0;
    long  updateFrequency = timer.highResFrequency()>>1,
          currentTime     = 0,
          frameTime       = timer.highResCounter(),
          lastTime        = timer.highResCounter();
    int   fps             = 0;

    while (runDemo){
      currentTime = timer.highResCounter();
      fps++;

      if(currentTime - lastTime >=updateFrequency){
        if(!fullScreen)
          parentFrame.setTitle("Basic Xith3D Frame: FPS " + String.valueOf(fps<<1) );
        lastTime = currentTime;
        fps      = 0;
      }

      checkUserEvents();
      view.renderOnce();
    }
  }

  public void checkUserEvents(){
    if(KeyboardEvents.getBlockEventAt((char)27))
      killApplication();
  }

  private void killApplication(){
    runDemo = false;
    System.gc();
    System.exit(0);
  }

  public class shutDownWindow extends WindowAdapter {
    public void windowClosing(WindowEvent e) {
      killApplication();
    }
  }
}
     

Total 192 Lines of Code.
Source code formatted using showsrc by William Denniss