|
Version: 1.1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JPanel org.biomoby.service.dashboard.chooser.DateTimeChooser
public class DateTimeChooser
A Swing component that lets choose date and time. It is just a thin wrapper around an open-source package jcalendar, written by Kai Toedter, and released under GNU Lesser General Public License.
Regarding functionality, the wrapper is similar to the standard
Java JColorChooser. Which means that a date-time chooser
can be either instantiate as a standalone component, or as part of
a modal dialog. In former case, the user can listen to the
date-time changes in the chooser by implementing a standard
ChangeListener, in the later case the returned value of
showDialog
contains the selected date-time.
It also allows to add a user-defined preview panel that can indicate (in any user-defined format) directly in the chooser window what date is selected.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.BaselineResizeBehavior |
Field Summary |
---|
Fields inherited from class javax.swing.JComponent |
---|
TOOL_TIP_TEXT_KEY, 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 | |
---|---|
DateTimeChooser()
Creates a date-time chooser with the curent date as an initial date. |
|
DateTimeChooser(Date initialDate)
Creates a date-time chooser with the given date as an initial date. |
Method Summary | |
---|---|
void |
addChangeListener(ChangeListener listener)
Adds a listener that is notified when a new date is selected. |
ChangeListener[] |
getChangeListeners()
Returns an array of all the ChangeListener s. |
Date |
getDate()
Gets the current value from the date-time chooser. |
Date |
getInitialDate()
Returns a date that was used to initiate this date-time chooser instance. |
JPanel |
getPreviewPanel()
Returns the preview panel that shows a currently chosen date. |
void |
propertyChange(PropertyChangeEvent evt)
Implementing PropertyChangeListener. |
void |
removeChangeListener(ChangeListener listener)
Remove a listener that has been previously added by addChangeListener(javax.swing.event.ChangeListener) . |
void |
setDate(Date newDate)
Sets the given date as a new value for the date-time chooser. |
void |
setPreviewPanel(JPanel preview)
Sets the current preview panel. |
static Date |
showDialog(Component parent,
String title,
Date initialDate)
Shows a modal date-time chooser dialog and blocks until the dialog is hidden. |
static Date |
showDialog(Component parent,
String title,
DateTimeChooser chooser)
Shows a modal date-time chooser dialog and blocks until the dialog is hidden. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, setUI, updateUI |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DateTimeChooser()
public DateTimeChooser(Date initialDate)
Method Detail |
---|
public Date getDate()
public void setDate(Date newDate)
newDate
- to be set into the chooserpublic Date getInitialDate()
public JPanel getPreviewPanel()
public void setPreviewPanel(JPanel preview)
preview
- is a panel used to display currently selected datepublic static Date showDialog(Component parent, String title, Date initialDate)
If the user presses the "OK" button, then this method hides/disposes the dialog and returns the selected date.
If the user presses the "Cancel" button or closes the dialog without pressing "OK", then this method hides/disposes the dialog and returns the initial date (which could have been null).
If the user presses the "Empty" button, then this method hides/disposes the dialog and returns null. It indicates that no date is selected (even though that might have been a date as an initial value).
parent
- is the parent Component for the dialogtitle
- contains the dialog's titleinitialDate
- is shown when the dialog starts; if this is
null the current date is shown
public static Date showDialog(Component parent, String title, DateTimeChooser chooser)
showDialog
. This method allows to create an instance of a date-time chooser separately, and perhaps to customize it (e.g. by calling chooser.setPreviewPanel (myPreviewPanel)) before it is used in a modal dialog.
parent
- is the parent Component for the dialogtitle
- contains the dialog's titlechooser
- is the chooser instance that was created
separately and will be used in this dialog
public void addChangeListener(ChangeListener listener)
listener
- to be addedpublic void removeChangeListener(ChangeListener listener)
addChangeListener(javax.swing.event.ChangeListener)
.
listener
- to be addedpublic ChangeListener[] getChangeListeners()
ChangeListener
s.
ChangeListener
s added, or an empty
array if no listeners have been addedpublic void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener
|
Version: 1.1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |