public class ApplicationFrame
extends javax.swing.JFrame
This class provides the infrastructure for creating applications (which extend this class) and provides them with utilities for creating a main window with a title and default close and dispose behavior, as well as access to properties, and a window snapshot function.
javax.swing.JFrame.AccessibleJFrame
java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
Modifier and Type | Field and Description |
---|---|
protected static java.util.ResourceBundle |
resourceBundle |
protected static java.lang.String |
resourceBundleName |
protected com.pixelmed.display.StatusBarManager |
statusBarManager |
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
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
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Constructor and Description |
---|
ApplicationFrame()
Construct a window with the default size and title and no property source.
|
ApplicationFrame(int closeOperation)
Construct a window with the default size and title and no property source.
|
ApplicationFrame(java.lang.String title)
Construct a window with the default size, specified title and no property source.
|
ApplicationFrame(java.lang.String title,
int closeOperation)
Construct a window with the default size, specified title and no property source.
|
ApplicationFrame(java.lang.String title,
java.lang.String applicationPropertyFileName)
Construct a window with the default size, and specified title and property sources.
|
ApplicationFrame(java.lang.String title,
java.lang.String applicationPropertyFileName,
int closeOperation)
Construct a window with the default size, and specified title and property sources.
|
ApplicationFrame(java.lang.String title,
java.lang.String applicationPropertyFileName,
int w,
int h)
Construct a window with the specified size, title and property sources.
|
ApplicationFrame(java.lang.String title,
java.lang.String applicationPropertyFileName,
int w,
int h,
int closeOperation)
Construct a window with the specified size, title and property sources.
|
Modifier and Type | Method and Description |
---|---|
protected void |
createGUI()
Do what is necessary to build an application window.
|
protected java.lang.String |
getApplicationPropertyFileName()
Get the name of the property file set for the application.
|
static boolean |
getBooleanPropertyOrDefaultAndAddIt(java.util.Properties properties,
java.lang.String key,
boolean defaultValue)
Get the value of a boolean property from the specified property list or a default, adding it.
|
boolean |
getBooleanPropertyOrDefaultAndAddIt(java.lang.String key,
boolean defaultValue)
Get the value of a boolean property from this application's property list or a default, adding it.
|
protected static java.lang.String |
getBuildDate()
Get the date the package was built.
|
static int |
getIntegerPropertyOrDefaultAndAddIt(java.util.Properties properties,
java.lang.String key,
int defaultValue)
Get the value of an integer property from the specified property list or a default, adding it.
|
int |
getIntegerPropertyOrDefaultAndAddIt(java.lang.String key,
int defaultValue)
Get the value of an integer property from this application's property list or a default, adding it.
|
protected java.util.Properties |
getProperties()
Get the properties for the application that have already been loaded (see
loadProperties() ). |
static java.lang.String |
getPropertyInsistently(java.util.Properties properties,
java.lang.String key)
Searches for the property with the specified key in the specified property list, insisting on a value.
|
java.lang.String |
getPropertyInsistently(java.lang.String key)
Searches for the property with the specified key in this application's property list, insisting on a value.
|
static java.lang.String |
getPropertyOrDefaultAndAddIt(java.util.Properties properties,
java.lang.String key,
java.lang.String defaultValue)
Get the value of a property from the specified property list or a default, adding it.
|
java.lang.String |
getPropertyOrDefaultAndAddIt(java.lang.String key,
java.lang.String defaultValue)
Get the value of a property from this application's property list or a default, adding it.
|
protected static java.lang.String |
getReleaseString()
Get the release string for this application.
|
protected javax.swing.JLabel |
getStatusBar()
Setup a StatusBarManager and return its StatusBar.
|
protected void |
loadProperties()
Store the properties from the current properties file.
|
protected static void |
localizeJOptionPane() |
static void |
main(java.lang.String[] arg)
For testing.
|
protected static java.lang.String |
makePathToFileInUsersHomeDirectory(java.lang.String fileName)
Given a file name, such as the properties file name, make a path to it in the user's home directory.
|
protected void |
setApplicationPropertyFileName(java.lang.String applicationPropertyFileName)
Set the name of the property file set for the application.
|
static void |
setBackgroundForGUI()
Setup background for UI.
|
static void |
setInternationalizedFontsForGUI()
Setup internationalized fonts if possible.
|
static void |
setPreferredLookAndFeelForPlatform()
Setup preferred Look and Feel.
|
protected void |
storeProperties(java.lang.String comment)
Store the current properties in the current properties file.
|
protected java.io.File |
takeSnapShot(java.awt.Rectangle extent)
Store a JPEG snapshot of the specified window in the user's home directory.
|
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, 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, setSize, setType, setVisible, show, toBack, toFront
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
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, 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, 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, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
protected static java.util.ResourceBundle resourceBundle
protected static java.lang.String resourceBundleName
protected com.pixelmed.display.StatusBarManager statusBarManager
public ApplicationFrame()
Construct a window with the default size and title and no property source.
Does not show the window.
Will exit the application when the window closes.
public ApplicationFrame(int closeOperation)
Construct a window with the default size and title and no property source.
Does not show the window.
closeOperation
- argument to setDefaultCloseOperation()
public ApplicationFrame(java.lang.String title)
Construct a window with the default size, specified title and no property source.
Does not show the window.
Will exit the application when the window closes.
title
- the title for the top bar decorationpublic ApplicationFrame(java.lang.String title, int closeOperation)
Construct a window with the default size, specified title and no property source.
Does not show the window.
title
- the title for the top bar decorationcloseOperation
- argument to setDefaultCloseOperation()
public ApplicationFrame(java.lang.String title, java.lang.String applicationPropertyFileName)
Construct a window with the default size, and specified title and property sources.
Does not show the window.
Will exit the application when the window closes.
title
- the title for the top bar decorationapplicationPropertyFileName
- the name of the properties filepublic ApplicationFrame(java.lang.String title, java.lang.String applicationPropertyFileName, int closeOperation)
Construct a window with the default size, and specified title and property sources.
Does not show the window.
title
- the title for the top bar decorationapplicationPropertyFileName
- the name of the properties filecloseOperation
- argument to setDefaultCloseOperation()
public ApplicationFrame(java.lang.String title, java.lang.String applicationPropertyFileName, int w, int h)
Construct a window with the specified size, title and property sources.
Does not show the window.
Will exit the application when the window closes.
title
- the title for the top bar decorationapplicationPropertyFileName
- the name of the properties filew
- widthh
- heightpublic ApplicationFrame(java.lang.String title, java.lang.String applicationPropertyFileName, int w, int h, int closeOperation)
Construct a window with the specified size, title and property sources.
Does not show the window.
title
- the title for the top bar decorationapplicationPropertyFileName
- the name of the properties filew
- widthh
- heightcloseOperation
- argument to setDefaultCloseOperation()
protected void createGUI()
Do what is necessary to build an application window.
Invoked by constructors.
Sub-classes should call this if they do not use the super() constructors, but should NOT usually need to override it, but rather should override the methods that it calls.
protected java.lang.String getApplicationPropertyFileName()
Get the name of the property file set for the application.
public static boolean getBooleanPropertyOrDefaultAndAddIt(java.util.Properties properties, java.lang.String key, boolean defaultValue)
Get the value of a boolean property from the specified property list or a default, adding it.
Adds the default property to he specified property list if not already present.
properties
- the property list to searchkey
- the property namedefaultValue
- the value to use if absentpublic boolean getBooleanPropertyOrDefaultAndAddIt(java.lang.String key, boolean defaultValue)
Get the value of a boolean property from this application's property list or a default, adding it.
Adds the default property to this application's property list if not already present.
key
- the property namedefaultValue
- the value to use if absentprotected static java.lang.String getBuildDate()
Get the date the package was built.
public static int getIntegerPropertyOrDefaultAndAddIt(java.util.Properties properties, java.lang.String key, int defaultValue)
Get the value of an integer property from the specified property list or a default, adding it.
Adds the default property to he specified property list if not already present.
properties
- the property list to searchkey
- the property namedefaultValue
- the value to use if absentpublic int getIntegerPropertyOrDefaultAndAddIt(java.lang.String key, int defaultValue)
Get the value of an integer property from this application's property list or a default, adding it.
Adds the default property to this application's property list if not already present.
key
- the property namedefaultValue
- the value to use if absentprotected java.util.Properties getProperties()
Get the properties for the application that have already been loaded (see loadProperties()
).
public static java.lang.String getPropertyInsistently(java.util.Properties properties, java.lang.String key) throws java.lang.Exception
Searches for the property with the specified key in the specified property list, insisting on a value.
properties
- the property list to searchkey
- the property namejava.lang.Exception
- if there is no such property or it has no valuepublic java.lang.String getPropertyInsistently(java.lang.String key) throws java.lang.Exception
Searches for the property with the specified key in this application's property list, insisting on a value.
key
- the property namejava.lang.Exception
- if there is no such property or it has no valuepublic static java.lang.String getPropertyOrDefaultAndAddIt(java.util.Properties properties, java.lang.String key, java.lang.String defaultValue)
Get the value of a property from the specified property list or a default, adding it.
Adds the default property to he specified property list if not already present.
properties
- the property list to searchkey
- the property namedefaultValue
- the value to use if absentpublic java.lang.String getPropertyOrDefaultAndAddIt(java.lang.String key, java.lang.String defaultValue)
Get the value of a property from this application's property list or a default, adding it.
Adds the default property to this application's property list if not already present.
key
- the property namedefaultValue
- the value to use if absentprotected static java.lang.String getReleaseString()
Get the release string for this application.
protected javax.swing.JLabel getStatusBar()
Setup a StatusBarManager and return its StatusBar.
The initial string in the StatusBar is composed of the build date and release string.
protected void loadProperties()
Store the properties from the current properties file.
protected static void localizeJOptionPane()
public static void main(java.lang.String[] arg)
For testing.
Shows an empty default sized window.
arg
- ignoredprotected static java.lang.String makePathToFileInUsersHomeDirectory(java.lang.String fileName)
Given a file name, such as the properties file name, make a path to it in the user's home directory.
fileName
- the file name to make a path toprotected void setApplicationPropertyFileName(java.lang.String applicationPropertyFileName)
Set the name of the property file set for the application.
applicationPropertyFileName
- the property file namepublic static void setBackgroundForGUI()
Setup background for UI.
Invoked by createGUI()
.
public static void setInternationalizedFontsForGUI()
Setup internationalized fonts if possible.
Invoked by createGUI()
.
public static void setPreferredLookAndFeelForPlatform()
Setup preferred Look and Feel.
Invoked by createGUI()
.
protected void storeProperties(java.lang.String comment) throws java.io.IOException
Store the current properties in the current properties file.
comment
- the description to store as the header of the properties filejava.io.IOException
protected java.io.File takeSnapShot(java.awt.Rectangle extent)
Store a JPEG snapshot of the specified window in the user's home directory.
extent
- the rectangle to take a snapshot of (typically this.getBounds()
for whole application)