Java3D JFrame Source Code

This class is the basic JFrame class for Java3D applications, feel free to use this code however you wish.

 * Basic Java3D JFrame Class
 * Developed for

import java.awt.BorderLayout;
import java.awt.GraphicsConfiguration;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.ToolTipManager;

import com.sun.j3d.utils.universe.SimpleUniverse;

//JFrame class inherits the code from the Swing JPanel class.
public class Main extends JPanel {

	//The constructor method
	public Main() {

		//Set the layout, this is just a standard thing.
		setLayout(new BorderLayout());

		//Get the preferred graphics configuration for the default screen
		GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();

		//Create a Canvas3D using the preferred configuration
		Canvas3D canvas = new Canvas3D(config);

		//Create a Simple Universe with view branch
		SimpleUniverse universe = new SimpleUniverse(canvas);

		//Create the root of the branch graph
		BranchGroup group = new BranchGroup();

		//Add the canvas into the center of the screen
		add("Center", canvas);

		//This will move the ViewPlatform back so the objects in the scene can be viewed

		//Set the render distance of objects

		//Add the branch into the Universe


	//Main method
	public static void main(String[] args) {
		//Set the No Erase Background property to true
		System.setProperty("sun.awt.noerasebackground", "true");

		//Disable the JPopupMenu

		//Create an instance for the ToolTipManager
		ToolTipManager ttm = ToolTipManager.sharedInstance();

		//Disable the ToolTipManager

		//Create object instance
		Main main = new Main();

		//Create new JFrame instance
		JFrame frame = new JFrame("This is a Default JFrame Created by Just Java 3D");

		//Set the size of the JFrame
		frame.setSize(750, 500);

		//The frame will now hold the main canvas

		//Make sure the frame is actually visisble