Class JXDatePicker
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- org.jdesktop.swingx.JXDatePicker
-
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
public class JXDatePicker extends JComponent
A component for entering dates with a user interaction similar to a JComboBox. The dates can be typed into a text field or selected from a JXMonthView which opens in a JXPopupMenu on user's request.The date selection is controlled by the JXMonthView's DateSelectionModel. This allows the use of all its functionality in the JXDatePicker as well. F.i. restrict the selection to a date in the current or next week:
Similar to a JXMonthView, the JXDatePicker fires an ActionEvent when the user actively commits or cancels a selection. Interested client code can add a ActionListener to be notified by the user action.Appointment appointment = new Appointment(director, "Be sure to have polished shoes!"); JXDatePicker picker = new JXDatePicker(); Calendar calendar = picker.getMonthView().getCalendar(); // starting today if we are in a hurry calendar.setTime(new Date()); picker.getMonthView().setLowerBound(calendar.getTime()); // end of next week CalendarUtils.endOfWeek(calendar); calendar.add(Calendar.WEEK_OF_YEAR); picker.getMonthView().setUpperBound(calendar.getTime());
Note that ActionListener will not be notified if the user edits the date text without hitting the Enter key afterwards. To detect both kinds of date change, interested client code can add a PropertyChangeListener.JXDatePicker picker = new JXDatePicker(new Date()); ActionListener l = new ActionListener() { public void actionPerformed(ActionEvent e) { if (JXDatePicker.COMMIT_KEY.equals(e.getActionCommand)) { saveDate(picker.getDate()); } } }; picker.addActionListener(l);
JXDatePicker picker = new JXDatePicker(new Date()); PropertyChangeListener listener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if ("date".equals(e.getPropertyName()) { saveDate(picker.getDate()); } } }; picker.addPropertyChangeListener(listener);
The DateFormats used in the JXDatePicker's are initialized to the default formats of the DatePickerFormatter, as defined by the picker's resourceBundle DatePicker.properties. Application code can overwrite the picker's default
PENDING JW: explain what the alternatives are for (after understanding it myself ;-)picker.setDateFormats(myCustomFormat, myAlternativeCustomFormat);
The selected Date is a bound property of the JXDatePicker. This allows easy binding to a property of a custom bean when using a binding framework.
Keybindings (as installed by the UI-Delegate)
- ENTER commits the edited or selected value
- ESCAPE reverts the edited or selected value
- alt-DOWN opens the monthView popup
- shift-F5 if monthView is visible, navigates the monthView to today (no effect otherwise)
- F5 commits today
- Author:
- Joshua Outwater, Jeanette Winzenburg
- See Also:
JXMonthView
,DateSelectionModel
,DatePickerFormatter
, Serialized Form
-
-
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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description static String
CANCEL_KEY
action command used for cancel actionEvent.static String
COMMIT_KEY
action command used for commit actionEvent.static String
EDITOR
static String
HOME_COMMIT_KEY
action key for commit home actionstatic String
HOME_NAVIGATE_KEY
action key for navigate home actionprotected boolean
lightWeightPopupEnabled
static String
LINK_PANEL
static String
MONTH_VIEW
static String
uiClassID
UI Class ID-
Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
Constructors Constructor Description JXDatePicker()
Intantiates a date picker with no selection and the defaultDatePickerFormatter
.JXDatePicker(Date selected)
Intantiates a date picker using the specified time as the initial selection and the defaultDatePickerFormatter
.JXDatePicker(Date selection, Locale locale)
Intantiates a date picker using the specified time as the initial selection and the defaultDatePickerFormatter
.JXDatePicker(Locale locale)
Intantiates a date picker with no selection and the defaultDatePickerFormatter
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addActionListener(ActionListener l)
Adds an ActionListener.void
addPopupMenuListener(PopupMenuListener l)
Adds a PopupMenuListener.void
cancelEdit()
Cancels the editor's changes and notifies ActionListeners.void
commitEdit()
Commits the editor's changes and notifies ActionListeners.protected void
fireActionPerformed(String actionCommand)
Fires an ActionEvent with the given actionCommand to all listeners.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.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 ofJXDatePickerFormatter
.
Date
getLinkDay()
Returns the date shown in the LinkPanel.protected MessageFormat
getLinkFormat()
JPanel
getLinkPanel()
Return the panel that is used at the bottom of the popup.<T extends EventListener>
T[]getListeners(Class<T> listenerType)
JXMonthView
getMonthView()
Return theJXMonthView
used in the popup to select dates from.PopupMenuListener[]
getPopupMenuListeners()
Returns an array containing all PopupMenuListeners which are registered to this picker.TimeZone
getTimeZone()
Gets the time zone.DatePickerUI
getUI()
Returns the look and feel (L&F) object that renders this component.String
getUIClassID()
boolean
isEditable()
Returns the editable property.boolean
isEditValid()
Returns true if the current value being edited is valid.boolean
isLightWeightPopupEnabled()
Gets the value of thelightWeightPopupEnabled
property.void
removeActionListener(ActionListener l)
Removes an ActionListener.void
removePopupMenuListener(PopupMenuListener l)
Removes a PopupMenuListener.void
setComponentOrientation(ComponentOrientation orientation)
void
setDate(Date date)
Sets the date property.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(String... formats)
Replaces the currently installed formatter and factory used by the editor.void
setFormats(DateFormat... formats)
Replaces the currently installed formatter and factory used by the editor.void
setLightWeightPopupEnabled(boolean aFlag)
Sets thelightWeightPopupEnabled
property, which provides a hint as to whether or not a lightweightComponent
should be used to contain theJXDatePicker
, versus a heavyweightComponent
such as aPanel
or aWindow
.void
setLinkDay(Date linkDay)
Sets the date shown in the TodayPanel.void
setLinkDay(Date linkDay, String linkFormatString)
Set the date the link will use and the string defining a MessageFormat to format the link.protected void
setLinkFormat(MessageFormat _linkFormat)
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.protected void
updateTimeZone(TimeZone oldValue, TimeZone newValue)
Callback from monthView timezone changes.void
updateUI()
Resets the UI property with the 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, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, 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, 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, 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, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
uiClassID
public static final String uiClassID
UI Class ID- See Also:
- Constant Field Values
-
EDITOR
public static final String EDITOR
- See Also:
- Constant Field Values
-
MONTH_VIEW
public static final String MONTH_VIEW
- See Also:
- Constant Field Values
-
LINK_PANEL
public static final String LINK_PANEL
- See Also:
- Constant Field Values
-
COMMIT_KEY
public static final String COMMIT_KEY
action command used for commit actionEvent.- See Also:
- Constant Field Values
-
CANCEL_KEY
public static final String CANCEL_KEY
action command used for cancel actionEvent.- See Also:
- Constant Field Values
-
HOME_NAVIGATE_KEY
public static final String HOME_NAVIGATE_KEY
action key for navigate home action- See Also:
- Constant Field Values
-
HOME_COMMIT_KEY
public static final String HOME_COMMIT_KEY
action key for commit home action- See Also:
- Constant Field Values
-
lightWeightPopupEnabled
protected boolean lightWeightPopupEnabled
-
-
Constructor Detail
-
JXDatePicker
public JXDatePicker()
Intantiates a date picker with no selection and the defaultDatePickerFormatter
. The date picker is configured with the default time zone and locale- See Also:
setTimeZone(java.util.TimeZone)
,getTimeZone()
-
JXDatePicker
public JXDatePicker(Date selected)
Intantiates a date picker using the specified time as the initial selection and the defaultDatePickerFormatter
. The date picker is configured with the default time zone and locale- Parameters:
selected
- the initially selected date- See Also:
setTimeZone(java.util.TimeZone)
,getTimeZone()
-
JXDatePicker
public JXDatePicker(Locale locale)
Intantiates a date picker with no selection and the defaultDatePickerFormatter
. The date picker is configured with the default time zone and specified locale- Parameters:
locale
- initial Locale- See Also:
setTimeZone(java.util.TimeZone)
,getTimeZone()
-
JXDatePicker
public JXDatePicker(Date selection, Locale locale)
Intantiates a date picker using the specified time as the initial selection and the defaultDatePickerFormatter
. The date picker is configured with the default time zone and specified locale- Parameters:
selection
- initially selected Datelocale
- initial Locale- See Also:
setTimeZone(java.util.TimeZone)
,getTimeZone()
-
-
Method Detail
-
setDate
public void setDate(Date date)
Sets the date property.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 is controlled by the JXMonthView's DateSelectionModel. The default implementation normalizes the date to the start of the day in the model's calendar's coordinates, that is all time fields are zeroed. To keep the time fields, configure the monthView with a SingleDaySelectionModel.
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 enforced by the DatePickerUI.
This is a bound property.
- Parameters:
date
- the new date to set.- See Also:
getDate()
,DateSelectionModel
,SingleDaySelectionModel
-
getDate
public Date getDate()
Returns the currently selected date.- Returns:
- Date
-
updateTimeZone
protected void updateTimeZone(TimeZone oldValue, TimeZone newValue)
Callback from monthView timezone changes.NOTE: as timeZone is a bound property of this class we need to guarantee the propertyChangeNotification. As this class doesn't own this property it must listen to the owner (monthView) and re-fire the change.
- Parameters:
oldValue
- the old timezone.newValue
- the new timezone.
-
getUI
public DatePickerUI getUI()
Returns the look and feel (L&F) object that renders this component.- Overrides:
getUI
in classJComponent
- Returns:
- the DatePickerUI object that renders this component
-
setUI
public void setUI(DatePickerUI ui)
Sets the L&F object that renders this component.- Parameters:
ui
- UI to use for thisJXDatePicker
-
updateUI
public void updateUI()
Resets the UI property with the value from the current look and feel.- Overrides:
updateUI
in classJComponent
- See Also:
UIManager.getUI(javax.swing.JComponent)
-
getUIClassID
public String getUIClassID()
- Overrides:
getUIClassID
in classJComponent
-
setFormats
public void setFormats(String... formats)
Replaces the currently installed formatter and factory used by the editor. These string formats are defined by thejava.text.SimpleDateFormat
class.Note: The given formats are internally synched to the picker's current TimeZone.
- Parameters:
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.- Throws:
NullPointerException
- any array element is null.- See Also:
SimpleDateFormat
-
setFormats
public void setFormats(DateFormat... formats)
Replaces the currently installed formatter and factory used by the editor.Note: The given formats are internally synched to the picker's current TimeZone.
- Parameters:
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.- Throws:
NullPointerException
- any of its elements is null.
-
getFormats
public DateFormat[] getFormats()
Returns an array of the formats used by the installed formatter if it is a subclass ofJXDatePickerFormatter
.
javax.swing.JFormattedTextField.AbstractFormatter
andjavax.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.
-
getMonthView
public JXMonthView getMonthView()
Return theJXMonthView
used in the popup to select dates from.- Returns:
- the month view component
-
setMonthView
public void setMonthView(JXMonthView monthView)
Set the component to use the specified JXMonthView. If the new JXMonthView is configured to a different time zone it will affect the time zone of this component.- Parameters:
monthView
- month view comopnent.- Throws:
NullPointerException
- if view component is null- See Also:
setTimeZone(java.util.TimeZone)
,getTimeZone()
-
getTimeZone
public TimeZone getTimeZone()
Gets the time zone. This is a convenience method which returns the time zone of the JXMonthView being used.- Returns:
- The
TimeZone
used by theJXMonthView
.
-
setTimeZone
public void setTimeZone(TimeZone tz)
Sets the time zone with the given time zone value. This is a convenience method which returns the time zone of the JXMonthView being used.PENDING JW: currently this property is the only property of the monthView which is exposed in this api. Not sure why it is here at all. It's asymetric (to the other properties) and as such should be either removed or the others which might be relevant to a datePicker exposed as well (probably hiding the monthView itself as an implementation detail of the ui delegate).
- Parameters:
tz
- TheTimeZone
.
-
getLinkDay
public Date getLinkDay()
Returns the date shown in the LinkPanel.PENDING JW: the property should be named linkDate - but that's held by the deprecated long returning method. Maybe revisit if we actually remove the other.
- Returns:
- the date shown in the LinkPanel.
-
setLinkDay
public void setLinkDay(Date linkDay, String linkFormatString)
Set the date the link will use and the string defining a MessageFormat to format the link. If no valid date is in the editor when the popup is displayed the popup will focus on the month the linkDate is in. Calling this method will replace the currently installed linkPanel and install a new one with the requested date and format.- Parameters:
linkDay
- the Date to set on the LinkPanellinkFormatString
- String used to format the link- See Also:
MessageFormat
-
setLinkDay
public void setLinkDay(Date linkDay)
Sets the date shown in the TodayPanel. PENDING JW ... quick api hack for testing. Don't recreate the panel if it had been used- Parameters:
linkDay
- the date used in the TodayPanel
-
setLinkFormat
protected void setLinkFormat(MessageFormat _linkFormat)
- Parameters:
_linkFormat
- the _linkFormat to set
-
getLinkFormat
protected MessageFormat getLinkFormat()
- Returns:
- the _linkFormat
-
getLinkPanel
public JPanel getLinkPanel()
Return the panel that is used at the bottom of the popup. The default implementation shows a link that displays the current month.- Returns:
- The currently installed link panel
-
setLinkPanel
public void setLinkPanel(JPanel linkPanel)
Set the panel that will be used at the bottom of the popup. PENDING JW: why insist on JPanel? JComponent would be enough?- Parameters:
linkPanel
- The new panel to install in the popup
-
getEditor
public JFormattedTextField getEditor()
Returns the formatted text field used to edit the date selection.Clients should NOT use this method. It is provided to temporarily support the PLAF code.
- Returns:
- the formatted text field
-
setEditor
public void setEditor(JFormattedTextField editor)
Sets the editor. The editor's editable and enabled properties are set the corresponding properties of the JXDatePicker.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.
- Parameters:
editor
- the formatted input.- Throws:
NullPointerException
- if editor is null.- See Also:
getEditor()
-
setComponentOrientation
public void setComponentOrientation(ComponentOrientation orientation)
- Overrides:
setComponentOrientation
in classComponent
-
isEditValid
public boolean isEditValid()
Returns true if the current value being edited is valid.- Returns:
- true if the current value being edited is valid.
-
commitEdit
public void commitEdit() throws ParseException
Commits the editor's changes and notifies ActionListeners. Forces the current value to be taken from the AbstractFormatter and set as the current value. This has no effect if there is no current AbstractFormatter installed.- Throws:
ParseException
- Throws parse exception if the date can not be parsed.
-
cancelEdit
public void cancelEdit()
Cancels the editor's changes and notifies ActionListeners.
-
setEditable
public void setEditable(boolean value)
Sets the editable property. If false, ...? The default value is true.- Parameters:
value
-- See Also:
isEditable()
-
isEditable
public boolean isEditable()
Returns the editable property.- Returns:
true
if the picker is editable;false
otherwise
-
getFont
public Font getFont()
Returns the font that is associated with the editor of this date picker.- Specified by:
getFont
in interfaceMenuContainer
- Overrides:
getFont
in classComponent
-
setFont
public void setFont(Font font)
Set the font for the editor associated with this date picker.- Overrides:
setFont
in classJComponent
-
setLightWeightPopupEnabled
public void setLightWeightPopupEnabled(boolean aFlag)
Sets thelightWeightPopupEnabled
property, which provides a hint as to whether or not a lightweightComponent
should be used to contain theJXDatePicker
, versus a heavyweightComponent
such as aPanel
or aWindow
. The decision of lightweight versus heavyweight is ultimately up to theJXDatePicker
. 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 thelightWeightPopupEnabled
property istrue
, 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.- Parameters:
aFlag
- iftrue
, lightweight popups are desired
-
isLightWeightPopupEnabled
public boolean isLightWeightPopupEnabled()
Gets the value of thelightWeightPopupEnabled
property.- Returns:
- the value of the
lightWeightPopupEnabled
property - See Also:
setLightWeightPopupEnabled(boolean)
-
getBaseline
public 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. The baseline is measured from the top of the component.- Overrides:
getBaseline
in classJComponent
- Parameters:
width
- Width of the component to determine baseline for.height
- Height of the component to determine baseline for.- Returns:
- baseline for the specified component
-
addActionListener
public void addActionListener(ActionListener l)
Adds an ActionListener. The ActionListener will receive an ActionEvent when a selection has been made.- Parameters:
l
- The ActionListener that is to be notified
-
removeActionListener
public void removeActionListener(ActionListener l)
Removes an ActionListener.- Parameters:
l
- The action listener to remove.
-
getListeners
public <T extends EventListener> T[] getListeners(Class<T> listenerType)
- Overrides:
getListeners
in classJComponent
-
fireActionPerformed
protected void fireActionPerformed(String actionCommand)
Fires an ActionEvent with the given actionCommand to all listeners.
-
addPopupMenuListener
public void addPopupMenuListener(PopupMenuListener l)
Adds a PopupMenuListener.PENDING JW: the canceled method is never called due to internal interference in BasicDatePickerUI. Probably need to re-visit that.
- Parameters:
l
- the PopupMenuListener to add.
-
removePopupMenuListener
public void removePopupMenuListener(PopupMenuListener l)
Removes a PopupMenuListener.- Parameters:
l
- the PopupMenuListener to remove.
-
getPopupMenuListeners
public PopupMenuListener[] getPopupMenuListeners()
Returns an array containing all PopupMenuListeners which are registered to this picker.- Returns:
- an array containing all PopupMenuListeners which are registered to this picker, guaranteed to be never null.
-
-