uic.widgets.calendar
Class UICCalendar

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by uic.widgets.calendar.UICCalendar
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class UICCalendar
extends JComponent

A widget for selecting a date.

By clicking on any date that date will be selected. If the next month is clicked, the view will change to the next month, the same goes for the previous month.

By calling the setShowWeekNrs(boolean) method weeknumbers can be turned on or off. With the weeknumbers showing the UICCalendar looks like this:

The UICCalendar follows Translate.getLocale(), unless specified otherwise. For instance, the UICCalendar for the Dutch locale ("nl_NL") will look like this:

TODO - integrate the calendar plugins.

Since:
2.0
Author:
Stefan Rotman
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.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String SELECT_ACTION
          The actionCommand for the ActionEvent that will be fired on date selections.
 
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
UICCalendar()
          Constructs a new UICCalendar with the default locale and today as selected date.
UICCalendar(Locale locale, Calendar calendar)
          Constructs a new UICCalendar with the specified locale and Calendar to use as selected date.
UICCalendar(UICCalendarModel model)
          Constructs a new UICCalendar that uses the specified model.
 
Method Summary
 void addActionListener(ActionListener listener)
          Adds the specified listener to the ActionListener list.
 void changedDateSlot(int oldDate, int newDate)
          Gets called for date changes in the model.
 void changedMonthSlot()
          Gets called for month changes in the model.
 Calendar getCalendar()
           
 int getDate()
           
 Dimension getMinimumSize()
          Returns the minimal size for this UICCalendar component.
 UICCalendarModel getModel()
           
 int getMonth()
           
 Dimension getPreferredSize()
          Returns the preferred size for this UICCalendar component.
 boolean getShowWeekNrs()
          Returns whether or not week numbers are shown.
 int getWeek()
           
 int getYear()
           
 void paintComponent(Graphics g)
          Paint the calendar on this component.
 void removeActionListener(ActionListener listener)
          Removes the specified listener from the ActionListener list.
protected  void selectDateSlot(int x, int y, boolean finalSelect)
          Selects the date at the specified x,y position.
 void setCalendar(Calendar calendar)
           
 void setDate(int date)
           
 void setMonth(int month)
           
 void setShowWeekNrs(boolean showWeekNrs)
          Sets the showing of week numbers on or off.
 void setWeek(int week)
           
 void setYear(int year)
           
 
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, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, updateUI
 
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, 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
 

Field Detail

SELECT_ACTION

public static String SELECT_ACTION
The actionCommand for the ActionEvent that will be fired on date selections.

Constructor Detail

UICCalendar

public UICCalendar()
Constructs a new UICCalendar with the default locale and today as selected date.


UICCalendar

public UICCalendar(Locale locale,
                   Calendar calendar)
Constructs a new UICCalendar with the specified locale and Calendar to use as selected date.

Parameters:
locale - the locale to use.
calendar - the Calendar to use as selected date.

UICCalendar

public UICCalendar(UICCalendarModel model)
Constructs a new UICCalendar that uses the specified model.

Parameters:
model - the calendar model to use.
Method Detail

setShowWeekNrs

public void setShowWeekNrs(boolean showWeekNrs)
Sets the showing of week numbers on or off.

Parameters:
showWeekNrs - indicates whether or not to show week numbers.

getShowWeekNrs

public boolean getShowWeekNrs()
Returns whether or not week numbers are shown.


getMinimumSize

public Dimension getMinimumSize()
Returns the minimal size for this UICCalendar component.

Overrides:
getMinimumSize in class JComponent

getPreferredSize

public Dimension getPreferredSize()
Returns the preferred size for this UICCalendar component.

Overrides:
getPreferredSize in class JComponent

paintComponent

public void paintComponent(Graphics g)
Paint the calendar on this component.

Overrides:
paintComponent in class JComponent

selectDateSlot

protected void selectDateSlot(int x,
                              int y,
                              boolean finalSelect)
Selects the date at the specified x,y position.


changedMonthSlot

public void changedMonthSlot()
Gets called for month changes in the model. This is in case of month change, but also in case of year change, calendar change, or week change.


changedDateSlot

public void changedDateSlot(int oldDate,
                            int newDate)
Gets called for date changes in the model.


getModel

public UICCalendarModel getModel()

setCalendar

public void setCalendar(Calendar calendar)

getCalendar

public Calendar getCalendar()

setYear

public void setYear(int year)

getYear

public int getYear()

setMonth

public void setMonth(int month)

getMonth

public int getMonth()

setDate

public void setDate(int date)

getDate

public int getDate()

setWeek

public void setWeek(int week)

getWeek

public int getWeek()

addActionListener

public void addActionListener(ActionListener listener)
Adds the specified listener to the ActionListener list. Action listeners will be notified on date selections.

Parameters:
listener - the listener to add.

removeActionListener

public void removeActionListener(ActionListener listener)
Removes the specified listener from the ActionListener list.

Parameters:
listener - the listener to remove.


Copyright © 2002-2004 Thomas Zander Available under the Free Apache licence