|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
org.jdesktop.swingx.JXDatePicker
public class JXDatePicker
A component that combines a button, an editable field and a JXMonthView component. The user can select a date from the calendar component, which appears when the button is pressed. The selection from the calendar component will be displayed in editable field. Values may also be modified manually by entering a date into the editable field using one of the supported date formats.
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 |
CANCEL_KEY
action command used for cancel actionEvent. |
static String |
COMMIT_KEY
action command used for commit actionEvent. |
static String |
DATE_IN_MILLIS
|
static String |
EDITOR
|
static String |
HOME_COMMIT_KEY
action key for commit home action |
static String |
HOME_NAVIGATE_KEY
action key for navigate home action |
protected boolean |
lightWeightPopupEnabled
|
static String |
LINK_PANEL
|
static String |
MONTH_VIEW
|
static String |
uiClassID
UI Class ID |
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 | |
---|---|
JXDatePicker()
Create a new date picker using the current date as the initial selection and the default abstract formatter JXDatePickerFormatter . |
|
JXDatePicker(long millis)
Create a new date picker using the specified time as the initial selection and the default abstract formatter JXDatePickerFormatter . |
Method Summary | ||
---|---|---|
void |
addActionListener(ActionListener l)
Adds an ActionListener. |
|
void |
cancelEdit()
Cancels the editor's changes and notifies ActionListeners. |
|
void |
commitEdit()
Commits the editor's changes and notifies ActionListeners. |
|
protected void |
fireActionPerformed()
Fires an ActionEvent with this picker's actionCommand to all listeners. |
|
protected void |
fireActionPerformed(String actionCommand)
Fires an ActionEvent with the given actionCommand to all listeners. |
|
String |
getActionCommand()
Returns the string currently used to identiy fired ActionEvents. |
|
int |
getBaseline(int width,
int height)
Get the baseline for the specified component, or a value less than 0 if the baseline can not be determined. |
|
Date |
getDate()
Returns the currently selected date. |
|
long |
getDateInMillis()
Returns the currently selected date in milliseconds. |
|
JFormattedTextField |
getEditor()
Returns the formatted text field used to edit the date selection. |
|
Font |
getFont()
Returns the font that is associated with the editor of this date picker. |
|
DateFormat[] |
getFormats()
Returns an array of the formats used by the installed formatter if it is a subclass of JXDatePickerFormatter |
|
long |
getLinkDate()
|
|
JPanel |
getLinkPanel()
Return the panel that is used at the bottom of the popup. |
|
|
getListeners(Class<T> listenerType)
Returns an array of all the objects currently registered as FooListener s
upon this JComponent . |
|
JXMonthView |
getMonthView()
Return the JXMonthView used in the popup to
select dates from. |
|
TimeZone |
getTimeZone()
Gets the time zone. |
|
DatePickerUI |
getUI()
Returns the look and feel (L&F) object that renders this component. |
|
String |
getUIClassID()
Returns the UIDefaults key used to
look up the name of the swing.plaf.ComponentUI
class that defines the look and feel
for this component. |
|
boolean |
isEditable()
Returns the editable property. |
|
boolean |
isEditValid()
Returns true if the current value being edited is valid. |
|
boolean |
isLightWeightPopupEnabled()
Gets the value of the lightWeightPopupEnabled
property. |
|
void |
postActionEvent()
Deprecated. use cancelEdit() and commitEdit() instead |
|
void |
removeActionListener(ActionListener l)
Removes an ActionListener. |
|
void |
setActionCommand(String actionCommand)
Sets the string used to identify fired ActionEvents. |
|
void |
setComponentOrientation(ComponentOrientation orientation)
Sets the language-sensitive orientation that is to be used to order the elements or text within this component. |
|
void |
setDate(Date date)
Sets the date property. |
|
void |
setDateInMillis(long millis)
Set the currently selected date. |
|
void |
setEditable(boolean value)
Sets the editable property. |
|
void |
setEditor(JFormattedTextField editor)
Sets the editor. |
|
void |
setFont(Font font)
Set the font for the editor associated with this date picker. |
|
void |
setFormats(DateFormat... formats)
Replaces the currently installed formatter and factory used by the editor. |
|
void |
setFormats(String... formats)
Replaces the currently installed formatter and factory used by the editor. |
|
void |
setLightWeightPopupEnabled(boolean aFlag)
Sets the lightWeightPopupEnabled property, which
provides a hint as to whether or not a lightweight
Component should be used to contain the
JXDatePicker , versus a heavyweight
Component such as a Panel
or a Window . |
|
void |
setLinkDate(long linkDate)
PENDING JW ... |
|
void |
setLinkDate(long linkDate,
String linkFormatString)
Set the date the link will use and the string defining a MessageFormat to format the link. |
|
void |
setLinkPanel(JPanel linkPanel)
Set the panel that will be used at the bottom of the popup. |
|
void |
setMonthView(JXMonthView monthView)
Set the component to use the specified JXMonthView. |
|
void |
setTimeZone(TimeZone tz)
Sets the time zone with the given time zone value. |
|
void |
setUI(DatePickerUI ui)
Sets the L&F object that renders this component. |
|
void |
updateUI()
Resets the UI property with the value from the current look and feel. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String uiClassID
public static final String EDITOR
public static final String MONTH_VIEW
public static final String DATE_IN_MILLIS
public static final String LINK_PANEL
public static final String COMMIT_KEY
public static final String CANCEL_KEY
public static final String HOME_NAVIGATE_KEY
public static final String HOME_COMMIT_KEY
protected boolean lightWeightPopupEnabled
Constructor Detail |
---|
public JXDatePicker()
JXDatePickerFormatter
.
The date picker is configured with the default time zone and locale
setTimeZone(java.util.TimeZone)
,
getTimeZone()
public JXDatePicker(long millis)
JXDatePickerFormatter
.
The date picker is configured with the default time zone and locale
millis
- initial time in millisecondssetTimeZone(java.util.TimeZone)
,
getTimeZone()
Method Detail |
---|
public void setDate(Date date)
Does nothing if the ui vetos the new date - as might happen if the code tries to set a date which is unselectable in the monthView's context. The actual value of the new Date might be changed by the ui, the default implementation cleans the Date by zeroing all time components.
At all "stable" (= not editing in date input field nor in the monthView) times the date is the same in the JXMonthView, this JXDatePicker and the editor. If a new Date is set, this invariant is enforce by the DatePickerUI.
A not null default value is set on instantiation. This is a bound property.
date
- the new date to set.getDate()
public void setDateInMillis(long millis)
millis
- millisecondspublic Date getDate()
public long getDateInMillis()
public DatePickerUI getUI()
public void setUI(DatePickerUI ui)
ui
- UI to use for this JXDatePicker
public void updateUI()
updateUI
in class JComponent
UIManager.getUI(javax.swing.JComponent)
public String getUIClassID()
javax.swing.JComponent
UIDefaults
key used to
look up the name of the swing.plaf.ComponentUI
class that defines the look and feel
for this component. Most applications will never need to
call this method. Subclasses of JComponent
that support
pluggable look and feel should override this method to
return a UIDefaults
key that maps to the
ComponentUI
subclass that defines their look and feel.
getUIClassID
in class JComponent
UIDefaults
key for a
ComponentUI
subclassUIDefaults.getUI(javax.swing.JComponent)
public void setFormats(String... formats)
java.text.SimpleDateFormat
class.
formats
- zero or more not null string formats to use. Note that a
null array is allowed and resets the formatter to use the
localized default formats.
NullPointerException
- any array element is null.SimpleDateFormat
public void setFormats(DateFormat... formats)
formats
- zero or more not null formats to use. Note that a
null array is allowed and resets the formatter to use the
localized default formats.
NullPointerException
- any of its elements is null.public DateFormat[] getFormats()
JXDatePickerFormatter.
javax.swing.JFormattedTextField.AbstractFormatter
and javax.swing.text.DefaultFormatter
do not have
support for accessing the formats used.
- Returns:
- array of formats guaranteed to be not null, but might be empty.
public JXMonthView getMonthView()
JXMonthView
used in the popup to
select dates from.
public void setMonthView(JXMonthView monthView)
monthView
- month view comopnent.
NullPointerException
- if view component is nullsetTimeZone(java.util.TimeZone)
,
getTimeZone()
public TimeZone getTimeZone()
TimeZone
used by the JXMonthView
.public void setTimeZone(TimeZone tz)
tz
- The TimeZone
.public long getLinkDate()
public void setLinkDate(long linkDate, String linkFormatString)
linkDate
- Date in millisecondslinkFormatString
- String used to format the linkMessageFormat
public void setLinkDate(long linkDate)
linkDate
- public JPanel getLinkPanel()
public void setLinkPanel(JPanel linkPanel)
linkPanel
- The new panel to install in the popuppublic JFormattedTextField getEditor()
Clients should NOT use this method. It is provided to temporarily support the PLAF code.
public void setEditor(JFormattedTextField editor)
The default is created and set by the UI delegate.
Clients should NOT use this method. It is provided to temporarily support the PLAF code.
editor
- the formatted input.
NullPointerException
- if editor is null.getEditor()
public void setComponentOrientation(ComponentOrientation orientation)
java.awt.Component
LayoutManager
and Component
subclasses will use this property to
determine how to lay out and draw components.
At construction time, a component's orientation is set to
ComponentOrientation.UNKNOWN
,
indicating that it has not been specified
explicitly. The UNKNOWN orientation behaves the same as
ComponentOrientation.LEFT_TO_RIGHT
.
To set the orientation of a single component, use this method.
To set the orientation of an entire component
hierarchy, use
applyComponentOrientation
.
setComponentOrientation
in class Component
ComponentOrientation
public boolean isEditValid()
public void commitEdit() throws ParseException
ParseException
- Throws parse exception if the date
can not be parsed.public void cancelEdit()
public void setEditable(boolean value)
value
- isEditable()
public boolean isEditable()
true
if the picker is editable; false
otherwisepublic Font getFont()
getFont
in interface MenuContainer
getFont
in class Component
Component.setFont(java.awt.Font)
public void setFont(Font font)
setFont
in class JComponent
font
- the desired Font
for this componentComponent.getFont()
public void setLightWeightPopupEnabled(boolean aFlag)
lightWeightPopupEnabled
property, which
provides a hint as to whether or not a lightweight
Component
should be used to contain the
JXDatePicker
, versus a heavyweight
Component
such as a Panel
or a Window
. The decision of lightweight
versus heavyweight is ultimately up to the
JXDatePicker
. Lightweight windows are more
efficient than heavyweight windows, but lightweight
and heavyweight components do not mix well in a GUI.
If your application mixes lightweight and heavyweight
components, you should disable lightweight popups.
The default value for the lightWeightPopupEnabled
property is true
, unless otherwise specified
by the look and feel. Some look and feels always use
heavyweight popups, no matter what the value of this property.
See the article Mixing Heavy and Light Components
on
The Swing Connection
This method fires a property changed event.
aFlag
- if true
, lightweight popups are desiredpublic boolean isLightWeightPopupEnabled()
lightWeightPopupEnabled
property.
lightWeightPopupEnabled
propertysetLightWeightPopupEnabled(boolean)
public int getBaseline(int width, int height)
width
- Width of the component to determine baseline for.height
- Height of the component to determine baseline for.
public String getActionCommand()
public void setActionCommand(String actionCommand)
actionCommand
- The string used for identifying ActionEvents.public void addActionListener(ActionListener l)
l
- The ActionListener that is to be notifiedpublic void removeActionListener(ActionListener l)
l
- The action listener to remove.public <T extends EventListener> T[] getListeners(Class<T> listenerType)
javax.swing.JComponent
FooListener
s
upon this JComponent
.
FooListener
s are registered using the
addFooListener
method.
You can specify the listenerType
argument
with a class literal,
such as
FooListener.class
.
For example, you can query a
JComponent
c
for its mouse listeners with the following code:
MouseListener[] mls = (MouseListener[])(c.getListeners(MouseListener.class));If no such listeners exist, this method returns an empty array.
getListeners
in class JComponent
listenerType
- the type of listeners requested; this parameter
should specify an interface that descends from
java.util.EventListener
FooListener
s on this component,
or an empty array if no such
listeners have been addedJComponent.getVetoableChangeListeners()
,
JComponent.getAncestorListeners()
protected void fireActionPerformed()
protected void fireActionPerformed(String actionCommand)
@Deprecated public void postActionEvent()
cancelEdit()
and commitEdit()
instead
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |