Class OSPFrame

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants, AppFrame, Hidable
Direct Known Subclasses:
ArrayFrame, ControlFrame, DataTableFrame, DataTool, DrawingFrame, DrawingFrame3D, GridTableFrame, ImageFrame, TableFrame, TFrame

public class OSPFrame extends JFrame implements Hidable, AppFrame
OSPFrame is the base class for Open Source Physics JFrames such as DrawingFrame and DataTableFrame. Copyright: Copyright (c) 2002
Version:
1.1
Author:
Wolfgang Christian
See Also:
  • Field Details

    • customButtons

      protected ArrayList<JButton> customButtons
    • animated

      protected boolean animated
      Set to true if a simulation should automatically render this frame after every animation step.
    • autoclear

      protected boolean autoclear
      Set to true if a simulation should automatically clear the data when it is initialized.
    • constructorThreadGroup

      public ThreadGroup constructorThreadGroup
      The thread group that created this object.
    • keepHidden

      protected boolean keepHidden
    • strategy

      protected BufferStrategy strategy
    • buttonPanel

      protected JPanel buttonPanel
    • childFrames

      protected Collection<JFrame> childFrames
    • myFontLevel

      protected int myFontLevel
    • action

      protected String action
  • Constructor Details

    • OSPFrame

      public OSPFrame(String title)
      OSPFrame constructor with a title.
      Parameters:
      title -
    • OSPFrame

      public OSPFrame()
      OSPFrame constructor.
    • OSPFrame

      public OSPFrame(Container contentPane)
      OSPFrame constructor with a new content pane.
      Parameters:
      contentPane -
  • Method Details

    • getChooser

      @Deprecated public static JFileChooser getChooser()
      Deprecated.
      use OSPRuntime.getChooser()<\code>.
      Gets a file chooser that is the same for all OSPFrames.
      Returns:
      the chooser
    • setResizeAction

      public void setResizeAction(String o)
      Sets the window resize action for JavaScript implementation.
    • setTitle

      public void setTitle(String title)
      Sets the title for this frame to the specified string after converting TeX math symbols to characters.
      Overrides:
      setTitle in class Frame
      Parameters:
      title - the title to be displayed in the frame's border. A null value is treated as an empty string, "".
      See Also:
    • addChildFrame

      public void addChildFrame(JFrame frame)
      Adds a child frame that depends on this frame. Child frames are closed when this frame is closed.
      Parameters:
      frame - JFrame
    • clearChildFrames

      public void clearChildFrames()
      Clears all frames from the child frame list.
    • getChildFrames

      public Collection<JFrame> getChildFrames()
      Gets a copy of the ChildFrames collection.
      Returns:
      Collection
    • isIconified

      public boolean isIconified()
      Gets the ICONIFIED flag for this frame.
      Returns:
      boolean true if frame is iconified; false otherwise
    • invalidateImage

      public void invalidateImage()
      Invalidates image buffers if a drawing panel is buffered.
    • setFontLevel

      protected void setFontLevel(int level)
      Sets the font level.
      Parameters:
      level - the level
    • isAnimated

      public boolean isAnimated()
      Reads the animated property.
      Returns:
      boolean
    • setAnimated

      public void setAnimated(boolean animated)
      Sets the animated property.
      Parameters:
      animated -
    • isAutoclear

      public boolean isAutoclear()
      Reads the animated property.
      Returns:
      boolean
    • setAutoclear

      public void setAutoclear(boolean autoclear)
      Sets the autoclear property.
      Parameters:
      autoclear -
    • loadDisplayMenu

      protected JMenu loadDisplayMenu()
      Adds a Display menu to the menu bar. The default method does nothing. Override this method to create a menu item that is appropriate for the frame.
    • loadToolsMenu

      protected JMenu loadToolsMenu()
      Adds a Tools menu to the menu bar. The default method does nothing. Override this method to create a menu item that is appropriate for the frame.
    • clearData

      public void clearData()
      Clears data from drawing objects within this frame. The default method does nothing. Override this method to select the object(s) and the data to be cleared.
    • clearDataAndRepaint

      public void clearDataAndRepaint()
      Clears data and repaints the drawing panel within this frame. The default method does nothing. Override this method to clear and repaint objects that have data.
    • setSize

      public void setSize(int width, int height)
      Overrides:
      setSize in class Window
    • show

      @Deprecated public void show()
      Deprecated.
      Shows the frame on the screen if the keep hidden flag is false.
      Overrides:
      show in class Window
    • dispose

      public void dispose()
      Disposes all resources.
      Overrides:
      dispose in class Window
    • setVisible

      public void setVisible(boolean b)
      Shows or hides this component depending on the value of parameter b and the keepHidden flag. OSP Applets often keep windows hidden.
      Overrides:
      setVisible in class Window
      Parameters:
      b -
    • setKeepHidden

      public void setKeepHidden(boolean _keepHidden)
      Sets the keepHidden flag.
      Specified by:
      setKeepHidden in interface Hidable
      Parameters:
      _keepHidden -
    • isKeepHidden

      public boolean isKeepHidden()
      Reads the keepHidden flag.
      Specified by:
      isKeepHidden in interface Hidable
    • getConstructorThreadGroup

      public ThreadGroup getConstructorThreadGroup()
      Gets the ThreadGroup that constructed this frame.
      Returns:
      the ThreadGroup
    • createBufferStrategy

      public void createBufferStrategy()
      Creates a BufferStrategy based on the capabilites of the hardware.
    • bufferStrategyShow

      public void bufferStrategyShow()
      Shows (repaints) the frame useing the current BufferStrategy.
    • render

      public void render()
      Renders the frame. Subclass this method to render the contents of this frame in the calling thread.
    • getMenu

      public JMenu getMenu(String menuName)
      Gets a menu with the given name from the menu bar. Returns null if menu item does not exist.
      Parameters:
      menuName - String
      Returns:
      JMenu
    • removeMenu

      public JMenu removeMenu(String menuName)
      Removes a menu with the given name from the menu bar and returns the removed item. Returns null if menu item does not exist.
      Parameters:
      menuName - String
      Returns:
      JMenu
    • removeMenuItem

      public JMenuItem removeMenuItem(String menuName, String itemName)
      Removes a menu item with the given name from the menu bar and returns the removed item. Returns null if menu item does not exist.
      Parameters:
      menuName - String
      Returns:
      JMenu
    • parseXMLMenu

      public void parseXMLMenu(String xmlMenu)
    • parseXMLMenu

      public void parseXMLMenu(String xmlMenu, Class<?> type)
    • refreshGUI

      protected void refreshGUI()
      Refreshes the user interface in response to display changes such as Language.
    • addButton

      public JButton addButton(String methodName, String text, String toolTipText, Object target)
      Adds a custom button to the control's frame.
      Parameters:
      methodName - the name of the method; the method has no parameters
      text - the button's text label
      toolTipText - the button's tool tip text
      target - the target for the method
      Returns:
      the custom button
    • setDefaultCloseOperation

      public void setDefaultCloseOperation(int operation)
      Overrides JFrame method. This converts EXIT_ON_CLOSE to DISPOSE_ON_CLOSE and sets the wishesToExit flag.
      Specified by:
      setDefaultCloseOperation in interface AppFrame
      Overrides:
      setDefaultCloseOperation in class JFrame
      Parameters:
      operation - the operation
      See Also:
    • wishesToExit

      public boolean wishesToExit()
      Returns true if this frame wishes to exit. Launcher uses this to identify control frames.
      Specified by:
      wishesToExit in interface AppFrame
      Returns:
      true if this frame wishes to exit