org.tentackle.ui
Class FormComponentPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.tentackle.ui.FormPanel
                      extended by org.tentackle.ui.FormComponentPanel
All Implemented Interfaces:
ContainerListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, FormComponent, FormContainer
Direct Known Subclasses:
FormFieldComponentPanel, FormSpinField, YesNoRadioButton

public class FormComponentPanel
extends FormPanel
implements FormComponent

A FormPanel with an embedded FormComponent.

Author:
harald
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
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.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
FormComponentPanel()
          Creates a FormComponentPanel for a StringFormField.
FormComponentPanel(FormComponent comp)
          Creates a FormComponentPanel for a given FormComponent.
 
Method Summary
 void addValueListener(ValueListener l)
          Adds a value listener that implements the binding between this component and the data.
 void fireValueChanged()
          Fires all value listeners registered on this component invoking their valueChanged-handler.
This method is invoked whenever the data has been changed and that change should be reflected in the view.
 void fireValueEntered()
          Fires all listeners registered on this component invoking their valueEntered-handler.
This method is invoked whenever the user edited the view and that change should be reflected in the data.
 FormComponent getFormComponent()
          Gets the embedded form component.
 Object getFormValue()
          Retrieves the value from this component.
The method is used to update the data if the view has changed because the user edited it.
 String getHelpURL()
          Gets the online-help URL.
 Window getParentWindow()
          Gets the parent window.
 boolean hasFocus()
          Returns true if this Component is the focus owner.
 void invalidateParentInfo()
          Invalidates all container-relevant (cached) information for the hierarchy of this container's parents.
For optimization purposes.
 boolean isCellEditorUsage()
          Returns whether this component is used as a cell editor.
 boolean isChangeable()
          Returns if this component is changeable.
 boolean isFireRunning()
          Checks whether a fire-method is running.
 boolean isFormTraversable()
          Returns whether this component is form traversable or not.
 boolean isHonourChangeable()
          Returns whether this component should honour the changeable-attribute or not.
 boolean isValueChanged()
          Checks whether the contents have been changed since the last savepoint.
 void prepareFocusLost()
          Prepares for FOCUS_LOST.
Gives this component the opportunity to invoke fireValueEntered() earlier than FOCUS_LOST is really received.
 void removeValueListener(ValueListener l)
          Remove a value listener.
 void requestFocusLater()
          Requests the keyboard focus for this component by appending an event to the end of the event queue.
Applications should not use requestFocus() or requestFocusInWindow() unless the order in which the events are processed is unimportant.
 void saveValue()
          Sets a savepoint for the data of this component.
Allows to decide whether the user has changed the data associated with this component or not.
 void setCellEditorUsage(boolean flag)
          Sets a hint that this component is used as a cell editor.
Some components behave differently in tables than in forms, for example.
 void setChangeable(boolean flag)
          Set the component to be changeable.
This is a unified abstraction and will be translated to setEditable or setEnabled, whatever is appropriate to this component.
 void setFireRunning(boolean running)
          Sets a component's flag that a fire-method is currently running.
Used by the framework to minimize valueChanged/valueEntered processing.
 void setFormComponent(FormComponent comp)
          Sets the embedded form field component.
 void setFormTraversable(boolean formTraversable)
          Sets whether this component is form traversable or not, i.e.
 void setFormValue(Object obj)
          Sets a value in this component.
The method is used to update the view if the data has changed.
 void setFormWrapWindow(FormWindow parent)
          Sets the window that will fire a FormWrapEvent when this components loses the keyboard focus.
 void setHelpURL(String helpURL)
          Sets the online-help URL.
If a help url is set for this container, a browser will be launched to show that url if there is no help url for the component the help was requested for.
 void setHonourChangeable(boolean flag)
          Sets whether this component should honour the changeable-attribute or not.
The default is true.
 void showHelp()
          Displays online help for this container.
 void triggerValueChanged()
          Promotes the fact that value changed to all FormContainers this component is a child of.
 boolean wasFocusGainedFromTransfer()
          Returns whether the keyboard focus was gained due to FormComponent.transferFocus() in the opposite component.
 boolean wasFocusGainedFromTransferBackward()
          Returns whether the keyboard focus was gained due to FormComponent.transferFocusBackward() in the opposite component.
 boolean wasTransferFocus()
          Returns whether this component lost the keyboard focus due to FormComponent.transferFocus().
 boolean wasTransferFocusBackward()
          Returns whether this component lost the keyboard focus due to FormComponent.transferFocusBackward().
 boolean wasTransferFocusByEnter()
          Returns whether this component lost the keyboard focus due to KeyEvent.VK_ENTER.
 
Methods inherited from class org.tentackle.ui.FormPanel
addActionListener, areValuesChanged, componentAdded, componentRemoved, fireActionPerformed, getFormValues, getTitle, isAllChangeable, isHonourAllChangeable, removeActionListener, saveValues, setAllChangeable, setFormValues, setFormValuesKeepChanged, setHonourAllChangeable, setTitle, triggerValuesChanged
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.tentackle.ui.FormComponent
transferFocus, transferFocusBackward
 

Constructor Detail

FormComponentPanel

public FormComponentPanel(FormComponent comp)
Creates a FormComponentPanel for a given FormComponent.

Parameters:
comp - the component

FormComponentPanel

public FormComponentPanel()
Creates a FormComponentPanel for a StringFormField.

Method Detail

getFormComponent

public FormComponent getFormComponent()
Gets the embedded form component.

Returns:
the component

setFormComponent

public void setFormComponent(FormComponent comp)
Sets the embedded form field component.

Parameters:
comp - the component.

setFireRunning

public void setFireRunning(boolean running)
Description copied from interface: FormComponent
Sets a component's flag that a fire-method is currently running.
Used by the framework to minimize valueChanged/valueEntered processing.

Specified by:
setFireRunning in interface FormComponent
Parameters:
running - true if some fire-method is running

isFireRunning

public boolean isFireRunning()
Description copied from interface: FormComponent
Checks whether a fire-method is running.

Specified by:
isFireRunning in interface FormComponent
Returns:
true if some fire-method is running

addValueListener

public void addValueListener(ValueListener l)
Description copied from interface: FormComponent
Adds a value listener that implements the binding between this component and the data.

Specified by:
addValueListener in interface FormComponent
Parameters:
l - the value listener to add

removeValueListener

public void removeValueListener(ValueListener l)
Description copied from interface: FormComponent
Remove a value listener.

Specified by:
removeValueListener in interface FormComponent
Parameters:
l - the value listener to remove

fireValueChanged

public void fireValueChanged()
Description copied from interface: FormComponent
Fires all value listeners registered on this component invoking their valueChanged-handler.
This method is invoked whenever the data has been changed and that change should be reflected in the view.

Specified by:
fireValueChanged in interface FormComponent

fireValueEntered

public void fireValueEntered()
Description copied from interface: FormComponent
Fires all listeners registered on this component invoking their valueEntered-handler.
This method is invoked whenever the user edited the view and that change should be reflected in the data.

Specified by:
fireValueEntered in interface FormComponent

setFormValue

public void setFormValue(Object obj)
Description copied from interface: FormComponent
Sets a value in this component.
The method is used to update the view if the data has changed.

Specified by:
setFormValue in interface FormComponent
Parameters:
obj - is the object to set

getFormValue

public Object getFormValue()
Description copied from interface: FormComponent
Retrieves the value from this component.
The method is used to update the data if the view has changed because the user edited it.

Specified by:
getFormValue in interface FormComponent
Returns:
the object from the form

setChangeable

public void setChangeable(boolean flag)
Description copied from interface: FormComponent
Set the component to be changeable.
This is a unified abstraction and will be translated to setEditable or setEnabled, whatever is appropriate to this component.

Specified by:
setChangeable in interface FormComponent
Parameters:
flag - true the user can edit the data, false if show only

isChangeable

public boolean isChangeable()
Description copied from interface: FormComponent
Returns if this component is changeable.

Specified by:
isChangeable in interface FormComponent
Returns:
true the user can edit the data, false if show only

setHonourChangeable

public void setHonourChangeable(boolean flag)
Description copied from interface: FormComponent
Sets whether this component should honour the changeable-attribute or not.
The default is true. Notice: if this component does not honour the changeable flag, isValueChanged() always returns false and it will not perform any saveValue().

Specified by:
setHonourChangeable in interface FormComponent
Parameters:
flag - true if honour the changeable attribute, false if not

isHonourChangeable

public boolean isHonourChangeable()
Description copied from interface: FormComponent
Returns whether this component should honour the changeable-attribute or not.

Specified by:
isHonourChangeable in interface FormComponent
Returns:
true if honour the changeable attribute, false if not

requestFocusLater

public void requestFocusLater()
Description copied from interface: FormComponent
Requests the keyboard focus for this component by appending an event to the end of the event queue.
Applications should not use requestFocus() or requestFocusInWindow() unless the order in which the events are processed is unimportant. This method guarantees that this component gets the focus when all events queued so far have been processed.

Specified by:
requestFocusLater in interface FormComponent

setFormWrapWindow

public void setFormWrapWindow(FormWindow parent)
Description copied from interface: FormComponent
Sets the window that will fire a FormWrapEvent when this components loses the keyboard focus. When fired the reference to the window is cleared.

Specified by:
setFormWrapWindow in interface FormComponent
Parameters:
parent - the window (usually the parent window of this component).

isValueChanged

public boolean isValueChanged()
Description copied from interface: FormComponent
Checks whether the contents have been changed since the last savepoint.

Specified by:
isValueChanged in interface FormComponent
Returns:
true if changed
See Also:
FormComponent.saveValue()

saveValue

public void saveValue()
Description copied from interface: FormComponent
Sets a savepoint for the data of this component.
Allows to decide whether the user has changed the data associated with this component or not.

Specified by:
saveValue in interface FormComponent
See Also:
FormComponent.isValueChanged()

triggerValueChanged

public void triggerValueChanged()
Description copied from interface: FormComponent
Promotes the fact that value changed to all FormContainers this component is a child of.

Specified by:
triggerValueChanged in interface FormComponent

getHelpURL

public String getHelpURL()
Description copied from interface: FormContainer
Gets the online-help URL.

Specified by:
getHelpURL in interface FormComponent
Specified by:
getHelpURL in interface FormContainer
Overrides:
getHelpURL in class FormPanel
Returns:
the help url, default is null

setHelpURL

public void setHelpURL(String helpURL)
Description copied from interface: FormContainer
Sets the online-help URL.
If a help url is set for this container, a browser will be launched to show that url if there is no help url for the component the help was requested for.

Specified by:
setHelpURL in interface FormComponent
Specified by:
setHelpURL in interface FormContainer
Overrides:
setHelpURL in class FormPanel
Parameters:
helpURL - the help url
See Also:
FormHelper.openHelpURL(Component)

showHelp

public void showHelp()
Description copied from interface: FormContainer
Displays online help for this container.

Specified by:
showHelp in interface FormComponent
Specified by:
showHelp in interface FormContainer
Overrides:
showHelp in class FormPanel

hasFocus

public boolean hasFocus()
Description copied from class: java.awt.Component
Returns true if this Component is the focus owner. This method is obsolete, and has been replaced by isFocusOwner().

Specified by:
hasFocus in interface FormComponent
Overrides:
hasFocus in class Component
Returns:
true if this Component is the focus owner; false otherwise

wasTransferFocus

public boolean wasTransferFocus()
Description copied from interface: FormComponent
Returns whether this component lost the keyboard focus due to FormComponent.transferFocus().

Specified by:
wasTransferFocus in interface FormComponent
Returns:
true if focus lost due to transferFocus

wasTransferFocusBackward

public boolean wasTransferFocusBackward()
Description copied from interface: FormComponent
Returns whether this component lost the keyboard focus due to FormComponent.transferFocusBackward().

Specified by:
wasTransferFocusBackward in interface FormComponent
Returns:
true if focus lost due to transferFocusBackward

wasFocusGainedFromTransfer

public boolean wasFocusGainedFromTransfer()
Description copied from interface: FormComponent
Returns whether the keyboard focus was gained due to FormComponent.transferFocus() in the opposite component.

Specified by:
wasFocusGainedFromTransfer in interface FormComponent
Returns:
true if this component gained the focus from the logically previous component
See Also:
FormFocusTraversalPolicy

wasFocusGainedFromTransferBackward

public boolean wasFocusGainedFromTransferBackward()
Description copied from interface: FormComponent
Returns whether the keyboard focus was gained due to FormComponent.transferFocusBackward() in the opposite component.

Specified by:
wasFocusGainedFromTransferBackward in interface FormComponent
Returns:
true if this component gained the focus from the logically next component
See Also:
FormFocusTraversalPolicy

wasTransferFocusByEnter

public boolean wasTransferFocusByEnter()
Description copied from interface: FormComponent
Returns whether this component lost the keyboard focus due to KeyEvent.VK_ENTER.

Specified by:
wasTransferFocusByEnter in interface FormComponent
Returns:
true if pressing the Enter/Return key caused a focus lost

getParentWindow

public Window getParentWindow()
Description copied from interface: FormContainer
Gets the parent window.

Specified by:
getParentWindow in interface FormComponent
Specified by:
getParentWindow in interface FormContainer
Overrides:
getParentWindow in class FormPanel
Returns:
the parent window, null if none

invalidateParentInfo

public void invalidateParentInfo()
Description copied from interface: FormContainer
Invalidates all container-relevant (cached) information for the hierarchy of this container's parents.
For optimization purposes.

Specified by:
invalidateParentInfo in interface FormComponent
Specified by:
invalidateParentInfo in interface FormContainer
Overrides:
invalidateParentInfo in class FormPanel

setCellEditorUsage

public void setCellEditorUsage(boolean flag)
Description copied from interface: FormComponent
Sets a hint that this component is used as a cell editor.
Some components behave differently in tables than in forms, for example.

Specified by:
setCellEditorUsage in interface FormComponent
Parameters:
flag - true if component is a cell editor, false if not.

isCellEditorUsage

public boolean isCellEditorUsage()
Description copied from interface: FormComponent
Returns whether this component is used as a cell editor.

Specified by:
isCellEditorUsage in interface FormComponent
Returns:
true true if component is a cell editor, false if not.

prepareFocusLost

public void prepareFocusLost()
Description copied from interface: FormComponent
Prepares for FOCUS_LOST.
Gives this component the opportunity to invoke fireValueEntered() earlier than FOCUS_LOST is really received. Useful because the next focused component is determined before FOCUS_LOST is sent to this component. Thus, if this component changes the focusability of the next component, the focus policy would probably pick the wrong component otherwise.

Specified by:
prepareFocusLost in interface FormComponent

setFormTraversable

public void setFormTraversable(boolean formTraversable)
Description copied from interface: FormComponent
Sets whether this component is form traversable or not, i.e. gets the focus or is skipped.

Specified by:
setFormTraversable in interface FormComponent
Parameters:
formTraversable - true if traversable, false if not

isFormTraversable

public boolean isFormTraversable()
Description copied from interface: FormComponent
Returns whether this component is form traversable or not.

Specified by:
isFormTraversable in interface FormComponent
Returns:
the focus traversable flag


Copyright © 2001-2008 Harald Krake, Bergstr. 48, 78098 Triberg, Germany, harald@krake.de