Class ViewFrame

All Implemented Interfaces:
WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants

public class ViewFrame extends JFrame implements WindowListener
Convenience window (JFrame) that creates and hosts a ViewPanel for 3D rendering.

This is the simplest way to get a 3D view up and running. The frame starts maximized, enforces a minimum size of 400x400, and handles window lifecycle events (minimizing, restoring, closing) automatically.

Quick start:


 // Create a window with a 3D view
 ViewFrame frame = new ViewFrame();

 // Access the view panel to add shapes and configure the scene
 ViewPanel viewPanel = frame.getViewPanel();
 viewPanel.getRootShapeCollection().addShape(
     new WireframeCube(new Point3D(0, 0, 200), 50,
         new LineAppearance(5, Color.GREEN))
 );

 // To close programmatically:
 frame.exit();
 
See Also:
  • Constructor Details

    • ViewFrame

      public ViewFrame()
      Creates a new maximized window with a 3D view.
    • ViewFrame

      public ViewFrame(String title)
      Creates a new maximized window with a 3D view and custom title.
      Parameters:
      title - the window title to display
    • ViewFrame

      public ViewFrame(int width, int height)
      Creates a new window with a 3D view at the specified size.
      Parameters:
      width - window width in pixels, or -1 for default
      height - window height in pixels, or -1 for default
    • ViewFrame

      public ViewFrame(String title, int width, int height)
      Creates a new window with a 3D view at the specified size with a custom title.
      Parameters:
      title - the window title to display
      width - window width in pixels, or -1 for default
      height - window height in pixels, or -1 for default
  • Method Details