|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
jmri.util.JmriJFrame
public class JmriJFrame
JFrame extended for common JMRI use.
We needed a place to refactor common JFrame additions in JMRI code, so this class was created.
Features:
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE)
If you want this behavior, but need to do something when the
window is closing, override the windowClosing(java.awt.event.WindowEvent) method
to do what you want. Also, if you override dispose(),
make sure to call super.dispose().
If you want the window to just do nothing or just hide, rather than be disposed, when closed, set the DefaultCloseOperation to DO_NOTHING_ON_CLOSE or HIDE_ON_CLOSE depending on what you're looking for.
| 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 |
| 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 |
| Nested classes/interfaces inherited from interface jmri.util.swing.WindowInterface |
|---|
WindowInterface.Hint |
| Field Summary | |
|---|---|
protected boolean |
allowInFrameServlet
|
(package private) static ArrayList<JmriJFrame> |
list
|
protected HashMap<String,Object> |
properties
|
protected boolean |
reuseFrameSavedPosition
|
protected boolean |
reuseFrameSavedSized
|
(package private) static String |
WINDOW_MODIFIED
|
(package private) String |
windowFrameRef
|
protected WindowInterface |
windowInterface
|
| 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 | |
|---|---|
JmriJFrame()
Creates a JFrame with standard settings, including saving/restoring of size and position. |
|
JmriJFrame(boolean saveSize,
boolean savePosition)
Creates a JFrame with standard settings, optional save/restore of size and position. |
|
JmriJFrame(String name)
Creates a JFrame with with given name plus standard settings, including saving/restoring of size and position. |
|
JmriJFrame(String name,
boolean saveSize,
boolean savePosition)
Creates a JFrame with with given name plus standard settings, including optional save/restore of size and position. |
|
| Method Summary | |
|---|---|
void |
addHelpMenu(String ref,
boolean direct)
Add a standard help menu, including window specific help item. |
void |
addNotify()
|
(package private) void |
addWindowCloseShortCut()
Adds a "Close Window" key short cut to close window on op-W. |
void |
componentHidden(ComponentEvent e)
|
void |
componentMoved(ComponentEvent e)
|
void |
componentResized(ComponentEvent e)
|
void |
componentShown(ComponentEvent e)
|
void |
dispose()
When window is finally destroyed, remove it from the list of windows. |
void |
generateWindowRef()
Regenerates the window frame ref that is used for saving and setting frame size and position against. |
boolean |
getAllowInFrameServlet()
|
AbstractAction |
getEscapeKeyAction()
The action associated with the Escape key. |
boolean |
getEscapeKeyClosesWindow()
Does the Escape key close the window? |
Frame |
getFrame()
Returns the WindowInterface as a Frame or null. |
static JmriJFrame |
getFrame(String name)
Get a JmriJFrame of a particular name. |
static List<JmriJFrame> |
getFrameList()
Get a List of the currently-existing JmriJFrame objects. |
static List<JmriJFrame> |
getFrameList(Class<?> subClass)
Get a list of currently-existing JmriJFrame objects that are specific sub-classes of JmriJFrame. |
Object |
getIndexedProperty(String key,
int index)
Get the value of an element in an indexed property. |
Dimension |
getMaximumSize()
Provide a maximum frame size that is limited to what can fit on the screen after toolbars, etc are deducted. |
boolean |
getModifiedFlag()
Get the balue of the modified flag. |
Dimension |
getPreferredSize()
The preferred size must fit on the physical screen, so calculate the lesser of either the preferred size from the layout or the screen size. |
Object |
getProperty(String key)
Get the value of a property. |
Set<String> |
getPropertyNames()
List all property names or keys. |
boolean |
getSavePosition()
Returns if the frame Position is saved or not |
boolean |
getSaveSize()
Returns if the frame Size is saved or not |
String |
getWindowFrameRef()
|
WindowInterface |
getWindowInterface()
|
protected void |
handleModified()
Handle closing a window or quiting the program while the modified bit was set. |
boolean |
hasProperty(String key)
Test that a property exists. |
void |
initComponents()
By default, Swing components should be created an installed in this method, rather than in the ctor itself. |
void |
makePrivateWindow()
Remove this window from e.g. the Windows Menu by removing it from the list of active JmriJFrames |
void |
markWindowModified(boolean yes)
|
boolean |
multipleInstances()
Should 2nd and subsequent requests for a panel (e.g. in an Action) create a new instance, or provide the 1st one for reuse? |
(package private) void |
offSetFrameOnScreen(JmriJFrame f)
|
void |
pack()
|
(package private) void |
reSizeToFitOnScreen()
Tries to get window to fix entirely on screen. |
void |
setAllowInFrameServlet(boolean allow)
|
void |
setEscapeKeyAction(AbstractAction action)
Bind an action to the Escape key. |
void |
setEscapeKeyClosesWindow(boolean closesWindow)
Bind the Escape key to an action that closes the window. |
(package private) void |
setFrameLocation()
|
void |
setIndexedProperty(String key,
int index,
Object value)
Set the value of an element in an indexed property. |
void |
setModifiedFlag(boolean flag)
A frame is considered "modified" if it has changes that have not been stored. |
void |
setProperty(String key,
Object value)
Set the value of a property. |
void |
setSavePosition(boolean save)
Set whether the frame Position is saved or not after it has been created. |
void |
setSaveSize(boolean save)
Set whether the frame Size is saved or not after it has been created |
protected void |
setShutDownTask()
|
void |
setWindowInterface(WindowInterface wi)
|
void |
show(JmriPanel child,
JmriAbstractAction action)
Show, in whatever way is appropriate, a specific JmriPanel |
void |
show(JmriPanel child,
JmriAbstractAction action,
WindowInterface.Hint hint)
Show, in whatever way is appropriate, a specific JmriPanel |
protected void |
storeValues()
|
void |
windowActivated(WindowEvent e)
|
void |
windowClosed(WindowEvent e)
|
void |
windowClosing(WindowEvent e)
|
void |
windowDeactivated(WindowEvent e)
|
void |
windowDeiconified(WindowEvent e)
|
void |
windowIconified(WindowEvent e)
|
void |
windowOpened(WindowEvent e)
|
| Methods inherited from class java.awt.Frame |
|---|
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.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.awt.MenuContainer |
|---|
getFont, postEvent |
| Field Detail |
|---|
protected boolean allowInFrameServlet
String windowFrameRef
static volatile ArrayList<JmriJFrame> list
static final String WINDOW_MODIFIED
protected boolean reuseFrameSavedPosition
protected boolean reuseFrameSavedSized
protected HashMap<String,Object> properties
protected transient WindowInterface windowInterface
| Constructor Detail |
|---|
public JmriJFrame(boolean saveSize,
boolean savePosition)
saveSize - - Set true to save the last known sizesavePosition - - Set true to save the last known locationpublic JmriJFrame()
public JmriJFrame(String name)
name - - Title of the JFrame
public JmriJFrame(String name,
boolean saveSize,
boolean savePosition)
name - - Title of the JFramesaveSize - - Set true to save the last knowm sizesavePosition - - Set true to save the last known location| Method Detail |
|---|
public void makePrivateWindow()
void setFrameLocation()
public void generateWindowRef()
public void pack()
pack in class Windowvoid reSizeToFitOnScreen()
void offSetFrameOnScreen(JmriJFrame f)
public String getWindowFrameRef()
public void initComponents()
throws Exception
Exception
public void addHelpMenu(String ref,
boolean direct)
ref - JHelp reference for the desired window-specific help pagedirect - true if the help menu goes directly to the help system,
e.g. there are no items in the help menuvoid addWindowCloseShortCut()
public void setEscapeKeyAction(AbstractAction action)
Binds an AbstractAction to the Escape key. If an action is already
bound to the Escape key, that action will be replaced. Passing
null unbinds any existing actions from the Escape key.
Note that binding the Escape key to any action may break expected or standardized behaviors. See Keyboard Shortcuts, Mnemonics, and Other Keyboard Operations in the Java Look and Feel Design Guidelines for standardized behaviors.
action - The AbstractAction to bind to.getEscapeKeyAction(),
setEscapeKeyClosesWindow(boolean)public AbstractAction getEscapeKeyAction()
setEscapeKeyAction(javax.swing.AbstractAction),
AbstractActionpublic void setEscapeKeyClosesWindow(boolean closesWindow)
If closesWindow is true, this method creates an action that triggers the "window is closing" event; otherwise this method removes any actions from the Escape key.
closesWindow - Create or destroy an action to close the window.WindowEvent.WINDOW_CLOSING,
setEscapeKeyAction(javax.swing.AbstractAction)public boolean getEscapeKeyClosesWindow()
true if Escape key is bound to action created by
setEscapeKeyClosesWindow, false in all other cases.setEscapeKeyClosesWindow(boolean),
setEscapeKeyAction(javax.swing.AbstractAction)public Dimension getMaximumSize()
Some of the methods used here return null pointers on some Java implementations, however, so this will return the superclasses's maximum size if the algorithm used here fails.
getMaximumSize in class Containerpublic Dimension getPreferredSize()
getPreferredSize in class Containerpublic static List<JmriJFrame> getFrameList()
public static List<JmriJFrame> getFrameList(Class<?> subClass)
The returned list is a copy made at the time of the call, so it can be manipulated as needed by the caller.
If subClass is null, returns a list of all JmriJFrames.
subClass - The Class the list should be limited to.
public static JmriJFrame getFrame(String name)
public void addNotify()
addNotify in class Framepublic void setSavePosition(boolean save)
public void setSaveSize(boolean save)
public boolean getSavePosition()
public boolean getSaveSize()
public void setModifiedFlag(boolean flag)
setModifiedFlag in interface ModifiedFlagflag - true if the object has been modifiedpublic boolean getModifiedFlag()
Not a bound parameter
getModifiedFlag in interface ModifiedFlagprotected void handleModified()
protected void storeValues()
public void markWindowModified(boolean yes)
public void windowOpened(WindowEvent e)
windowOpened in interface WindowListenerpublic void windowClosed(WindowEvent e)
windowClosed in interface WindowListenerpublic void windowActivated(WindowEvent e)
windowActivated in interface WindowListenerpublic void windowDeactivated(WindowEvent e)
windowDeactivated in interface WindowListenerpublic void windowIconified(WindowEvent e)
windowIconified in interface WindowListenerpublic void windowDeiconified(WindowEvent e)
windowDeiconified in interface WindowListenerpublic void windowClosing(WindowEvent e)
windowClosing in interface WindowListenerpublic void componentHidden(ComponentEvent e)
componentHidden in interface ComponentListenerpublic void componentMoved(ComponentEvent e)
componentMoved in interface ComponentListenerpublic void componentResized(ComponentEvent e)
componentResized in interface ComponentListenerpublic void componentShown(ComponentEvent e)
componentShown in interface ComponentListenerprotected void setShutDownTask()
public void dispose()
Subclasses that over-ride this method must invoke this implementation with super.dispose()
dispose in interface WindowInterfacedispose in class Window
public void setIndexedProperty(String key,
int index,
Object value)
BeanInterface
NOTE Implementing methods must not call Bean.setIndexedProperty(),
as doing so will cause a stack overflow. Implementing methods may call
Beans.setIntrospectedIndexedProperty() instead.
setIndexedProperty in interface BeanInterfacekey - name of the propertyindex - index of the property element to changevalue - the value to set the property to
public Object getIndexedProperty(String key,
int index)
BeanInterface
NOTE Implementing methods must not call Bean.getIndexedProperty(),
as doing so will cause a stack overflow. Implementing methods may call
Beans.getIntrospectedIndexedProperty() instead.
getIndexedProperty in interface BeanInterfacekey - name of the propertyindex - index of the property element to change
public void setProperty(String key,
Object value)
BeanInterface
NOTE Implementing methods must not call Bean.setProperty(),
as doing so will cause a stack overflow. Implementing methods may call
Beans.setIntrospectedProperty() instead.
setProperty in interface BeanInterfacekey - name of the propertyvalue - the value to set the property topublic Object getProperty(String key)
BeanInterface
NOTE Implementing methods must not call Bean.getProperty(),
as doing so will cause a stack overflow. Implementing methods may call
Beans.getIntrospectedProperty() instead.
getProperty in interface BeanInterfacekey - name of the property
public boolean hasProperty(String key)
BeanInterface
NOTE Implementing method must not call Bean.hasProperty(),
as doing so will cause a stack overflow. Implementing methods may call
Beans.hasIntrospectedProperty() instead.
hasProperty in interface BeanInterfacekey - name of the property
public void show(JmriPanel child,
JmriAbstractAction action)
WindowInterface
show in interface WindowInterfacechild - new JmriPanel to showaction - JmriAbstractAction making the request
public void show(JmriPanel child,
JmriAbstractAction action,
WindowInterface.Hint hint)
WindowInterface
show in interface WindowInterfacechild - new JmriPanel to showaction - JmriAbstractAction making the requesthint - suggestion on where to put the contentpublic boolean multipleInstances()
WindowInterface
multipleInstances in interface WindowInterfacepublic void setWindowInterface(WindowInterface wi)
public WindowInterface getWindowInterface()
public Set<String> getPropertyNames()
BeanInterface
NOTE Implementing method must not call Bean.getPropertyNames(),
as doing so will cause a stack overflow. Implementing methods may call
Beans.getIntrospectedPropertyNames() instead.
NOTE Implementations of this method should not return null.
getPropertyNames in interface BeanInterfacepublic void setAllowInFrameServlet(boolean allow)
public boolean getAllowInFrameServlet()
public Frame getFrame()
WindowInterface
getFrame in interface WindowInterface
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||