JComponentPack 1.5.0

com.zfqjava.swing
Class JCalendar

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.zfqjava.swing.JCalendar
All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class JCalendar
extends JComponent
implements Accessible, ActionListener

JCalendar provides a calendar component.
Client Property:

NameValueDefault Value
JCalendar.headerStyle
  • Classic_Arrow
  • Modern_Arrow
  • ComboBox_Spinner
  • None
Classic_Arrow
JCalendar.centerStyle
  • MonthView
  • YearView
MonthView
JCalendar.footerStyle
  • Today
  • None
Today
JCalendar.autoResizeRowHeight
  • Boolean.TRUE
  • Boolean.FALSE
Boolean.TRUE
JCalendar.headerRolloverMode
  • JToolBar
  • JButton
JToolBar
JCalendar.todayButtonFireActionEventEnabled
  • Boolean.TRUE
  • Boolean.FALSE
Boolean.FALSE

See Also:
Serialized Form

Nested Class Summary
protected  class JCalendar.AccessibleJCalendar
          This class implements accessibility support for the JCalendar class.
static class JCalendar.AdjustTimeStyle
           
 
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
JCalendar()
          Constructs a JCalendar.
 
Method Summary
 void actionPerformed(ActionEvent e)
          This method should not invoke by user.
 void addActionListener(ActionListener listener)
          Adds an action listener to the JCalendar.
 void addChangeListener(ChangeListener l)
          Adds a ChangeListener to the JCalendar component.
 boolean canSelect(int year, int month, int day)
          Determines whether the specified time can be selected.
protected  void fireActionPerformed(ActionEvent e)
          Notifies all listeners that have registered interest for notification on this event type.
protected  void fireStateChanged()
          Notifies all listeners that have registered interest for notification on this event type.
 AccessibleContext getAccessibleContext()
          Gets the AccessibleContext associated with this JCalendar.
 int getActionClickCount()
           
 ActionListener[] getActionListeners()
          Returns an array of all the action listeners registered on this JCalendar.
 Date getAdjustTime()
          Returns the adjust time based the adjust style.
 JCalendar.AdjustTimeStyle getAdjustTimeStyle()
           
 Calendar getCalendar()
          Returns the calendar object used by this JClock.
 CellProvider getCellProvider()
          Returns the cell provider for renderer.
 AbstractCellRenderer getCellRenderer()
          Returns the cell renderer for render day.
 ChangeListener[] getChangeListeners()
          Returns an array of all the ChangeListeners added to this JCalendar with addChangeListener().
 int getDate()
          Returns the calendar's current date.
 Calendar getModel()
          Deprecated. replaced by getCalendar()
 int getMonth()
          Returns the calendar's current month.
 DateFormat getSelectionDateFormat()
          Returns the selection date format.
 Date getTime()
          Gets this Calendar's current time.
 CalendarUI getUI()
          Returns the look and feel (L&F) object that renders this component.
 String getUIClassID()
          Returns a string that specifies the name of the L&F class that renders this component.
 int getYear()
          Returns this calendar's current year.
 boolean isSelectionLabelVisible()
          Returns whether the selection label is visible.
protected  String paramString()
          Returns a string representation of this JCalendar.
 void removeActionListener(ActionListener listener)
          Removes the specified action listener from the JCalendar.
 void removeChangeListener(ChangeListener l)
          Removes a ChangeListener from the JCalendar component.
 void setActionClickCount(int actionClickCount)
           
 void setAdjustTimeStyle(JCalendar.AdjustTimeStyle adjustTimeStyle)
           
 void setCalendar(Calendar cal)
          Sets the calendar object used by this JClock.
 void setCellProvider(CellProvider cellProvider)
          Sets the cell provider for renderer.
 void setCellRenderer(AbstractCellRenderer cellRenderer)
           
 void setDate(int date)
          Sets the day of the month of this JCalendar object to the specified value.
 void setModel(Calendar cal)
          Deprecated. replaced by setCalendar(java.util.Calendar)
 void setMonth(int month)
          Sets the month of this date to the specified value.
 void setSelectionDateFormat(DateFormat format)
          Sets the selection date format.
 void setSelectionLabelVisible(boolean selectionLabelVisible)
          Sets the selection label visible property.
 void setTime(Date time)
          Sets this Calendar's current time with the given Date.
 void setUI(CalendarUI ui)
          Sets the look and feel (L&F) object that renders this component.
 void setYear(int year)
          Sets the year of this JCalendar object to be the specified value.
 void updateUI()
          Resets the UI property with a value from the current look and feel.
 
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, 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

JCalendar

public JCalendar()
Constructs a JCalendar.

Method Detail

updateUI

public void updateUI()
Resets the UI property with a value from the current look and feel.

Overrides:
updateUI in class JComponent
See Also:
JComponent.updateUI()

getUI

public CalendarUI getUI()
Returns the look and feel (L&F) object that renders this component.

Returns:
the CalendarUI object that renders this component

setUI

public void setUI(CalendarUI ui)
Sets the look and feel (L&F) object that renders this component.

Parameters:
ui - the CalendarUI L&F object
See Also:
UIDefaults.getUI(javax.swing.JComponent)

getUIClassID

public String getUIClassID()
Returns a string that specifies the name of the L&F class that renders this component.

Overrides:
getUIClassID in class JComponent
Returns:
"CalendarUI"
See Also:
JComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)

getModel

public Calendar getModel()
Deprecated. replaced by getCalendar()

Returns the model, java.util.Calendar.

Returns:
the calendar model
See Also:
setModel(java.util.Calendar)

setModel

public void setModel(Calendar cal)
Deprecated. replaced by setCalendar(java.util.Calendar)

Sets the model, java.util.Calendar.

Parameters:
cal - the calendar model
See Also:
getModel()

getActionClickCount

public int getActionClickCount()

setActionClickCount

public void setActionClickCount(int actionClickCount)

setCalendar

public void setCalendar(Calendar cal)
Sets the calendar object used by this JClock.

Parameters:
cal - the calendar object used by this JClock
Since:
JCalendar 1.2
See Also:
getCalendar()

getCalendar

public Calendar getCalendar()
Returns the calendar object used by this JClock.

Returns:
the calendar object used by this JClock
Since:
JCalendar 1.2
See Also:
setCalendar(java.util.Calendar)

setTime

public void setTime(Date time)
Sets this Calendar's current time with the given Date.

Parameters:
date - the given Date.
See Also:
getTime()

getTime

public Date getTime()
Gets this Calendar's current time.

Returns:
the current time.
See Also:
setTime(java.util.Date)

getAdjustTimeStyle

public JCalendar.AdjustTimeStyle getAdjustTimeStyle()

setAdjustTimeStyle

public void setAdjustTimeStyle(JCalendar.AdjustTimeStyle adjustTimeStyle)

getAdjustTime

public Date getAdjustTime()
Returns the adjust time based the adjust style.

Returns:
Since:
JComponentPack 1.1.0

getYear

public int getYear()
Returns this calendar's current year.

Returns:
the year represented by this date
See Also:
Calendar

setYear

public void setYear(int year)
Sets the year of this JCalendar object to be the specified value.

Parameters:
year - the year value.
See Also:
Calendar

getMonth

public int getMonth()
Returns the calendar's current month.

Returns:
the month represented by this date.
See Also:
replaced by Calendar.get(Calendar.MONTH).

setMonth

public void setMonth(int month)
Sets the month of this date to the specified value.

Parameters:
month - the month value between 0-11.
See Also:
replaced by Calendar.set(Calendar.MONTH, int month).

getDate

public int getDate()
Returns the calendar's current date.

Returns:
the day of the month represented by this date.
See Also:
Calendar

setDate

public void setDate(int date)
Sets the day of the month of this JCalendar object to the specified value.

Parameters:
date - the day of the month value between 1-31.
See Also:
Calendar

canSelect

public boolean canSelect(int year,
                         int month,
                         int day)
Determines whether the specified time can be selected.

Parameters:
year - the year
month - the month
day - the day
Since:
ComponentSet 1.7.1

setSelectionDateFormat

public void setSelectionDateFormat(DateFormat format)
Sets the selection date format.

Parameters:
dateFormat - the selection date format
Since:
ComponentSet 1.7.3

getSelectionDateFormat

public DateFormat getSelectionDateFormat()
Returns the selection date format.

Since:
ComponentSet 1.7.3

isSelectionLabelVisible

public boolean isSelectionLabelVisible()
Returns whether the selection label is visible.

Returns:
true if the selection label is visible, false otherwise.
Since:
ComponentSet 1.7.4
See Also:
setSelectionLabelVisible(boolean)

setSelectionLabelVisible

public void setSelectionLabelVisible(boolean selectionLabelVisible)
Sets the selection label visible property.

Parameters:
selectionLabelVisible - the selection label visible property
Since:
ComponentSet 1.7.4
See Also:
isSelectionLabelVisible()

setCellRenderer

public void setCellRenderer(AbstractCellRenderer cellRenderer)

getCellRenderer

public AbstractCellRenderer getCellRenderer()
Returns the cell renderer for render day.

Returns:
the cell renderer
Since:
JCalendar 1.3
See Also:
setCellRenderer(com.zfqjava.swing.cell.AbstractCellRenderer)

setCellProvider

public void setCellProvider(CellProvider cellProvider)
Sets the cell provider for renderer.

Parameters:
cellProvider - the cell provider
Since:
JCalendar 1.3
See Also:
getCellProvider()

getCellProvider

public CellProvider getCellProvider()
Returns the cell provider for renderer.

Returns:
the cell provider
Since:
JCalendar 1.3
See Also:
setCellProvider

actionPerformed

public void actionPerformed(ActionEvent e)
This method should not invoke by user.

Specified by:
actionPerformed in interface ActionListener

addActionListener

public void addActionListener(ActionListener listener)
Adds an action listener to the JCalendar.

Parameters:
listener - the listener to add
See Also:
JCalendar()

removeActionListener

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

Parameters:
listener - the listener to remove

getActionListeners

public ActionListener[] getActionListeners()
Returns an array of all the action listeners registered on this JCalendar.

Returns:
all of the JCalendar's ActionListeners or an empty array if no action listeners are currently registered
See Also:
addActionListener(java.awt.event.ActionListener), removeActionListener(java.awt.event.ActionListener)

fireActionPerformed

protected void fireActionPerformed(ActionEvent e)
Notifies all listeners that have registered interest for notification on this event type.

Parameters:
e - the action event to fire
See Also:
EventListenerList

addChangeListener

public void addChangeListener(ChangeListener l)
Adds a ChangeListener to the JCalendar component.

Note: Fires ChangeEvent when month or year or date selection has changed. If only interesting date changed event, attach a PropertyChangeListener and listen date property, about month or year you can use the same style.

Parameters:
l - the listener to add

removeChangeListener

public void removeChangeListener(ChangeListener l)
Removes a ChangeListener from the JCalendar component.

Note: Fires ChangeEvent when month or year or date selection has changed. If only interesting date changed event, attach a PropertyChangeListener and listen date property, about month or year you can use the same style.

Parameters:
l - the listener to remove

getChangeListeners

public ChangeListener[] getChangeListeners()
Returns an array of all the ChangeListeners added to this JCalendar with addChangeListener().

Note: Fires ChangeEvent when month or year or date selection has changed. If only interesting date changed event, attach a PropertyChangeListener and listen date property, about month or year you can use the same style.

Returns:
all of the ChangeListeners added or an empty array if no listeners have been added

fireStateChanged

protected void fireStateChanged()
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created.

See Also:
EventListenerList

paramString

protected String paramString()
Returns a string representation of this JCalendar. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

Overrides:
paramString in class JComponent
Returns:
a string representation of this JCalendar.

getAccessibleContext

public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this JCalendar. For JCalendars, the AccessibleContext takes the form of an AccessibleJCalendar. A new AccessibleJCalendar instance is created if necessary.

Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in class JComponent
Returns:
an AccessibleJCalendar that serves as the AccessibleContext of this JCalendar

JComponentPack 1.5.0

Send your Feedback
JComponentPack 1.5.0
Copyright © 2001-2007 Extreme Component, Inc. All rights reserved.