public class ApplicationFrame extends 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.
JFrame.AccessibleJFrame
Frame.AccessibleAWTFrame
Window.AccessibleAWTWindow, Window.Type
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
protected static ResourceBundle |
resourceBundle |
protected static 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
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
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(String title)
Construct a window with the default size, specified title and no property source.
|
ApplicationFrame(String title,
int closeOperation)
Construct a window with the default size, specified title and no property source.
|
ApplicationFrame(String title,
String applicationPropertyFileName)
Construct a window with the default size, and specified title and property sources.
|
ApplicationFrame(String title,
String applicationPropertyFileName,
int closeOperation)
Construct a window with the default size, and specified title and property sources.
|
ApplicationFrame(String title,
String applicationPropertyFileName,
int w,
int h)
Construct a window with the specified size, title and property sources.
|
ApplicationFrame(String title,
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 String |
getApplicationPropertyFileName()
Get the name of the property file set for the application.
|
static boolean |
getBooleanPropertyOrDefaultAndAddIt(Properties properties,
String key,
boolean defaultValue)
Get the value of a boolean property from the specified property list or a default, adding it.
|
boolean |
getBooleanPropertyOrDefaultAndAddIt(String key,
boolean defaultValue)
Get the value of a boolean property from this application's property list or a default, adding it.
|
protected static String |
getBuildDate()
Get the date the package was built.
|
static int |
getIntegerPropertyOrDefaultAndAddIt(Properties properties,
String key,
int defaultValue)
Get the value of an integer property from the specified property list or a default, adding it.
|
int |
getIntegerPropertyOrDefaultAndAddIt(String key,
int defaultValue)
Get the value of an integer property from this application's property list or a default, adding it.
|
protected Properties |
getProperties()
Get the properties for the application that have already been loaded (see
loadProperties() ). |
static String |
getPropertyInsistently(Properties properties,
String key)
Searches for the property with the specified key in the specified property list, insisting on a value.
|
String |
getPropertyInsistently(String key)
Searches for the property with the specified key in this application's property list, insisting on a value.
|
static String |
getPropertyOrDefaultAndAddIt(Properties properties,
String key,
String defaultValue)
Get the value of a property from the specified property list or a default, adding it.
|
String |
getPropertyOrDefaultAndAddIt(String key,
String defaultValue)
Get the value of a property from this application's property list or a default, adding it.
|
protected static String |
getReleaseString()
Get the release string for this application.
|
protected 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(String[] arg)
For testing.
|
protected static String |
makePathToFileInUsersHomeDirectory(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(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(String comment)
Store the current properties in the current properties file.
|
protected File |
takeSnapShot(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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getFont, postEvent
protected static ResourceBundle resourceBundle
protected static 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(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(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(String title, 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(String title, 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(String title, 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(String title, 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 String getApplicationPropertyFileName()
Get the name of the property file set for the application.
public static boolean getBooleanPropertyOrDefaultAndAddIt(Properties properties, 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(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 String getBuildDate()
Get the date the package was built.
public static int getIntegerPropertyOrDefaultAndAddIt(Properties properties, 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(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 Properties getProperties()
Get the properties for the application that have already been loaded (see loadProperties()
).
public static String getPropertyInsistently(Properties properties, String key) throws 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 nameException
- if there is no such property or it has no valuepublic String getPropertyInsistently(String key) throws Exception
Searches for the property with the specified key in this application's property list, insisting on a value.
key
- the property nameException
- if there is no such property or it has no valuepublic static String getPropertyOrDefaultAndAddIt(Properties properties, String key, 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 String getPropertyOrDefaultAndAddIt(String key, 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 String getReleaseString()
Get the release string for this application.
protected 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(String[] arg)
For testing.
Shows an empty default sized window.
arg
- ignoredprotected static String makePathToFileInUsersHomeDirectory(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(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(String comment) throws IOException
Store the current properties in the current properties file.
comment
- the description to store as the header of the properties fileIOException