org.opensourcephysics.display
Class OSPFrame

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by org.opensourcephysics.display.OSPFrame
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants, AppFrame, Hidable
Direct Known Subclasses:
ArrayFrame, ControlFrame, DataTableFrame, DataTool, DrawingFrame, DrawingFrame3D, GridTableFrame, ImageFrame, TableFrame

public class OSPFrame
extends javax.swing.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:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
 java.lang.ThreadGroup constructorThreadGroup
          The thread group that created this object.
 
Fields inherited from class javax.swing.JFrame
EXIT_ON_CLOSE
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
OSPFrame()
          OSPFrame constructor.
OSPFrame(java.awt.Container contentPane)
          OSPFrame constructor with a new content pane.
OSPFrame(java.lang.String title)
          OSPFrame constructor with a title.
 
Method Summary
 javax.swing.JButton addButton(java.lang.String methodName, java.lang.String text, java.lang.String toolTipText, java.lang.Object target)
          Adds a custom button to the control's frame.
 void addChildFrame(javax.swing.JFrame frame)
          Adds a child frame that depends on this frame.
 void bufferStrategyShow()
          Shows (repaints) the frame useing the current BufferStrategy.
 void clearChildFrames()
          Clears all frames from the child frame list.
 void clearData()
          Clears data from drawing objects within this frame.
 void clearDataAndRepaint()
          Clears data and repaints the drawing panel within this frame.
 void createBufferStrategy()
          Creates a BufferStrategy based on the capabilites of the hardware.
 void dispose()
          Disposes all resources.
 java.util.Collection<javax.swing.JFrame> getChildFrames()
          Gets a copy of the ChildFrames collection.
static javax.swing.JFileChooser getChooser()
          Deprecated. use OSPRuntime.getChooser()<\code>.
 java.lang.ThreadGroup getConstructorThreadGroup()
          Gets the ThreadGroup that constructed this frame.
 javax.swing.JMenu getMenu(java.lang.String menuName)
          Gets a menu with the given name from the menu bar.
 void invalidateImage()
          Invalidates image buffers if a drawing panel is buffered.
 boolean isAnimated()
          Reads the animated property.
 boolean isAutoclear()
          Reads the animated property.
 boolean isIconified()
          Gets the ICONIFIED flag for this frame.
 boolean isKeepHidden()
          Reads the keepHidden flag.
 void parseXMLMenu(java.lang.String xmlMenu)
           
 void parseXMLMenu(java.lang.String xmlMenu, java.lang.Class<?> type)
           
 javax.swing.JMenu removeMenu(java.lang.String menuName)
          Removes a menu with the given name from the menu bar and returns the removed item.
 javax.swing.JMenuItem removeMenuItem(java.lang.String menuName, java.lang.String itemName)
          Removes a menu item with the given name from the menu bar and returns the removed item.
 void render()
          Renders the frame.
 void setAnimated(boolean animated)
          Sets the animated property.
 void setAutoclear(boolean autoclear)
          Sets the autoclear property.
 void setDefaultCloseOperation(int operation)
          Overrides JFrame method.
 void setKeepHidden(boolean _keepHidden)
          Sets the keepHidden flag.
 void setSize(int width, int height)
           
 void setTitle(java.lang.String title)
          Sets the title for this frame to the specified string after converting TeX math symbols to characters.
 void setVisible(boolean b)
          Shows or hides this component depending on the value of parameter b and the keepHidden flag.
 void show()
          Deprecated.  
 boolean wishesToExit()
          Returns true if this frame wishes to exit.
 
Methods inherited from class javax.swing.JFrame
getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, remove, repaint, setContentPane, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opensourcephysics.display.AppFrame
getDefaultCloseOperation
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

constructorThreadGroup

public java.lang.ThreadGroup constructorThreadGroup
The thread group that created this object.

Constructor Detail

OSPFrame

public OSPFrame(java.lang.String title)
OSPFrame constructor with a title.

Parameters:
title -

OSPFrame

public OSPFrame()
OSPFrame constructor.


OSPFrame

public OSPFrame(java.awt.Container contentPane)
OSPFrame constructor with a new content pane.

Parameters:
contentPane -
Method Detail

getChooser

public static javax.swing.JFileChooser getChooser()
Deprecated. use OSPRuntime.getChooser()<\code>.

Gets a file chooser that is the same for all OSPFrames.

Returns:
the chooser

setTitle

public void setTitle(java.lang.String title)
Sets the title for this frame to the specified string after converting TeX math symbols to characters.

Overrides:
setTitle in class java.awt.Frame
Parameters:
title - the title to be displayed in the frame's border. A null value is treated as an empty string, "".
See Also:
Frame.getTitle()

addChildFrame

public void addChildFrame(javax.swing.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 java.util.Collection<javax.swing.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.


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 -

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 java.awt.Window

show

public void show()
Deprecated. 

Shows the frame on the screen if the keep hidden flag is false.

Overrides:
show in class java.awt.Window

dispose

public void dispose()
Disposes all resources.

Overrides:
dispose in class java.awt.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 java.awt.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 java.lang.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 javax.swing.JMenu getMenu(java.lang.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 javax.swing.JMenu removeMenu(java.lang.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 javax.swing.JMenuItem removeMenuItem(java.lang.String menuName,
                                            java.lang.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(java.lang.String xmlMenu)

parseXMLMenu

public void parseXMLMenu(java.lang.String xmlMenu,
                         java.lang.Class<?> type)

addButton

public javax.swing.JButton addButton(java.lang.String methodName,
                                     java.lang.String text,
                                     java.lang.String toolTipText,
                                     java.lang.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 javax.swing.JFrame
Parameters:
operation - the operation
See Also:
AppFrame.getDefaultCloseOperation()

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