Copyright © 2011 Citra Technologies. All Rights Reserved.

com.citra.editors
Class JDateChooser

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 com.citra.editors.JDateChooser
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class JDateChooser
extends JPanel

A date chooser that contains controls for specifying year, month, date and time.

See Also:
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.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  boolean keepSelectedDate
          flag that indicates whether the selected date should be kept, when changing the month or year from the gui
protected  boolean showDatePanel
          flag that controls the date panel's visibility.
protected  boolean showTimePanel
          flag that controls the time panel's visibility.
 
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
JDateChooser()
          Creates a new JDateChooser object.
 
Method Summary
 void clearSelectionDate()
           
static JDialog createDialog(Component parent, String title, boolean modal, JDateChooser dateChooser, ActionListener okListener, ActionListener cancelListener)
          Creates and returns a new dialog containing the JDateChooser object and buttons for controlling the dialog.
 Calendar getDateFromGUI()
          Returns a calendar object which is initialized to the selected values shown on the datechooser panel.
 boolean getKeepSelectedDate()
          Determines whether the selected date should be kept, when changing the month or year.
 Calendar getSelectedDate()
          Returns a calendar object which is initialized to the selected date.
 boolean getShowDatePanel()
          Determines whether the date panel is visible.
 boolean getShowSeconds()
          Determines whether the date chooser will show and accept seconds in the time field box.
 boolean getShowTimePanel()
          Determines whether the time panel is visible.
 void loadCurrentDate()
          Positions the date chooser to the current date.
 void loadDate(Calendar calendar)
          Positions the date chooser to the date specified by calendar.
 void loadDate(Date date)
          Positions the date chooser to the date specified by date.
 void setDefaultTime(String defaultTime)
          Assigns the default time to show when the time field is visible.
 void setKeepSelectedDate(boolean keepSelectedDate)
          Determines whether the selected date should be kept, when changing the month or year.
 void setSelectedDate(Date date)
          Selects and positions the date chooser to the specified date.
 void setShowDatePanel(boolean showDatePanel)
          Specifies whether the date panel should be visible.
 void setShowSeconds(boolean showSeconds)
          Determines whether the date chooser will show and accept seconds in the time field box.
 void setShowTimePanel(boolean showTimePanel)
          Specifies whether the time panel should be visible.
 void updateUI()
          Resets the UI property with a value from the current look and feel.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI
 
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

showTimePanel

protected boolean showTimePanel
flag that controls the time panel's visibility.


showDatePanel

protected boolean showDatePanel
flag that controls the date panel's visibility.


keepSelectedDate

protected boolean keepSelectedDate
flag that indicates whether the selected date should be kept, when changing the month or year from the gui

Constructor Detail

JDateChooser

public JDateChooser()
Creates a new JDateChooser object.

Method Detail

clearSelectionDate

public void clearSelectionDate()

createDialog

public static JDialog createDialog(Component parent,
                                   String title,
                                   boolean modal,
                                   JDateChooser dateChooser,
                                   ActionListener okListener,
                                   ActionListener cancelListener)
Creates and returns a new dialog containing the JDateChooser object and buttons for controlling the dialog.

The "OK" button hides the dialog and stores the selected date.

The "Cancel" button hides the dialog without storing the selected date.

The "Reset" button resets the date chooser to the date which was set when the dialog was invoked.

Furthermore, the user can supply his own ActionListeners that will be invoked when the "OK" or "Cancel" buttons are pressed.

Parameters:
parent - the parent component for the dialog
title - the title for the dialog
modal - boolean specifying whether the dialog is modal
dateChooser - the date chooser to be placed inside the dialog
okListener - the ActionListener invoked when "OK" is pressed
cancelListener - the ActionListener invoked when "Cancel" is pressed
Returns:
a new dialog componenet

getDateFromGUI

public Calendar getDateFromGUI()
Returns a calendar object which is initialized to the selected values shown on the datechooser panel.

Returns:
a calendar object

getKeepSelectedDate

public boolean getKeepSelectedDate()
Determines whether the selected date should be kept, when changing the month or year. The default value is false.

Returns:
true, if the date is to be kept, false otherwise

getSelectedDate

public Calendar getSelectedDate()
Returns a calendar object which is initialized to the selected date.

Returns:
a calendar object

getShowDatePanel

public boolean getShowDatePanel()
Determines whether the date panel is visible.

Returns:
true if the date panel is visible, false otherwise

getShowSeconds

public boolean getShowSeconds()
Determines whether the date chooser will show and accept seconds in the time field box.

Returns:
true, if seconds are shown, false otherwise.

getShowTimePanel

public boolean getShowTimePanel()
Determines whether the time panel is visible.

Returns:
true if the time panel is visible, false otherwise

loadCurrentDate

public void loadCurrentDate()
Positions the date chooser to the current date.


loadDate

public void loadDate(Calendar calendar)
Positions the date chooser to the date specified by calendar.

Parameters:
calendar - the calendar object which the date chooser will show.

loadDate

public void loadDate(Date date)
Positions the date chooser to the date specified by date.

Parameters:
date - the date which the date chooser will show.

setDefaultTime

public void setDefaultTime(String defaultTime)
Assigns the default time to show when the time field is visible.

Parameters:
defaultTime - the default time in the format HH:MM

setKeepSelectedDate

public void setKeepSelectedDate(boolean keepSelectedDate)
Determines whether the selected date should be kept, when changing the month or year. The default value is false.

Parameters:
keepSelectedDate - true, if the date is to be kept, false otherwise

setSelectedDate

public void setSelectedDate(Date date)
Selects and positions the date chooser to the specified date.

Parameters:
date - the date which this chooser will show.

setShowDatePanel

public void setShowDatePanel(boolean showDatePanel)
Specifies whether the date panel should be visible.

Parameters:
showDatePanel - true if the date panel is visible, false otherwise

setShowSeconds

public void setShowSeconds(boolean showSeconds)
Determines whether the date chooser will show and accept seconds in the time field box.

Parameters:
showSeconds - true, if seconds are shown, false otherwise.

setShowTimePanel

public void setShowTimePanel(boolean showTimePanel)
Specifies whether the time panel should be visible.

Parameters:
showTimePanel - true if the time panel is visible, false otherwise

updateUI

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

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

Copyright © 2011 Citra Technologies. All Rights Reserved.