Package org.opensourcephysics.display
Class OSPFrame
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
org.opensourcephysics.display.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
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.Type
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
protected boolean
Set to true if a simulation should automatically render this frame after every animation step.protected boolean
Set to true if a simulation should automatically clear the data when it is initialized.protected JPanel
protected Collection<JFrame>
The thread group that created this object.protected boolean
protected int
protected BufferStrategy
Fields inherited from class javax.swing.JFrame
accessibleContext, rootPane, rootPaneCheckingEnabled
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a custom button to the control's frame.void
addChildFrame
(JFrame frame) Adds a child frame that depends on this frame.void
Shows (repaints) the frame useing the current BufferStrategy.void
Clears all frames from the child frame list.void
Clears data from drawing objects within this frame.void
Clears data and repaints the drawing panel within this frame.void
Creates a BufferStrategy based on the capabilites of the hardware.void
dispose()
Disposes all resources.Gets a copy of the ChildFrames collection.static JFileChooser
Deprecated.Gets the ThreadGroup that constructed this frame.Gets a menu with the given name from the menu bar.void
Invalidates image buffers if a drawing panel is buffered.boolean
Reads the animated property.boolean
Reads the animated property.boolean
Gets the ICONIFIED flag for this frame.boolean
Reads the keepHidden flag.protected JMenu
Adds a Display menu to the menu bar.protected JMenu
Adds a Tools menu to the menu bar.void
parseXMLMenu
(String xmlMenu) void
parseXMLMenu
(String xmlMenu, Class<?> type) protected void
Refreshes the user interface in response to display changes such as Language.removeMenu
(String menuName) Removes a menu with the given name from the menu bar and returns the removed item.removeMenuItem
(String menuName, 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.protected void
setFontLevel
(int level) Sets the font level.void
setKeepHidden
(boolean _keepHidden) Sets the keepHidden flag.void
Sets the window resize action for JavaScript implementation.void
setSize
(int width, int height) void
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 parameterb
and thekeepHidden
flag.void
show()
Deprecated.boolean
Returns true if this frame wishes to exit.Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setUndecorated
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setType, 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, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, 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, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, 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 Details
-
customButtons
-
animated
protected boolean animatedSet to true if a simulation should automatically render this frame after every animation step. -
autoclear
protected boolean autoclearSet to true if a simulation should automatically clear the data when it is initialized. -
constructorThreadGroup
The thread group that created this object. -
keepHidden
protected boolean keepHidden -
strategy
-
buttonPanel
-
childFrames
-
myFontLevel
protected int myFontLevel -
action
-
-
Constructor Details
-
OSPFrame
OSPFrame constructor with a title.- Parameters:
title
-
-
OSPFrame
public OSPFrame()OSPFrame constructor. -
OSPFrame
OSPFrame constructor with a new content pane.- Parameters:
contentPane
-
-
-
Method Details
-
getChooser
Deprecated.useOSPRuntime.getChooser()<\code>.
Gets a file chooser that is the same for all OSPFrames.- Returns:
- the chooser
-
setResizeAction
Sets the window resize action for JavaScript implementation. -
setTitle
Sets the title for this frame to the specified string after converting TeX math symbols to characters. -
addChildFrame
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
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
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
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) -
show
Deprecated.Shows the frame on the screen if the keep hidden flag is false. -
dispose
public void dispose()Disposes all resources. -
setVisible
public void setVisible(boolean b) Shows or hides this component depending on the value of parameterb
and thekeepHidden
flag. OSP Applets often keep windows hidden.- Overrides:
setVisible
in classWindow
- Parameters:
b
-
-
setKeepHidden
public void setKeepHidden(boolean _keepHidden) Sets the keepHidden flag.- Specified by:
setKeepHidden
in interfaceHidable
- Parameters:
_keepHidden
-
-
isKeepHidden
public boolean isKeepHidden()Reads the keepHidden flag.- Specified by:
isKeepHidden
in interfaceHidable
-
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
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
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
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
-
parseXMLMenu
-
refreshGUI
protected void refreshGUI()Refreshes the user interface in response to display changes such as Language. -
addButton
Adds a custom button to the control's frame.- Parameters:
methodName
- the name of the method; the method has no parameterstext
- the button's text labeltoolTipText
- the button's tool tip texttarget
- 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 interfaceAppFrame
- Overrides:
setDefaultCloseOperation
in classJFrame
- 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 interfaceAppFrame
- Returns:
- true if this frame wishes to exit
-
OSPRuntime.getChooser()<\code>.