org.jdesktop.swingx
Class JXFrame

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.jdesktop.swingx.JXFrame
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants
Direct Known Subclasses:
JXLoginPane.JXLoginFrame

public class JXFrame
extends JFrame

JXFrame is an enhanced JFrame. While JXFrame can replace any JFrame, it has features that make it particularly useful as the "main" frame for an application.

Additional Features

Root pane: JXFrame uses JXRootPane as its default root pane. The frame provide several convenience methods to provide easy access to the additional features.

Idle: JXFrame offers an idle timer. Registering a PropertyChangeListener for "idle" will notify when the user has not interacted with the JVM. A primary use for this type of functionality is to secure the application, blocking access and requiring the user to login again.

Wait (busy) glass pane: The JXFrame can be configured with an alternate glass pane. Typically, this glass pane is used to notify the user that the application is busy, but the glass pane could be for any purpose. This secondary glass pane can be quickly enabled or disabled by setting the wait pane visible.

See Also:
Serialized Form

Nested Class Summary
static class JXFrame.StartPosition
          An enumeration of JXFrame starting locations.
 
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
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, 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 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
JXFrame()
          Creates a JXFrame with no title and standard closing behavior.
JXFrame(String title)
          Creates a JXFrame with the specified title and default closing behavior.
JXFrame(String title, boolean exitOnClose)
          Creates a JXFrame with the specified title and closing behavior.
 
Method Summary
protected  JRootPane createRootPane()
          Overridden to create a JXRootPane.
 JButton getCancelButton()
          Returns the value of the cancel button property from the underlying JXRootPane.
 JButton getDefaultButton()
          Returns the value of the default button property from the underlying JRootPane.
 long getIdleThreshold()
          Returns the amount of time that must elapse before the frame automatically enters an idle state.
 boolean getKeyPreview()
          Returns the value for the key preview.
 JXRootPane getRootPaneExt()
          Return the extended root pane.
 JXFrame.StartPosition getStartPosition()
          Returns the start position for this frame.
 JXStatusBar getStatusBar()
          Returns the value of the status bar property from the underlying JXRootPane.
 JToolBar getToolBar()
          Returns the value of the tool bar property from the underlying JXRootPane.
 Component getWaitPane()
          Returns the current wait pane for this frame.
 boolean isIdle()
           
 boolean isWaitCursorVisible()
          Returns the state of the wait cursor visibility.
 boolean isWaiting()
          Determines if the frame is in a wait state or not.
 boolean isWaitPaneVisible()
          Returns the current visibility of the wait glass pane.
 void setCancelButton(JButton button)
          Sets the cancel button property on the underlying JXRootPane.
 void setCursor(Cursor c)
          Set the cursor image to a specified cursor.
 void setDefaultButton(JButton button)
          Sets the default button property on the underlying JRootPane.
 void setIdle(boolean idle)
          Sets the frame into an idle state or restores the frame from an idle state.
 void setIdleThreshold(long threshold)
          Sets a threshold for user interaction before automatically placing the frame in an idle state.
 void setKeyPreview(boolean flag)
          If enabled the KeyListeners will receive a preview of the KeyEvent prior to normal viewing.
 void setRootPane(JRootPane root)
          Overridden to make this public.
 void setStartPosition(JXFrame.StartPosition position)
          Sets the start position for this frame.
 void setStatusBar(JXStatusBar statusBar)
          Sets the status bar property on the underlying JXRootPane.
 void setToolBar(JToolBar toolBar)
          Sets the tool bar property on the underlying JXRootPane.
 void setVisible(boolean visible)
          Shows or hides this component depending on the value of parameter b.
 void setWaitCursorVisible(boolean flag)
          Switches the display cursor to or from the wait cursor.
 void setWaiting(boolean waiting)
          Sets the frame into a wait state or restores the frame from a wait state.
 void setWaitPane(Component c)
          Sets the component to use as a wait glass pane.
 void setWaitPaneVisible(boolean flag)
          Enabled or disabled the display of the normal or wait glass pane.
 
Methods inherited from class javax.swing.JFrame
addImpl, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, show, 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, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, 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, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Constructor Detail

JXFrame

public JXFrame()
Creates a JXFrame with no title and standard closing behavior.


JXFrame

public JXFrame(String title)
Creates a JXFrame with the specified title and default closing behavior.

Parameters:
title - the frame title

JXFrame

public JXFrame(String title,
               boolean exitOnClose)
Creates a JXFrame with the specified title and closing behavior.

Parameters:
title - the frame title
exitOnClose - true to override the default (JFrame) closing behavior and use EXIT_ON_CLOSE instead; false to use the default behavior
Method Detail

setCancelButton

public void setCancelButton(JButton button)
Sets the cancel button property on the underlying JXRootPane.

Parameters:
button - the JButton which is to be the cancel button
See Also:
getCancelButton(), JXRootPane.setCancelButton(JButton)

getCancelButton

public JButton getCancelButton()
Returns the value of the cancel button property from the underlying JXRootPane.

Returns:
the JButton which is the cancel button
See Also:
#setCancelButton(), JXRootPane.getCancelButton()

setDefaultButton

public void setDefaultButton(JButton button)
Sets the default button property on the underlying JRootPane.

Parameters:
button - the JButton which is to be the default button
See Also:
getDefaultButton(), JRootPane.setDefaultButton(JButton)

getDefaultButton

public JButton getDefaultButton()
Returns the value of the default button property from the underlying JRootPane.

Returns:
the JButton which is the default button
See Also:
setDefaultButton(JButton), JRootPane.getDefaultButton()

setKeyPreview

public void setKeyPreview(boolean flag)
If enabled the KeyListeners will receive a preview of the KeyEvent prior to normal viewing.

Parameters:
flag - true to enable previewing; false otherwise
See Also:
getKeyPreview(), Component.addKeyListener(KeyListener)

getKeyPreview

public final boolean getKeyPreview()
Returns the value for the key preview.

Returns:
if true previewing is enabled; otherwise it is not
See Also:
setKeyPreview(boolean)

setStartPosition

public void setStartPosition(JXFrame.StartPosition position)
Sets the start position for this frame. Setting this value only has an effect is the frame has never been displayed.

Parameters:
position - the position to display the frame at
See Also:
getStartPosition(), setVisible(boolean)

getStartPosition

public JXFrame.StartPosition getStartPosition()
Returns the start position for this frame.

Returns:
the start position of the frame
See Also:
setStartPosition(StartPosition)

setWaitCursorVisible

public void setWaitCursorVisible(boolean flag)
Switches the display cursor to or from the wait cursor.

Parameters:
flag - true to enable the wait cursor; false to enable the previous cursor
See Also:
isWaitCursorVisible(), Cursor.WAIT_CURSOR

isWaitCursorVisible

public boolean isWaitCursorVisible()
Returns the state of the wait cursor visibility.

Returns:
true if the current cursor is the wait cursor; false otherwise

setCursor

public void setCursor(Cursor c)
Set the cursor image to a specified cursor.

Overrides:
setCursor in class Window
Parameters:
c - One of the constants defined by the Cursor class. If this parameter is null then the cursor for this window will be set to the type Cursor.DEFAULT_CURSOR.
See Also:
Component.getCursor(), Cursor

setWaitPane

public void setWaitPane(Component c)
Sets the component to use as a wait glass pane. This component is not part of the display hierarchy unless isWaitPaneVisible() == true.

Parameters:
c - the wait glass pane for this frame
See Also:
getWaitPane(), setWaitPaneVisible(boolean)

getWaitPane

public Component getWaitPane()
Returns the current wait pane for this frame. This component may or may not be part of the display hierarchy.

Returns:
the current wait pane
See Also:
setWaitPane(Component)

setWaitPaneVisible

public void setWaitPaneVisible(boolean flag)
Enabled or disabled the display of the normal or wait glass pane. If true the wait pane is be displayed. Altering this property alters the display hierarchy.

Parameters:
flag - true to display the wait glass pane; false to display the normal glass pane
See Also:
isWaitPaneVisible(), setWaitPane(Component)

isWaitPaneVisible

public boolean isWaitPaneVisible()
Returns the current visibility of the wait glass pane.

Returns:
true if the wait glass pane is visible; false otherwise

setWaiting

public void setWaiting(boolean waiting)
Sets the frame into a wait state or restores the frame from a wait state.

Parameters:
waiting - true to place the frame in a wait state; false otherwise
See Also:
isWaiting(), setWaitCursorVisible(boolean), setWaitPaneVisible(boolean)

isWaiting

public boolean isWaiting()
Determines if the frame is in a wait state or not.

Returns:
true if the frame is in the wait state; false otherwise
See Also:
setWaiting(boolean)

setVisible

public void setVisible(boolean visible)
Shows or hides this component depending on the value of parameter b.

Overrides:
setVisible in class Component
Parameters:
visible - if true, shows this component; otherwise, hides this component
See Also:
Component.isVisible()

isIdle

public boolean isIdle()

setIdle

public void setIdle(boolean idle)
Sets the frame into an idle state or restores the frame from an idle state.

Parameters:
waiting - true to place the frame in an idle state; false otherwise
See Also:
isIdle(), setIdleThreshold(long)

setIdleThreshold

public void setIdleThreshold(long threshold)
Sets a threshold for user interaction before automatically placing the frame in an idle state.

Parameters:
threshold - the time (in milliseconds) to elapse before setting the frame idle
See Also:
getIdleThreshold(), setIdle(boolean)

getIdleThreshold

public long getIdleThreshold()
Returns the amount of time that must elapse before the frame automatically enters an idle state.

Returns:
the time in milliseconds

setStatusBar

public void setStatusBar(JXStatusBar statusBar)
Sets the status bar property on the underlying JXRootPane.

Parameters:
statusBar - the JXStatusBar which is to be the status bar
See Also:
getStatusBar(), JXRootPane.setStatusBar(JXStatusBar)

getStatusBar

public JXStatusBar getStatusBar()
Returns the value of the status bar property from the underlying JXRootPane.

Returns:
the JXStatusBar which is the current status bar
See Also:
setStatusBar(JXStatusBar), JXRootPane.getStatusBar()

setToolBar

public void setToolBar(JToolBar toolBar)
Sets the tool bar property on the underlying JXRootPane.

Parameters:
toolBar - the JToolBar which is to be the tool bar
See Also:
getToolBar(), JXRootPane.setToolBar(JToolBar)

getToolBar

public JToolBar getToolBar()
Returns the value of the tool bar property from the underlying JXRootPane.

Returns:
the JToolBar which is the current tool bar
See Also:
setToolBar(JToolBar), JXRootPane.getToolBar()

createRootPane

protected JRootPane createRootPane()
Overridden to create a JXRootPane.

Overrides:
createRootPane in class JFrame

setRootPane

public void setRootPane(JRootPane root)
Overridden to make this public.

Overrides:
setRootPane in class JFrame
Parameters:
root - the rootPane object for this frame
See Also:
JFrame.getRootPane()

getRootPaneExt

public JXRootPane getRootPaneExt()
Return the extended root pane. If this frame doesn't contain an extended root pane the root pane should be accessed with getRootPane().

Returns:
the extended root pane or null.