MDateSelector

mseries.ui
Class MDateEntryField

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by mseries.ui.MDateEntryField
All Implemented Interfaces:
FocusListener, ImageObserver, MenuContainer, Serializable, EventListener

public class MDateEntryField
extends JComponent
implements FocusListener

Date entry component which looks like a combobox, when the button is pushed a calendar drops down for selection of the date. Uses a JFormattedTextField as the display component

See Also:
Serialized Form

Nested Class Summary
 
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
protected  MDateField display
           
protected  EventListenerList listenerList
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
MDateEntryField()
          Creates a MDateEntryField with default SHORT DateFormatter
MDateEntryField(DateFormat df)
          Creates a MDateEntryField with the formatter passed
MDateEntryField(int size)
          Deprecated. simply delegates to MDateEntryField()
 
Method Summary
 void addMChangeListener(MChangeListener listener)
          Registers the listeners of the field changes.
 void addMFieldListener(MFieldListener listener)
          Registers the listeners of the field changes.
 void closed()
          This method is public as an implementation side effect, do not override or call it directly
 void drawBorder(boolean border)
          causes a border to be drawn around the component
 void focusGained(FocusEvent e)
          This method is public as an implementation side effect, do not override or call it directly
 void focusLost(FocusEvent e)
          This method is public as an implementation side effect, do not override or call it directly
 boolean getCloseOnToday()
           
 MDateSelectorConstraints getConstraints()
          Gets the constraints object that contains the parameters used to configure the pull down calendar
 MDateFormat getDateFormatter()
          Deprecated.  
 JFormattedTextField.AbstractFormatter getDateFormatter(Object x)
           
 MDateField getDisplay()
          Returns the textfield that handles the date editing.
 int getFocusLostBehavior()
          Delegates to the same method in the JFormattedTextField
 Font getFont()
          Returns the font that the editor part (the textfield) uses
 InputVerifier getInputVerifier()
           
 Date getMaximum()
           
 Date getMinimum()
           
 String getName()
          Gets the name attribute which is delegated to the textfield used as the display component
 boolean getNullOnEmpty()
           
 boolean getShowTodayButton()
          Does this field have a today button when the pull down is shown ?
 String getText()
           
 String getToolTipText()
           
 String getUIClassID()
          This method gives the UI Manager a constant to use to look up in the UI Defaults table to find the class name of the UI Delegate for the installed L&F.
 Date getValue()
           
 boolean hasBorder()
           
 boolean isEditable()
           
 boolean isEnabled()
           
 void notifyListeners(FocusEvent e)
           
 void notifyListeners(int type)
          Causes the MChangeEvents to be fired.
 void opened()
          This method is public as an implementation side effect, do not override or call it directly
protected  ComponentUI registerUIDelegate()
          Used to automatically install the UIDelagate for Windows & Metal Look & Feels.
 void removeMChangeListener(MChangeListener listener)
          Removes the listener from the registered list of listeners
 void removeMFieldListener(MFieldListener listener)
          Removes the listener from the registered list of listeners
 void requestFocus()
          Set focus on the receiving component if isRequestFocusEnabled returns true
 void setConstraints(MDateSelectorConstraints c)
          Sets the constraints object that contains the parameters used to configure the pull down calendar.
 void setDateFormatter(MDateFormat df)
          Deprecated. use setFormatter(DateFormat)
 void setEditable(boolean editable)
          Sets the date entry field editable or not, the button can still be used to allow date selection.
 void setFocusLostBehavior(int b)
          Delegates to the same method in the JFormattedTextField
 void setFont(Font font)
           
 void setInputVerifier(InputVerifier inputVerifier)
           
 void setMaximum(Date date)
          Sets the latest value that may be selected for this field when the poup calendar in invoked.
 void setMinimum(Date date)
          Sets the earliest value that may be selected for this field when the poup calendar in invoked.
 void setName(String name)
          Sets the name attribute which is delegated to the textfield used as the display component
 void setNullOnEmpty(boolean nullOnEmpty)
          If set to true the getValue method will return null when the text field is empty, otherwise a ParseException is thrown since "" is not a valid date.
 void setShowTodayButton(boolean show)
          The pull down can be configured with a button at the bottom to quickly select the current date.
 void setShowTodayButton(boolean show, boolean close)
          The pull down can be configured with a button at the bottom to quickly select the current date.
 void setText(String text)
          This method does not do anything, the implementation is empty and it only present to make the component a JavaBean
 void setToolTipText(String text)
           
 void setValue(Date newValue)
          Sets the current value in the field, parsed using the current date formatter
 void updateUI()
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, 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, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, 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, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, 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, 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
 

Field Detail

display

protected MDateField display

listenerList

protected EventListenerList listenerList
Constructor Detail

MDateEntryField

public MDateEntryField()
Creates a MDateEntryField with default SHORT DateFormatter


MDateEntryField

public MDateEntryField(DateFormat df)
Creates a MDateEntryField with the formatter passed

Parameters:
df - the date formatter to use in the display and for parsing the value in the JFormattedTextField

MDateEntryField

public MDateEntryField(int size)
Deprecated. simply delegates to MDateEntryField()

Creates a MDateEntryField

Parameters:
size - the size of the display part of the component
Method Detail

getDisplay

public MDateField getDisplay()
Returns the textfield that handles the date editing. Used by the UIDelegates


updateUI

public void updateUI()
Overrides:
updateUI in class JComponent

getFocusLostBehavior

public int getFocusLostBehavior()
Delegates to the same method in the JFormattedTextField

Returns:
the focus lost behaviour

setFocusLostBehavior

public void setFocusLostBehavior(int b)
Delegates to the same method in the JFormattedTextField

Parameters:
b - focus lost behaviour

registerUIDelegate

protected ComponentUI registerUIDelegate()
Used to automatically install the UIDelagate for Windows & Metal Look & Feels. Any other Look & Feel will get the basic look and feel unless a UIDelegate is provided and set in the look and feel class.

See Also:
getUIClassID()

getUIClassID

public String getUIClassID()
This method gives the UI Manager a constant to use to look up in the UI Defaults table to find the class name of the UI Delegate for the installed L&F.

Overrides:
getUIClassID in class JComponent
Returns:
string "DateEntryUI"

getNullOnEmpty

public boolean getNullOnEmpty()
Returns:
the nullOnEmpty attribute

setNullOnEmpty

public void setNullOnEmpty(boolean nullOnEmpty)
If set to true the getValue method will return null when the text field is empty, otherwise a ParseException is thrown since "" is not a valid date. Default is false.

Parameters:
nullOnEmpty - set to true if a null is required when the textfield is empty

getText

public String getText()
Returns:
the current value of the field The value of the entry field, no parsing is performed, use getValue() to get a Date

setText

public void setText(String text)
This method does not do anything, the implementation is empty and it only present to make the component a JavaBean


getName

public String getName()
Gets the name attribute which is delegated to the textfield used as the display component

Overrides:
getName in class Component
Returns:
the name

setName

public void setName(String name)
Sets the name attribute which is delegated to the textfield used as the display component

Overrides:
setName in class Component
Parameters:
name - the name attribute

getValue

public Date getValue()
              throws ParseException
Returns:
the current value of the field
Throws:
ParseException - if it is not a valid date

setValue

public void setValue(Date newValue)
Sets the current value in the field, parsed using the current date formatter

Parameters:
newValue - the new value

setDateFormatter

public void setDateFormatter(MDateFormat df)
Deprecated. use setFormatter(DateFormat)

Tells the component what date formatter to use for parsing and formatting the user input.

Parameters:
df - the date formatter

getDateFormatter

public MDateFormat getDateFormatter()
Deprecated. 


getDateFormatter

public JFormattedTextField.AbstractFormatter getDateFormatter(Object x)

setMinimum

public void setMinimum(Date date)
Sets the earliest value that may be selected for this field when the poup calendar in invoked. The default is 1 January 1900

Parameters:
date - the ealiest date

setMaximum

public void setMaximum(Date date)
Sets the latest value that may be selected for this field when the poup calendar in invoked. The default is 31 December 2037

Parameters:
date - the latest date

getMinimum

public Date getMinimum()

getMaximum

public Date getMaximum()

hasBorder

public boolean hasBorder()
Returns:
true if a border will be drawn

drawBorder

public void drawBorder(boolean border)
causes a border to be drawn around the component

Parameters:
border - true is a border is to be drawn (default=true)

getFont

public Font getFont()
Returns the font that the editor part (the textfield) uses

Specified by:
getFont in interface MenuContainer
Overrides:
getFont in class Component
Returns:
the font for the date display

setFont

public void setFont(Font font)
Overrides:
setFont in class JComponent

isEnabled

public boolean isEnabled()
Overrides:
isEnabled in class Component
Returns:
the date fields editable property

setEditable

public void setEditable(boolean editable)
Sets the date entry field editable or not, the button can still be used to allow date selection.

Parameters:
editable - true if the field can be typed into

isEditable

public boolean isEditable()
Returns:
the date fields editable property

setInputVerifier

public void setInputVerifier(InputVerifier inputVerifier)
Overrides:
setInputVerifier in class JComponent

getInputVerifier

public InputVerifier getInputVerifier()
Overrides:
getInputVerifier in class JComponent

setConstraints

public void setConstraints(MDateSelectorConstraints c)
Sets the constraints object that contains the parameters used to configure the pull down calendar. Constraints include the visual aspects of the pull down such as the colours, including the colours of the month and date changer, if the look and feel permits it.

Parameters:
c - the constraints object
See Also:
getConstraints()

getConstraints

public MDateSelectorConstraints getConstraints()
Gets the constraints object that contains the parameters used to configure the pull down calendar

See Also:
getConstraints()

setToolTipText

public void setToolTipText(String text)
Overrides:
setToolTipText in class JComponent

getToolTipText

public String getToolTipText()
Overrides:
getToolTipText in class JComponent

opened

public void opened()
This method is public as an implementation side effect, do not override or call it directly


closed

public void closed()
This method is public as an implementation side effect, do not override or call it directly


focusLost

public void focusLost(FocusEvent e)
This method is public as an implementation side effect, do not override or call it directly

Specified by:
focusLost in interface FocusListener

requestFocus

public void requestFocus()
Set focus on the receiving component if isRequestFocusEnabled returns true

Overrides:
requestFocus in class JComponent

focusGained

public void focusGained(FocusEvent e)
This method is public as an implementation side effect, do not override or call it directly

Specified by:
focusGained in interface FocusListener

addMFieldListener

public void addMFieldListener(MFieldListener listener)
Registers the listeners of the field changes. The event is fired when the component gets and loses focus.

Parameters:
listener - - MFieldListener
See Also:
removeMFieldListener(mseries.Calendar.MFieldListener)

removeMFieldListener

public void removeMFieldListener(MFieldListener listener)
Removes the listener from the registered list of listeners

Parameters:
listener - - MFieldListener

notifyListeners

public void notifyListeners(FocusEvent e)

addMChangeListener

public void addMChangeListener(MChangeListener listener)
Registers the listeners of the field changes. Fired when the user changes a value in the dropped down calendar

Parameters:
listener - - MMonthListener

removeMChangeListener

public void removeMChangeListener(MChangeListener listener)
Removes the listener from the registered list of listeners

Parameters:
listener - - MMonthListener

notifyListeners

public void notifyListeners(int type)
Causes the MChangeEvents to be fired. This is called by the L&F Delegate and should not be overloaded or called directly.


setShowTodayButton

public void setShowTodayButton(boolean show)
The pull down can be configured with a button at the bottom to quickly select the current date. The label is translated using the ResourceBundle given in the contraints object passed in the setConstraints() method (or the default which is false), by default the popup closes when the button is pushed, this behaviour can be changed by setting the closeOnToday attribute.

Parameters:
show - set this to true if the button is required.
See Also:
MDateSelectorConstraints

getShowTodayButton

public boolean getShowTodayButton()
Does this field have a today button when the pull down is shown ?

Returns:
true if a 'today' button is displayed.
See Also:
setShowTodayButton(boolean)

setShowTodayButton

public void setShowTodayButton(boolean show,
                               boolean close)
The pull down can be configured with a button at the bottom to quickly select the current date. The label is translated using the ResourceBundle given in the contraints object passed in the setConstraints() method (or the default which is false).

Parameters:
show - set this to true if the button is required.
close - the popup closes when close is true (default)
See Also:
MDateSelectorConstraints

getCloseOnToday

public boolean getCloseOnToday()
Returns:
the close on today attribute

MDateSelector

Copyright © 2001-2007 M Newstead. All Rights Reserved.