|
||||||||||
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
com.jgoodies.uif.AbstractFrame
public abstract class AbstractFrame
Provides convenience code that is frequently used in application frames:
AbstractFrame registers an ApplicationListener with the UIF's ApplicationContext. Currently the ApplicationContext class keeps an indirect (but hard) reference to AbstractFrames. And so AbstractFrame instances won't be garbage collected before the ApplicationContext closes. A future version of the UIF will register ApplicationContext listeners using a listener list based on WeakReferences.
TODO: Register the listener based on WeakReferences.
TODO: Remove the above note once the ApplicationContext uses WeakReferences.
ApplicationContext
,
WindowUtils
,
Serialized FormNested 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 |
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 | |
---|---|
protected |
AbstractFrame(String title)
Constructs an AbstractFrame using the given window title. |
Method Summary | |
---|---|
void |
build()
Builds the frame's content pane, packs it, locates it on the screen, sets the icon, restores the saved state, and registers listeners. |
protected abstract JComponent |
buildContentPane()
Subclasses must override this method to build and return the content pane. |
protected abstract void |
configureCloseOperation()
Configures the behavior that will happen when the user initiates a "close" on this frame. |
protected void |
configureWindowIcon()
Sets this frame's icon that is fetched via the ResourceUtils . |
String |
getTitleSuffix()
Returns the title's suffix, the part of the title that is appended to the prefix - if any. |
protected void |
initEventHandling()
Initializes the event handling. |
protected void |
locateOnScreen()
Locates this frame on the screen, by default centered on the screen. |
void |
open()
Makes this frame visible. |
protected void |
resizeHook(JComponent component)
Resizes the specified component. |
protected void |
restoreState()
Restores this frame's state from the user preferences as provided by the ApplicationContext . |
void |
setTitlePrefix(String prefix)
Sets this frame's title by means of a prefix. |
void |
setTitleSuffix(String newTitleSuffix)
Sets this frame's title suffix, which is used to compose this frame's title together with the title prefix. |
protected void |
storeState()
Stores this frame's state in the user preferences as provided by the ApplicationContext . |
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.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.awt.MenuContainer |
---|
getFont, postEvent |
Constructor Detail |
---|
protected AbstractFrame(String title)
title
- the window title to be usedMethod Detail |
---|
public void build()
Subclasses should rarely override this method.
protected abstract JComponent buildContentPane()
protected abstract void configureCloseOperation()
To properly shut down the application, you must invoke
ApplicationContext#close
. If you just want to shut down
you can use a default handler from class ApplicationContext
as follows:
protected void configureCloseOperation() { setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener( ApplicationContext.getApplicationCloseOnWindowClosingHandler()); }
JFrame.setDefaultCloseOperation(int)
,
Application.getApplicationExitOnWindowClosingHandler()
public void setTitlePrefix(String prefix)
Example: The suffix is "JDiskReport", if the prefix is empty, the title is just
JDiskReport. If the prefix is "Scanning", the title is
Scanning - JDiskReport.
prefix
- the window title's prefixsetTitleSuffix(String)
public String getTitleSuffix()
public void setTitleSuffix(String newTitleSuffix)
Example: The suffix is "JDiskReport", if the prefix is empty, the title is just
JDiskReport. If the prefix is "Scanning", the title is
Scanning - JDiskReport.
newTitleSuffix
- the suffix for this frame's titlesetTitlePrefix(String)
public void open()
protected void resizeHook(JComponent component)
Resizer
.
component
- the component to be resizedprotected void locateOnScreen()
protected void initEventHandling()
Subclasses that override this method will typically invoke this default implementation.
protected void configureWindowIcon()
ResourceUtils
.
Uses a 12x12 or 16x16 pixel image.
WindowUtils.setImageIcon(java.awt.Frame, Image, Image)
protected void storeState()
ApplicationContext
.The default implementation does nothing. Since we may add behavior in future versions, subclasses that override this method shall call this super implementation before their added behavior.
protected void restoreState()
ApplicationContext
.
The default implementation restores the window bounds and a maximized
or normal state via the WindowUtils
. Also the current bounds
are put into this frame's client properties.
Subclasses that override this method will likely call this default behavior before adding custom actions.
WindowUtils.restoreBounds(JFrame, Preferences)
,
WindowUtils.restoreState(Frame, Preferences, boolean)
,
Frame.getExtendedState()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |