ehsbe CommonsTM
Version 1.1.0rc3

com.ehsbe.commons.gui
Class AppFrame

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
                          extended by com.ehsbe.commons.gui.AppFrame
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class AppFrame
extends org.jdesktop.swingx.JXFrame

The application Frame.

Version:
$Revision: 497 $
Author:
Jens Elkner
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jdesktop.swingx.JXFrame
org.jdesktop.swingx.JXFrame.StartPosition
 
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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String ACTION_FILE_QUIT
          the command, which gets send, when the frame receives a WindowEvent.WINDOW_CLOSING event
static int PREF_APP_HEIGHT_DEFAULT
          default value to be used for the frames height
static String PREF_APP_HEIGHT_KEY
          key to be used for reading/storing the frames height in preferences
static int PREF_APP_WIDTH_DEFAULT
          default value to be used for the frames width
static String PREF_APP_WIDTH_KEY
          key to be used for reading/storing the frames width in preferences
static int PREF_APP_X_DEFAULT
          default value to be used for the frames x position
static String PREF_APP_X_KEY
          key to be used for reading/storing the frames x position in preferences
static int PREF_APP_Y_DEFAULT
          default value to be used for the frames y position
static String PREF_APP_Y_KEY
          key to be used for reading/storing the frames y position in preferences
 
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
AppFrame()
          Construct the frame using the default locale.
AppFrame(Locale locale)
          Construct a new frame using the given locale.
 
Method Summary
 void dispose()
          
 ActionManager getManager()
          Get the action manager attached to this frame
<T> T
getProperty(Class<T> clazz, String key)
          Get user data
 boolean hasJxStatusBar()
          Convinience method to check, whether the frame uses an enhanced JxStatusBar.
protected  void processWindowEvent(WindowEvent e)
          Overridden, so that a controller may intercept the window closing event.
 void putProperty(String key, Object value)
          Set user data.
 void saveLocation(Preferences prefs)
          Save the current location of the frame to the given preferences.
 void saveSize(Preferences prefs)
          Save the current size of the frame into the given preferences.
 void setIconImage(String path)
          Set the image to be displayed when minimized.
 void setLocation(Preferences prefs)
          Try to set the location of the frame using the given preferences.
 void setSize(Preferences prefs)
          Try to set the size of the frame using the given preferences.
 void setStatusBar(org.jdesktop.swingx.JXStatusBar statusBar)
          Use this method to set a statusbar.
 
Methods inherited from class org.jdesktop.swingx.JXFrame
createRootPane, getCancelButton, getDefaultButton, getIdleThreshold, getKeyPreview, getRootPaneExt, getStartPosition, getStatusBar, getToolBar, getWaitPane, isIdle, isWaitCursorVisible, isWaiting, isWaitPaneVisible, setCancelButton, setCursor, setDefaultButton, setIdle, setIdleThreshold, setKeyPreview, setRootPane, setStartPosition, setToolBar, setVisible, setWaitCursorVisible, setWaiting, setWaitPane, setWaitPaneVisible
 
Methods inherited from class javax.swing.JFrame
addImpl, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPaneCheckingEnabled, 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, setTitle, 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, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, 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, 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, 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, requestFocusInWindow, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

ACTION_FILE_QUIT

public static final String ACTION_FILE_QUIT
the command, which gets send, when the frame receives a WindowEvent.WINDOW_CLOSING event

See Also:
Constant Field Values

PREF_APP_WIDTH_KEY

public static final String PREF_APP_WIDTH_KEY
key to be used for reading/storing the frames width in preferences

See Also:
Constant Field Values

PREF_APP_WIDTH_DEFAULT

public static final int PREF_APP_WIDTH_DEFAULT
default value to be used for the frames width

See Also:
Constant Field Values

PREF_APP_HEIGHT_KEY

public static final String PREF_APP_HEIGHT_KEY
key to be used for reading/storing the frames height in preferences

See Also:
Constant Field Values

PREF_APP_HEIGHT_DEFAULT

public static final int PREF_APP_HEIGHT_DEFAULT
default value to be used for the frames height

See Also:
Constant Field Values

PREF_APP_X_KEY

public static final String PREF_APP_X_KEY
key to be used for reading/storing the frames x position in preferences

See Also:
Constant Field Values

PREF_APP_X_DEFAULT

public static final int PREF_APP_X_DEFAULT
default value to be used for the frames x position

See Also:
Constant Field Values

PREF_APP_Y_KEY

public static final String PREF_APP_Y_KEY
key to be used for reading/storing the frames y position in preferences

See Also:
Constant Field Values

PREF_APP_Y_DEFAULT

public static final int PREF_APP_Y_DEFAULT
default value to be used for the frames y position

See Also:
Constant Field Values
Constructor Detail

AppFrame

public AppFrame()
Construct the frame using the default locale.


AppFrame

public AppFrame(Locale locale)
Construct a new frame using the given locale.

Parameters:
locale - locale to use. If null the default locale will be used instead.
Method Detail

setIconImage

public void setIconImage(String path)
Set the image to be displayed when minimized.

Parameters:
path - the path to the image resource, which should be loaded via the current context classloader. Ignored if null.

setSize

public void setSize(Preferences prefs)
Try to set the size of the frame using the given preferences.

Parameters:
prefs - preferences to use for looking up PREF_APP_HEIGHT_KEY and PREF_APP_WIDTH_KEY. If the keys are not found, the appropriate default values will be used. If prefs is null, this method does nothing.

saveSize

public void saveSize(Preferences prefs)
Save the current size of the frame into the given preferences.

Parameters:
prefs - where to store all values. Ignored if null.

setLocation

public void setLocation(Preferences prefs)
Try to set the location of the frame using the given preferences. It takes the frames size into account by reducing its size in that way, that it is not larger than the whole screen and repositions the frame so that it is as close as possible to the given location, so that the whole frame is visible at the screen.

Parameters:
prefs - preferences to use for looking up PREF_APP_X_KEY and PREF_APP_Y_KEY. If the keys are not found, the appropriate default values will be used. If prefs is null, this method does nothing.
See Also:
Toolkit.getScreenSize()

saveLocation

public void saveLocation(Preferences prefs)
Save the current location of the frame to the given preferences.

Parameters:
prefs - Where to store the values. Ignored if null.

processWindowEvent

protected void processWindowEvent(WindowEvent e)
Overridden, so that a controller may intercept the window closing event.

It is done by obtaining the ACTION_FILE_QUIT action of the actionManager for this frame, and fireing the actions actionPerformed method with an ManagedActionEvent. The event contains this frame as source and the ACTION_FILE_QUIT as action command.

Since the fired event is a managed event, a controller, which is registered with the manager of the fram or the action itself may stop/ veto disposing the frame by calling ManagedActionEvent.stopDispatching()

Overrides:
processWindowEvent in class JFrame
Parameters:
e -

dispose

public void dispose()

Overrides:
dispose in class Window

getManager

public ActionManager getManager()
Get the action manager attached to this frame

Returns:
null if no action manager has been set

putProperty

public void putProperty(String key,
                        Object value)
Set user data.

Parameters:
key - property key
value - property value

getProperty

public <T> T getProperty(Class<T> clazz,
                         String key)
Get user data

Type Parameters:
T - type of the value
Parameters:
clazz - class of the value
key - key for the data to retrieve.
Returns:
null if not found, the value otherwise.

setStatusBar

public void setStatusBar(org.jdesktop.swingx.JXStatusBar statusBar)
Use this method to set a statusbar. So that it gets tracked, whether it has an enhanced JxStatusBar and also fixes some bugs in the original.

Overrides:
setStatusBar in class org.jdesktop.swingx.JXFrame

hasJxStatusBar

public boolean hasJxStatusBar()
Convinience method to check, whether the frame uses an enhanced JxStatusBar.

Returns:
a via setStatusBar(JXStatusBar) cached value.

ehsbe CommonsTM
Version 1.1.0rc3

Copyright ©2005-2009 EHSBE, Walther-Rathenau-Str. 58, 39104 Magdeburg, Sachsen-Anhalt, Germany. All Rights Reserved.