Package org.jdesktop.swingx.plaf.basic
Class SpinningCalendarHeaderHandler
- java.lang.Object
-
- org.jdesktop.swingx.plaf.basic.CalendarHeaderHandler
-
- org.jdesktop.swingx.plaf.basic.SpinningCalendarHeaderHandler
-
public class SpinningCalendarHeaderHandler extends CalendarHeaderHandler
Custom CalendarHeaderHandler which supports year-wise navigation.The custom component used as header component of this implementation contains month-navigation buttons, a label with localized month text and a spinner for .. well ... spinning the years. There is minimal configuration control via the UIManager:
- control the position of the nextMonth button: the default is at the
trailing edge of the header. Option is to insert it directly after the month
text, to enable set a Boolean.TRUE as value for key
ARROWS_SURROUNDS_MONTH
. - control the focusability of the spinner's text field: the default is
false. To enable set a Boolean.TRUE as value for key
FOCUSABLE_SPINNER_TEXT
.
PENDING JW: implement and bind actions for keyboard navigation. These are potentially different from navigation by mouse: need to move the selection along with the scrolling?UIManager.put(CalendarHeaderHandler.uiControllerID, "org.jdesktop.swingx.plaf.basic.SpinningCalendarHeaderHandler");
- control the position of the nextMonth button: the default is at the
trailing edge of the header. Option is to insert it directly after the month
text, to enable set a Boolean.TRUE as value for key
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
SpinningCalendarHeaderHandler.SpinningCalendarHeader
The custom header component controlled and configured by this handler.private class
SpinningCalendarHeaderHandler.YearSpinnerModel
Thin-layer implementation of a SpinnerModel which is actually backed by this controller.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ARROWS_SURROUND_MONTH
Key for use in UIManager to control the position of the nextMonth arrow.static java.lang.String
FOCUSABLE_SPINNER_TEXT
Key for use in UIManager to control the focusable property of the year spinner.private static java.util.logging.Logger
LOG
private java.beans.PropertyChangeListener
monthPropertyListener
listener for property changes of the JXMonthView.private FormatStringValue
monthStringValue
converter for month text.private javax.swing.SpinnerModel
yearSpinnerModel
the spinner model for year-wise navigation.-
Fields inherited from class org.jdesktop.swingx.plaf.basic.CalendarHeaderHandler
monthDownImage, monthUpImage, monthView, uiControllerID
-
-
Constructor Summary
Constructors Constructor Description SpinningCalendarHeaderHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SpinningCalendarHeaderHandler.SpinningCalendarHeader
createCalendarHeader()
Creates and returns the component used as header in a zoomable monthView.protected void
firstDisplayedDayChanged()
Updates internal state to monthView's firstDisplayedDay.SpinningCalendarHeaderHandler.SpinningCalendarHeader
getHeaderComponent()
Returns a component to be used as header in a zoomable month view, guaranteed to be not null.private int
getNextYear()
Returns the next year of the monthView.private int
getPreviousYear()
Returns the previous year of the monthView.private java.beans.PropertyChangeListener
getPropertyChangeListener()
Returns the property change listener for use on the monthView.private int
getYear()
Returns the current year of the monthView.private javax.swing.SpinnerModel
getYearSpinnerModel()
void
install(JXMonthView monthView)
Installs this handler to the given month view.protected void
installListeners()
Creates and registered listeners on the monthView as appropriate.protected void
localeChanged()
Updates internal state to monthView's locale.private boolean
setYear(java.lang.Object value)
Sets the current year of the monthView to the given value.void
uninstall(JXMonthView monthView)
Uninstalls this handler from the given target month view.protected void
uninstallListeners()
Unregisters listeners which had been installed to the monthView.protected void
updateFormatters()
Updates the formatter of the month text to the JXMonthView's Locale.-
Methods inherited from class org.jdesktop.swingx.plaf.basic.CalendarHeaderHandler
componentOrientationChanged, createDerivedFont, fontChanged, installNavigationActions, monthStringBackgroundChanged
-
-
-
-
Field Detail
-
ARROWS_SURROUND_MONTH
public static final java.lang.String ARROWS_SURROUND_MONTH
Key for use in UIManager to control the position of the nextMonth arrow.- See Also:
- Constant Field Values
-
FOCUSABLE_SPINNER_TEXT
public static final java.lang.String FOCUSABLE_SPINNER_TEXT
Key for use in UIManager to control the focusable property of the year spinner.- See Also:
- Constant Field Values
-
LOG
private static final java.util.logging.Logger LOG
-
yearSpinnerModel
private javax.swing.SpinnerModel yearSpinnerModel
the spinner model for year-wise navigation.
-
monthPropertyListener
private java.beans.PropertyChangeListener monthPropertyListener
listener for property changes of the JXMonthView.
-
monthStringValue
private FormatStringValue monthStringValue
converter for month text.
-
-
Method Detail
-
install
public void install(JXMonthView monthView)
Installs this handler to the given month view.Overridden to configure header specifics component after calling super.
- Overrides:
install
in classCalendarHeaderHandler
- Parameters:
monthView
- the target month view to install to.
-
uninstall
public void uninstall(JXMonthView monthView)
Uninstalls this handler from the given target month view.Overridden to cleanup the specifics before calling super.
- Overrides:
uninstall
in classCalendarHeaderHandler
- Parameters:
monthView
- the target month view to install from.
-
getHeaderComponent
public SpinningCalendarHeaderHandler.SpinningCalendarHeader getHeaderComponent()
Returns a component to be used as header in a zoomable month view, guaranteed to be not null.Convenience override to the type created.
- Overrides:
getHeaderComponent
in classCalendarHeaderHandler
- Returns:
- a component to be used as header in a zoomable JXMonthView
-
createCalendarHeader
protected SpinningCalendarHeaderHandler.SpinningCalendarHeader createCalendarHeader()
Creates and returns the component used as header in a zoomable monthView.Implemented to create and configure the custom header component.
- Specified by:
createCalendarHeader
in classCalendarHeaderHandler
- Returns:
- the component used as header in a zoomable monthView, guaranteed to be not null.
-
installListeners
protected void installListeners()
Creates and registered listeners on the monthView as appropriate. This implementation registers a PropertyChangeListener which synchronizes internal state on changes of componentOrientation, font and monthStringBackground.- Overrides:
installListeners
in classCalendarHeaderHandler
-
uninstallListeners
protected void uninstallListeners()
Unregisters listeners which had been installed to the monthView.- Overrides:
uninstallListeners
in classCalendarHeaderHandler
-
updateFormatters
protected void updateFormatters()
Updates the formatter of the month text to the JXMonthView's Locale.
-
firstDisplayedDayChanged
protected void firstDisplayedDayChanged()
Updates internal state to monthView's firstDisplayedDay.
-
localeChanged
protected void localeChanged()
Updates internal state to monthView's locale.
-
getPropertyChangeListener
private java.beans.PropertyChangeListener getPropertyChangeListener()
Returns the property change listener for use on the monthView. This is lazyly created if not yet done. This implementation listens to changes of firstDisplayedDay and locale property and updates internal state accordingly.- Returns:
- the property change listener for the monthView, never null.
-
getYear
private int getYear()
Returns the current year of the monthView. Callback for spinner model. return the current year of the monthView.
-
getPreviousYear
private int getPreviousYear()
Returns the previous year of the monthView. Callback for spinner model.PENDING JW: check against lower bound. return the previous year of the monthView.
-
getNextYear
private int getNextYear()
Returns the next year of the monthView. Callback for spinner model.PENDING JW: check against upper bound. return the next year of the monthView.
-
setYear
private boolean setYear(java.lang.Object value)
Sets the current year of the monthView to the given value. Callback for spinner model.- Parameters:
value
- the new value of the year.- Returns:
- a boolean indicating if a change actually happened.
-
getYearSpinnerModel
private javax.swing.SpinnerModel getYearSpinnerModel()
-
-