arlut.csd.JCalendar
Class JpanelCalendar

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--arlut.csd.JCalendar.JpanelCalendar
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class JpanelCalendar
extends javax.swing.JPanel
implements java.awt.event.ActionListener

A GUI Calendar for use with the JdateField class.

See Also:
Serialized Form

Field Summary
protected  arlut.csd.JCalendar.JdateButton[] _datebuttonArray
          The meat of the calendar.
private  boolean allowMonthChange
          If true, we'll allow the use to change the month and year displayed in the calendar.
private  javax.swing.JPanel buttonPanel
           
private  javax.swing.JPanel calButtonPanel
           
protected  arlut.csd.JDataComponent.JsetValueCallback callback
          Who do we notify when the user changes the date through direct manipulation of the calendar?
protected  javax.swing.JButton closeButton
           
private  boolean compact
          If true, we'll try to render the calendar in a compressed form, with less space for the calendar buttons.
private  boolean dateIsSet
          Used to control whether we show a selected day in the calendar.
(package private) static boolean debug
           
private  boolean editable
          If true, we will allow the calendar to be used to change the date/time selected.
(package private) static int[] leapDays
           
(package private) static java.lang.String[] month_names
           
(package private) static int[] monthDays
           
private  arlut.csd.JCalendar.JMonthYearPanel monthYearPanel
           
protected  java.awt.Font notTodayFont
           
protected  arlut.csd.JCalendar.JpopUpCalendar pCal
          If we are contained in a pop-up, this will refer to the dialog frame, so that the close button can close it.
private  java.util.Date previousDate
          The last known good date.
protected  java.util.GregorianCalendar selectedDate_calendar
          What time do we have set?
private  boolean showTime
          If true, we'll show the time of day in the calendar, and allow the user to edit the time of day if we are editable.
private  arlut.csd.JCalendar.JTimePanel timePanel
           
protected  java.awt.Font todayFont
           
protected  java.util.GregorianCalendar visibleDate_calendar
          What time do we have visible? Month, year, etc.
 
Fields inherited from class javax.swing.JPanel
 
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.Container
 
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
JpanelCalendar(java.util.GregorianCalendar parentCalendar, arlut.csd.JDataComponent.JsetValueCallback callback, boolean editable)
          Lots of constructors.
JpanelCalendar(java.util.GregorianCalendar parentCalendar, arlut.csd.JDataComponent.JsetValueCallback callback, boolean showTime, boolean editable)
          Constructors.
JpanelCalendar(java.util.GregorianCalendar parentCalendar, arlut.csd.JDataComponent.JsetValueCallback callback, boolean showTime, boolean compact, boolean editable)
          The main constructor.
JpanelCalendar(arlut.csd.JCalendar.JpopUpCalendar pC, java.util.GregorianCalendar parentCalendar, arlut.csd.JDataComponent.JsetValueCallback callback, boolean editable)
           
JpanelCalendar(arlut.csd.JCalendar.JpopUpCalendar pC, java.util.GregorianCalendar parentCalendar, arlut.csd.JDataComponent.JsetValueCallback callback, boolean showTime, boolean editable)
           
JpanelCalendar(arlut.csd.JCalendar.JpopUpCalendar pC, java.util.GregorianCalendar parentCalendar, arlut.csd.JDataComponent.JsetValueCallback callback, boolean showTime, boolean compact, boolean editable)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Our buttons call us back here.
 void buttonPressed(arlut.csd.JCalendar.JdateButton _bttn)
          This method handles the final processing of any calendar button pushed.
 void clear()
           
 void displaySelectedPage()
          This method forces the calendar to jump to the page containing the selected date.
 boolean getAllowMonthChange()
          This method may be used to query the calendar to see if the month and year changing buttons are enabled.
 java.util.Date getDate()
          This method returns the selected date held in this calendar.
 int getSelectedMonth()
          This method returns the month of the year for the selected date, in the range 0-11.
 java.lang.String getSelectedMonthString()
          This method returns a string describing the month and year of the currently selected date
 int getSelectedYear()
          This method returns the year being displayed in the calendar gui.
 int getVisibleMonth()
          This method returns the month of the year currently being displayed in the calendar gui, in the range 0-11.
 int getVisibleYear()
          This method returns the year being displayed in the calendar gui.
 boolean isEditable()
          Returns true if this calendar is configured to allow editing of the selected date.
static void main(java.lang.String[] argv)
          Command line test rig
 void setAllowMonthChange(boolean okay)
          This method may be used to enable or disable the month and year changing buttons.
 void setDate(java.util.Date date)
          This is the main programmatic entry point for setting the date selected in this calendar widget.
private  void setYear(int year)
           
 void timeChanged(java.lang.String _field, int _value)
          This method is used to update the calendar's notion of time from information passed in from the time panel.
 void update()
          This method takes the current time held in selectedDate_calendar and refreshes the calendar with it.
(package private)  void updateDate()
          This will update the visibleDate_calendar according to the current year and month visible in the GUI controls.
protected  void writeDates()
          This method updates the calendar buttons from the time information held in visibleDate_calendar.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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

debug

static final boolean debug
See Also:
Constant Field Values

leapDays

static final int[] leapDays

monthDays

static final int[] monthDays

month_names

static final java.lang.String[] month_names

selectedDate_calendar

protected java.util.GregorianCalendar selectedDate_calendar
What time do we have set?


visibleDate_calendar

protected java.util.GregorianCalendar visibleDate_calendar
What time do we have visible? Month, year, etc.


callback

protected arlut.csd.JDataComponent.JsetValueCallback callback

Who do we notify when the user changes the date through direct manipulation of the calendar?


pCal

protected arlut.csd.JCalendar.JpopUpCalendar pCal

If we are contained in a pop-up, this will refer to the dialog frame, so that the close button can close it.


closeButton

protected javax.swing.JButton closeButton

_datebuttonArray

protected arlut.csd.JCalendar.JdateButton[] _datebuttonArray

The meat of the calendar. This array of JdateButton's are both the display and the main user interface element for the JpanelCalendar.


monthYearPanel

private arlut.csd.JCalendar.JMonthYearPanel monthYearPanel

calButtonPanel

private javax.swing.JPanel calButtonPanel

buttonPanel

private javax.swing.JPanel buttonPanel

timePanel

private arlut.csd.JCalendar.JTimePanel timePanel

todayFont

protected java.awt.Font todayFont

notTodayFont

protected java.awt.Font notTodayFont

editable

private boolean editable

If true, we will allow the calendar to be used to change the date/time selected. If false, we will be display only.


dateIsSet

private boolean dateIsSet

Used to control whether we show a selected day in the calendar. If false, no date has been set, and we'll show all calendar pages with no dates highlighed.


showTime

private boolean showTime

If true, we'll show the time of day in the calendar, and allow the user to edit the time of day if we are editable. If false, we'll show the the date only.


allowMonthChange

private boolean allowMonthChange

If true, we'll allow the use to change the month and year displayed in the calendar.


compact

private boolean compact

If true, we'll try to render the calendar in a compressed form, with less space for the calendar buttons.


previousDate

private java.util.Date previousDate

The last known good date. If we attempt to pass a date change back to our client and the attempt fails, this is the date we'll revert to afterwards.

Constructor Detail

JpanelCalendar

public JpanelCalendar(java.util.GregorianCalendar parentCalendar,
                      arlut.csd.JDataComponent.JsetValueCallback callback,
                      boolean editable)
Lots of constructors.


JpanelCalendar

public JpanelCalendar(java.util.GregorianCalendar parentCalendar,
                      arlut.csd.JDataComponent.JsetValueCallback callback,
                      boolean showTime,
                      boolean editable)
Constructors.

Parameters:
showTime - If true, then the "Choose a time" part will be there. Also, if true, time will appear in date at top.

JpanelCalendar

public JpanelCalendar(arlut.csd.JCalendar.JpopUpCalendar pC,
                      java.util.GregorianCalendar parentCalendar,
                      arlut.csd.JDataComponent.JsetValueCallback callback,
                      boolean editable)

JpanelCalendar

public JpanelCalendar(arlut.csd.JCalendar.JpopUpCalendar pC,
                      java.util.GregorianCalendar parentCalendar,
                      arlut.csd.JDataComponent.JsetValueCallback callback,
                      boolean showTime,
                      boolean editable)

JpanelCalendar

public JpanelCalendar(arlut.csd.JCalendar.JpopUpCalendar pC,
                      java.util.GregorianCalendar parentCalendar,
                      arlut.csd.JDataComponent.JsetValueCallback callback,
                      boolean showTime,
                      boolean compact,
                      boolean editable)
Parameters:
compact - If true, calendar will be drawn smaller.

JpanelCalendar

public JpanelCalendar(java.util.GregorianCalendar parentCalendar,
                      arlut.csd.JDataComponent.JsetValueCallback callback,
                      boolean showTime,
                      boolean compact,
                      boolean editable)

The main constructor. Here's where all the magic happens.

Method Detail

setDate

public void setDate(java.util.Date date)

This is the main programmatic entry point for setting the date selected in this calendar widget. Calling this method will update the selected time/date to that passed, and will redraw the calendar with the selected time/date shown.

Calling this method will not trigger a callback to report the date change to our client.


getDate

public java.util.Date getDate()

This method returns the selected date held in this calendar.


isEditable

public boolean isEditable()

Returns true if this calendar is configured to allow editing of the selected date.


getVisibleMonth

public int getVisibleMonth()

This method returns the month of the year currently being displayed in the calendar gui, in the range 0-11.


getSelectedMonth

public int getSelectedMonth()

This method returns the month of the year for the selected date, in the range 0-11.


getVisibleYear

public int getVisibleYear()

This method returns the year being displayed in the calendar gui.


getSelectedYear

public int getSelectedYear()

This method returns the year being displayed in the calendar gui.


setYear

private void setYear(int year)

clear

public void clear()

setAllowMonthChange

public void setAllowMonthChange(boolean okay)

This method may be used to enable or disable the month and year changing buttons. If this method is called with a false parameter, the calendar will not allow changing of the month/year.

By default, the JpanelCalendar allows month flipping in editable calendars and does not allow it in non-editable calendars.


getAllowMonthChange

public boolean getAllowMonthChange()

This method may be used to query the calendar to see if the month and year changing buttons are enabled. If this method returns false, the calendar does not allow changing of the month/year.


updateDate

void updateDate()
This will update the visibleDate_calendar according to the current year and month visible in the GUI controls. Call this from writeDates().


displaySelectedPage

public void displaySelectedPage()

This method forces the calendar to jump to the page containing the selected date.


getSelectedMonthString

public java.lang.String getSelectedMonthString()

This method returns a string describing the month and year of the currently selected date


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Our buttons call us back here.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

update

public void update()
This method takes the current time held in selectedDate_calendar and refreshes the calendar with it.


writeDates

protected void writeDates()

This method updates the calendar buttons from the time information held in visibleDate_calendar.


buttonPressed

public void buttonPressed(arlut.csd.JCalendar.JdateButton _bttn)
This method handles the final processing of any calendar button pushed.


timeChanged

public void timeChanged(java.lang.String _field,
                        int _value)
This method is used to update the calendar's notion of time from information passed in from the time panel.


main

public static void main(java.lang.String[] argv)
Command line test rig