com.antelmann.util.gui
Class FormFrame
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
com.antelmann.util.gui.JMainFrame
com.antelmann.util.gui.FormFrame
- All Implemented Interfaces:
- Form, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants
public class FormFrame
- extends JMainFrame
- implements Form
a Frame that takes some form along with a FormValidator to edit some data.
The Frame contains the form and a toolbar with a save and a close button.
Upon saving, disposing or in the event of exceptions, events are generated that
can be monitored via the Listener interface.
Since all components sit on the embedded mainPanel using a BorderLayout, it
is relatively easy to add additional components to the sides of the frame.
- Since:
- 24. November 2007, 19:48
- Author:
- Holger Antelmann
- See Also:
FormDialog,
Serialized Form
| 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 |
| Methods inherited from class javax.swing.JFrame |
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 |
| 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, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, 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, 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 |
mainPanel
protected final JPanel mainPanel
saveButton
protected JButton saveButton
closeButton
protected JButton closeButton
FormFrame
public FormFrame(String title,
JComponent form,
FormValidator<?> validator)
- calls the next constructor with saveAlwaysEnabled=true
FormFrame
public FormFrame(String title,
JComponent form,
FormValidator<?> validator,
boolean saveAlwaysEnabled)
getMainPanel
public JPanel getMainPanel()
- returns the panel in the center that has the toolbar and the form on it
getButtonContainer
public JToolBar getButtonContainer()
- returns the toolbar that already contains save and close buttons
- Specified by:
getButtonContainer in interface Form
getFormComponent
public JComponent getFormComponent()
- Specified by:
getFormComponent in interface Form
getFormValidator
public FormValidator<?> getFormValidator()
- Specified by:
getFormValidator in interface Form
addListener
public void addListener(FormListener l)
- Specified by:
addListener in interface Form
removeListener
public boolean removeListener(FormListener l)
- Specified by:
removeListener in interface Form
getFormListeners
public FormListener[] getFormListeners()
- Specified by:
getFormListeners in interface Form
isDirty
public boolean isDirty()
- Description copied from interface:
Form
- determines whether the form is currently considered to be in a 'changed'-mode.
The form is in a changed mode after it received a PropertyChangeEvent until it is saved again.
- Specified by:
isDirty in interface Form
performSaveAction
public Object performSaveAction()
- Description copied from interface:
Form
- programmatically performs the action that would commonly be performed upon
pressing 'save' on the form.
Commonly, this method would first call
FormValidator.validateForm(Component)
and then call FormValidator.commitFormAction(Component); also this method
resets the Form.isDirty() status if the commit was successful.
- Specified by:
performSaveAction in interface Form
- Returns:
- the object saved or null if that didn't happen
getWarnOnClose
public boolean getWarnOnClose()
- Description copied from interface:
Form
- determines whether a warning is displayed upon cancel if the form is marked as changed (false by default)
- Specified by:
getWarnOnClose in interface Form
setWarnOnClose
public void setWarnOnClose(boolean flag)
- Description copied from interface:
Form
- if set to true, a warning is displayed when the form is closed w/o saving if it is marked changed
- Specified by:
setWarnOnClose in interface Form
closeAction
public boolean closeAction()
disposeForm
public boolean disposeForm(boolean forceWithoutConfirm)
- Description copied from interface:
Form
- allows to programmatically close the form.
- Specified by:
disposeForm in interface Form
- Parameters:
forceWithoutConfirm - if true, the form will be disposed no matter what;
if false, a confirmation dialog may appear if the form
is dirty and warnOnClose is true
- Returns:
- true only if the form has been closed (and the listeners were informed accordingly)
propertyChange
public void propertyChange(PropertyChangeEvent evt)
- marks the form dirty and enables the save button (in case it's not already generally enabled)
- Specified by:
propertyChange in interface PropertyChangeListener
getFormContainer
public Container getFormContainer()
- Description copied from interface:
Form
- provides access to the overall window, dialog, frame, internal frame or other that holds
the form with the formComponent and all the functional buttons that belong to the form
- Specified by:
getFormContainer in interface Form
(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads