MDateSelector

mseries.Calendar
Class MDateSelectorPanel

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 mseries.ui.MImagePanel
                      extended by mseries.Calendar.MDateSelectorPanel
All Implemented Interfaces:
MouseListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, GridSelectionListener, MMonthListener, MChangeListener

public class MDateSelectorPanel
extends MImagePanel
implements MMonthListener, GridSelectionListener, MChangeListener, MouseListener

A calender component that shows one month at a time with controls to change the month and year. The parameters to the calendar, including the style of the control are given in the MDateSelectorConstraints object that is passed. There is a default call MDefaultPullDownConstraints that can be used or subclassed to provide a set of application wide defaults.

See Also:
MDateSelectorConstraints, 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
MDateSelectorPanel()
           
MDateSelectorPanel(boolean lazy, Date min, Date max)
           
 
Method Summary
 void addMMonthListener(MMonthListener l)
          Registers objects that are to listen to events from the DateSelector Event types of NEW_DATE and NEW_MONTH indicate that the value has changed
 void close(String command)
           
 void dataChanged(MMonthEvent e)
          Reacts to all changes in the data model (MMonth) which is given by the event type.
 boolean getCloseOnToday()
           
 Date getDate()
          Returns the currently selected date value
 int getFirstDay()
           
 Date getMaximum()
          Returns the latest possible date that can be displayed
 Date getMinimum()
          Returns the earliest possible date that can be displayed
 boolean getShowTodayButton()
           
 ResourceBundle getTextLocalizer()
           
 void gridCellChanged(GridSelectionEvent e)
          Captures changes in the currently selected cell and sets the current date in the data model from com.java.swing.event.ListSelectionListener
 boolean isFocusCycleRoot()
           
 void mouseClicked(MouseEvent event)
           
 void mouseEntered(MouseEvent event)
           
 void mouseExited(MouseEvent event)
           
 void mousePressed(MouseEvent event)
           
 void mouseReleased(MouseEvent event)
           
 void removeMMonthListener(MMonthListener l)
          De-Registers objects that are to listen to events from the DateSelector
 void requestFocus()
           
 void setBackground(Color background)
          Set the background colour
 void setBackground(Color[] colors)
          Sets the all the background colors for each day element 0 - SUNDAY, 6 - SATURDAY
 void setBackground(int day, Color color)
          Sets the background color for the column representing the day given.
 void setCellSize(Dimension cellSize)
           
protected  void setChangerStyle(int style)
          Sets the style of changer for the month & year, implementations include COMBOBOX/SPINNER and a scrollbar
 void setCloseOnToday(boolean close)
           
protected  void setColours(Component c)
           
 void setComponentFont(Component c)
           
 void setDate(Date date)
          Sets the date in the calendar
 void setDMY(Date date)
          Sets a value in the component and does not change the time elements.
 void setEnabled(boolean enabled)
           
 void setFirstDay(int firstDay)
          The first column on the calendar grid shows the dates for the day passed here.
 void setFocusCycleRoot(boolean fcr)
           
 void setFont(Font font)
           
 void setForeground(Color foreground)
          Set the foreground colour
 void setForeground(Color[] colors)
          Sets the all the foreground colors for each day element 0 - SUNDAY, 6 - SATURDAY
 void setForeground(int day, Color color)
          Sets the foreground color for the column representing the day given.
 void setImageFile(String imageFile)
          Sets the background image, if set the background color is ignored
 void setMaximum(Date max)
          Sets the maximum date value allowed
 void setMinimum(Date min)
          Sets the minimum date value allowed
 void setPullDownConstraints(MDateSelectorConstraints c)
          Sets the display attributes for the pull down calendar
 void setShowTodayButton(boolean show)
           
 void setTextLocalizer(ResourceBundle rb)
          Sets the resource bundle for the day labels
 void valueChanged(MChangeEvent event)
          for MChangeListener
 
Methods inherited from class mseries.ui.MImagePanel
getImageFile, hasImage, loadImage, paintComponent, setImageURL
 
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, paintImmediately, paintImmediately, 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, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, 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, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, 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, hasFocus, 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
 

Constructor Detail

MDateSelectorPanel

public MDateSelectorPanel()

MDateSelectorPanel

public MDateSelectorPanel(boolean lazy,
                          Date min,
                          Date max)
Parameters:
lazy - set to true if it is known that the some constraints will be set before the panel is displayed, this avoids the default constraints from being used only to get overridden by a new set.
Method Detail

setChangerStyle

protected void setChangerStyle(int style)
Sets the style of changer for the month & year, implementations include COMBOBOX/SPINNER and a scrollbar

Parameters:
style - a constant from MDateChanger
See Also:
MDateChanger

requestFocus

public void requestFocus()
Overrides:
requestFocus in class JComponent

setEnabled

public void setEnabled(boolean enabled)
Overrides:
setEnabled in class JComponent

setTextLocalizer

public void setTextLocalizer(ResourceBundle rb)
Sets the resource bundle for the day labels

Parameters:
rb - resource bundle

getTextLocalizer

public ResourceBundle getTextLocalizer()
Returns:
the resource bundle

setMinimum

public void setMinimum(Date min)
Sets the minimum date value allowed

Parameters:
min - the earliest possible date

getMinimum

public Date getMinimum()
Returns the earliest possible date that can be displayed

Returns:
earliest date

setMaximum

public void setMaximum(Date max)
Sets the maximum date value allowed

Parameters:
max - the earliest possible date

getMaximum

public Date getMaximum()
Returns the latest possible date that can be displayed

Returns:
latest date

setCloseOnToday

public void setCloseOnToday(boolean close)

getCloseOnToday

public boolean getCloseOnToday()

setShowTodayButton

public void setShowTodayButton(boolean show)

getShowTodayButton

public boolean getShowTodayButton()

setDate

public void setDate(Date date)
Sets the date in the calendar

Parameters:
date - the date to set

setDMY

public void setDMY(Date date)
Sets a value in the component and does not change the time elements. This method would be used when a specific date is generated and only the Day, Month, Year are really needed along with the time that the component already had.

Parameters:
date - the new date

getDate

public Date getDate()
Returns the currently selected date value

Returns:
the date selected

setFirstDay

public void setFirstDay(int firstDay)
The first column on the calendar grid shows the dates for the day passed here.

Parameters:
firstDay - a day constant from java.util.Calendar such as Calendar.SUNDAY

getFirstDay

public int getFirstDay()
Returns:
the index of the first day in the first column

addMMonthListener

public void addMMonthListener(MMonthListener l)
Registers objects that are to listen to events from the DateSelector Event types of NEW_DATE and NEW_MONTH indicate that the value has changed

Parameters:
l - an MMonthListener

removeMMonthListener

public void removeMMonthListener(MMonthListener l)
De-Registers objects that are to listen to events from the DateSelector

Parameters:
l - an MMonthListener

setPullDownConstraints

public void setPullDownConstraints(MDateSelectorConstraints c)
Sets the display attributes for the pull down calendar

Parameters:
c - an instance of MDateSelectorConstraints that contains the desired settings.

gridCellChanged

public void gridCellChanged(GridSelectionEvent e)
Captures changes in the currently selected cell and sets the current date in the data model from com.java.swing.event.ListSelectionListener

Specified by:
gridCellChanged in interface GridSelectionListener

dataChanged

public void dataChanged(MMonthEvent e)
Reacts to all changes in the data model (MMonth) which is given by the event type. from mseries.utils.MMonthListener interface

Specified by:
dataChanged in interface MMonthListener

setImageFile

public void setImageFile(String imageFile)
Sets the background image, if set the background color is ignored

Overrides:
setImageFile in class MImagePanel
Parameters:
imageFile - the image file, usual Java file types (.jpg, .gif, etc) are supported.

valueChanged

public void valueChanged(MChangeEvent event)
for MChangeListener

Specified by:
valueChanged in interface MChangeListener

mouseClicked

public void mouseClicked(MouseEvent event)
Specified by:
mouseClicked in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent event)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent event)
Specified by:
mouseExited in interface MouseListener

mousePressed

public void mousePressed(MouseEvent event)
Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent event)
Specified by:
mouseReleased in interface MouseListener

setColours

protected void setColours(Component c)

setForeground

public void setForeground(Color foreground)
Set the foreground colour

Overrides:
setForeground in class JComponent

setBackground

public void setBackground(Color background)
Set the background colour

Overrides:
setBackground in class JComponent

setFont

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

setComponentFont

public void setComponentFont(Component c)

setForeground

public void setForeground(int day,
                          Color color)
Sets the foreground color for the column representing the day given.

Parameters:
day - a number in the range 1 - 7 from SUNDAY - SATURDAY, days not set will assume the default foreground color
color - the color to set

setBackground

public void setBackground(int day,
                          Color color)
Sets the background color for the column representing the day given.

Parameters:
day - a number in the range 1 - 7 from SUNDAY - SATURDAY, days not set will assume the default background color
color - the color to set

setBackground

public void setBackground(Color[] colors)
Sets the all the background colors for each day element 0 - SUNDAY, 6 - SATURDAY

Parameters:
colors - the array of colors to set

setForeground

public void setForeground(Color[] colors)
Sets the all the foreground colors for each day element 0 - SUNDAY, 6 - SATURDAY

Parameters:
colors - the array of colors to set

setCellSize

public void setCellSize(Dimension cellSize)

setFocusCycleRoot

public void setFocusCycleRoot(boolean fcr)
Overrides:
setFocusCycleRoot in class Container

isFocusCycleRoot

public boolean isFocusCycleRoot()
Overrides:
isFocusCycleRoot in class Container

close

public void close(String command)

MDateSelector

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