diff options
Diffstat (limited to 'src/HelloUniverse')
-rw-r--r-- | src/HelloUniverse/HelloUniverse.html | 15 | ||||
-rw-r--r-- | src/HelloUniverse/HelloUniverse.java | 106 | ||||
-rw-r--r-- | src/HelloUniverse/HelloUniverse_plugin.html | 39 | ||||
-rw-r--r-- | src/HelloUniverse/build.xml | 2 |
4 files changed, 88 insertions, 74 deletions
diff --git a/src/HelloUniverse/HelloUniverse.html b/src/HelloUniverse/HelloUniverse.html new file mode 100644 index 0000000..93b044c --- /dev/null +++ b/src/HelloUniverse/HelloUniverse.html @@ -0,0 +1,15 @@ +<HTML> +<HEAD> +<TITLE>Hello, Universe!</TITLE> +</HEAD> +<BODY BGCOLOR="#000000"> +<applet align=middle code="HelloUniverse.class" width=256 height=256> +<blockquote> +<hr> +If you were using a Java-capable browser, +you would see Hello Universe! instead of this paragraph. +<hr> +</blockquote> +</applet> +</BODY> +</HTML> diff --git a/src/HelloUniverse/HelloUniverse.java b/src/HelloUniverse/HelloUniverse.java index de8f783..7616a88 100644 --- a/src/HelloUniverse/HelloUniverse.java +++ b/src/HelloUniverse/HelloUniverse.java @@ -1,7 +1,7 @@ /* * $RCSfile$ * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -42,20 +42,20 @@ * $State$ */ -import com.sun.j3d.utils.universe.*; +import java.applet.Applet; +import java.awt.BorderLayout; +import java.awt.event.*; +import java.awt.GraphicsConfiguration; +import com.sun.j3d.utils.applet.MainFrame; import com.sun.j3d.utils.geometry.ColorCube; +import com.sun.j3d.utils.universe.*; import javax.media.j3d.*; import javax.vecmath.*; -import java.awt.GraphicsConfiguration; -/** - * Simple Java 3D example program to display a spinning cube. - */ -public class HelloUniverse extends javax.swing.JFrame { - - private SimpleUniverse univ = null; - private BranchGroup scene = null; +public class HelloUniverse extends Applet { + private SimpleUniverse u = null; + public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); @@ -91,77 +91,37 @@ public class HelloUniverse extends javax.swing.JFrame { return objRoot; } - private Canvas3D createUniverse() { - // Get the preferred graphics configuration for the default screen - GraphicsConfiguration config = - SimpleUniverse.getPreferredConfiguration(); + public HelloUniverse() { + } + + public void init() { + setLayout(new BorderLayout()); + GraphicsConfiguration config = + SimpleUniverse.getPreferredConfiguration(); - // Create a Canvas3D using the preferred configuration Canvas3D c = new Canvas3D(config); + add("Center", c); - // Create simple universe with view branch - univ = new SimpleUniverse(c); - - // This will move the ViewPlatform back a bit so the - // objects in the scene can be viewed. - univ.getViewingPlatform().setNominalViewingTransform(); + // Create a simple scene and attach it to the virtual universe + BranchGroup scene = createSceneGraph(); + u = new SimpleUniverse(c); - // Ensure at least 5 msec per frame (i.e., < 200Hz) - univ.getViewer().getView().setMinimumFrameCycleTime(5); + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + u.getViewingPlatform().setNominalViewingTransform(); - return c; + u.addBranchGraph(scene); } - /** - * Creates new form HelloUniverse - */ - public HelloUniverse() { - // Initialize the GUI components - initComponents(); - - // Create Canvas3D and SimpleUniverse; add canvas to drawing panel - Canvas3D c = createUniverse(); - drawingPanel.add(c, java.awt.BorderLayout.CENTER); - - // Create the content branch and add it to the universe - scene = createSceneGraph(); - univ.addBranchGraph(scene); + public void destroy() { + u.cleanup(); } - // ---------------------------------------------------------------- - - /** This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. - */ - // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents - private void initComponents() { - drawingPanel = new javax.swing.JPanel(); - - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - setTitle("HelloUniverse"); - drawingPanel.setLayout(new java.awt.BorderLayout()); - - drawingPanel.setPreferredSize(new java.awt.Dimension(250, 250)); - getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER); - - pack(); - }// </editor-fold>//GEN-END:initComponents - - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - new HelloUniverse().setVisible(true); - } - }); + // + // The following allows HelloUniverse to be run as an application + // as well as an applet + // + public static void main(String[] args) { + new MainFrame(new HelloUniverse(), 256, 256); } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JPanel drawingPanel; - // End of variables declaration//GEN-END:variables - } diff --git a/src/HelloUniverse/HelloUniverse_plugin.html b/src/HelloUniverse/HelloUniverse_plugin.html new file mode 100644 index 0000000..947a59b --- /dev/null +++ b/src/HelloUniverse/HelloUniverse_plugin.html @@ -0,0 +1,39 @@ +<HTML> +<HEAD> +<TITLE>Hello, Universe!</TITLE> +</HEAD> +<BODY BGCOLOR="#000000"> +<!--"CONVERTED_APPLET"--> +<!-- CONVERTER VERSION 1.3 --> +<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" +WIDTH = 256 HEIGHT = 256 ALIGN = middle codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"> +<PARAM NAME = CODE VALUE = "HelloUniverse.class" > + +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.2.2"> +<PARAM NAME="scriptable" VALUE="false"> +<COMMENT> +<EMBED type="application/x-java-applet;version=1.2.2" CODE = "HelloUniverse.class" WIDTH = 256 HEIGHT = 256 ALIGN = middle scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED></COMMENT> +<blockquote> +<hr> +If you were using a Java-capable browser, +you would see Hello Universe! instead of this paragraph. +<hr> +</blockquote> +</NOEMBED></EMBED> +</OBJECT> + +<!-- +<APPLET CODE = "HelloUniverse.class" WIDTH = 256 HEIGHT = 256 ALIGN = middle> +<blockquote> +<hr> +If you were using a Java-capable browser, +you would see Hello Universe! instead of this paragraph. +<hr> +</blockquote> + +</APPLET> +--> +<!--"END_CONVERTED_APPLET"--> + +</BODY> +</HTML> diff --git a/src/HelloUniverse/build.xml b/src/HelloUniverse/build.xml index 4e57328..47e5a36 100644 --- a/src/HelloUniverse/build.xml +++ b/src/HelloUniverse/build.xml @@ -4,7 +4,7 @@ /* * $RCSfile$ * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions |