|
||||||||||
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.JXMonthView
public class JXMonthView
Component that displays a month calendar which can be used to select a day
or range of days. By default the JXMonthView
will display a
single calendar using the current month and year, using
Calendar.SUNDAY
as the first day of the week.
The JXMonthView
can be configured to display more than one
calendar at a time by calling
setPreferredCalCols
/setPreferredCalRows
. These
methods will set the preferred number of calendars to use in each
column/row. As these values change, the Dimension
returned
from getMinimumSize
and getPreferredSize
will
be updated. The following example shows how to create a 2x2 view which is
contained within a JFrame
:
JXMonthView monthView = new JXMonthView(); monthView.setPreferredCols(2); monthView.setPreferredRows(2); JFrame frame = new JFrame(); frame.getContentPane().add(monthView); frame.pack(); frame.setVisible(true);
JXMonthView
can be further configured to allow any day of the
week to be considered the first day of the week. Character
representation of those days may also be set by providing an array of
strings.
monthView.setFirstDayOfWeek(Calendar.MONDAY); monthView.setDaysOfTheWeek( new String[]{"S", "M", "T", "W", "Th", "F", "S"});
This component supports flagging days. These flagged days are displayed in a bold font. This can be used to inform the user of such things as scheduled appointment.
// Create some dates that we want to flag as being important.
Calendar cal1 = Calendar.getInstance();
cal1.set(2004, 1, 1);
Calendar cal2 = Calendar.getInstance();
cal2.set(2004, 1, 5);
monthView.setFlaggedDates(cal1.getTime(), cal2.getTime(), new Date());
Applications may have the need to allow users to select different ranges of
dates. There are three modes of selection that are supported, single, single interval
and multiple interval selection. Once a selection is made an DateSelectionEvent is
fired to inform listeners of the change.
// Change the selection mode to select full weeks. monthView.setSelectionMode(SelectionMode.SINGLE_INTERVAL_SELECTION); // Register a date selection listener to get notified about // any changes in the date selection model. monthView.getSelectionModel().addDateSelectionListener(new DateSelectionListener { public void valueChanged(DateSelectionEvent e) { System.out.println(e.getSelection()); } });NOTE (for users of earlier versions): as of version 1.19 control about selection dates is moved completely into the model. The default model used is of type DaySelectionModel, which handles dates in the same way the JXMonthView did earlier (that is, normalize all to the start of the day, which means zeroing all time fields).
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected java.awt.Insets |
_monthStringInsets
|
static java.lang.String |
BOX_PADDING_X
|
static java.lang.String |
BOX_PADDING_Y
|
static java.lang.String |
CANCEL_KEY
action command used for cancel actionEvent. |
static java.lang.String |
COMMIT_KEY
action command used for commit actionEvent. |
static int |
DAYS_IN_WEEK
|
static java.lang.String |
DAYS_OF_THE_WEEK
|
static java.lang.String |
FLAGGED_DATES
|
protected java.util.Date |
modifiedEndDate
|
protected java.util.Date |
modifiedStartDate
|
static int |
MONTHS_IN_YEAR
|
static java.lang.String |
SELECTION_MODEL
|
static java.lang.String |
TRAVERSABLE
|
static java.lang.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 | |
---|---|
JXMonthView()
Create a new instance of the JXMonthView class using the
default Locale and the current system time as the first date to
display. |
|
JXMonthView(java.util.Date firstDisplayedDate)
Create a new instance of the JXMonthView class using the
default Locale and the given time as the first date to
display. |
|
JXMonthView(java.util.Date firstDisplayedDate,
DateSelectionModel model)
Create a new instance of the JXMonthView class using the
default Locale, the given time as the first date to
display and the given selection model. |
|
JXMonthView(java.util.Date firstDisplayedDay,
DateSelectionModel model,
java.util.Locale locale)
Create a new instance of the JXMonthView class using the
given Locale, the given time as the first date to
display and the given selection model. |
|
JXMonthView(java.util.Locale locale)
Create a new instance of the JXMonthView class using the
default Locale and the current system time as the first date to
display. |
Method Summary | ||
---|---|---|
void |
addActionListener(java.awt.event.ActionListener l)
Adds an ActionListener. |
|
void |
addFlaggedDates(java.util.Date... flagged)
Adds the dates to the flags. |
|
void |
addNotify()
|
|
void |
addSelectionInterval(java.util.Date startDate,
java.util.Date endDate)
Adds the selection interval to the selection model. |
|
void |
cancelSelection()
Cancels the selection. |
|
protected void |
cleanupWeekSelectionDates(java.util.Date startDate,
java.util.Date endDate)
Deprecated. - this is kept as a reminder only, don't use! |
|
void |
clearFlaggedDates()
Clears all flagged dates. |
|
void |
clearSelection()
Clear any selection from the selection model |
|
void |
commitSelection()
Commits the current selection. |
|
void |
ensureDateVisible(java.util.Date date)
Moves the date into the visible region of the calendar. |
|
protected void |
fireActionPerformed(java.lang.String actionCommand)
Creates and fires an ActionEvent with the given action command to all listeners. |
|
protected java.util.Date |
getAnchorDate()
Returns the anchor date. |
|
int |
getBoxPaddingX()
Returns the padding used between days in the calendar. |
|
int |
getBoxPaddingY()
Returns the padding used above and below days in the calendar. |
|
java.util.Calendar |
getCalendar()
Returns a clone of the internal calendar, with it's time set to firstDisplayedDate. |
|
java.util.Date |
getDayAtLocation(int x,
int y)
Returns the Date at the given location. |
|
java.awt.Color |
getDayForeground(int dayOfWeek)
Return the color that should be used for painting the numerical day of the week. |
|
java.lang.String[] |
getDaysOfTheWeek()
Returns the String representation for each day of the week. |
|
java.awt.Color |
getDaysOfTheWeekForeground()
|
|
int |
getFirstDayOfWeek()
Gets what the first day of the week is; e.g., Calendar.SUNDAY in the U.S., Calendar.MONDAY
in France. |
|
java.util.Date |
getFirstDisplayedDay()
Returns the first displayed date. |
|
java.util.Date |
getFirstSelectionDate()
Returns the earliest selected date. |
|
java.util.SortedSet<java.util.Date> |
getFlaggedDates()
Returns a sorted set of flagged Dates. |
|
java.awt.Color |
getFlaggedDayForeground()
Return the color that should be used for painting the foreground of the flagged day. |
|
java.util.Date |
getLastDisplayedDay()
Returns the last date able to be displayed. |
|
java.util.Date |
getLastSelectionDate()
Returns the earliest selected date. |
|
|
getListeners(java.lang.Class<T> listenerType)
|
|
java.util.Date |
getLowerBound()
Return the lower bound date that is allowed to be selected for this model. |
|
java.awt.Color |
getMonthStringBackground()
Returns the color used to paint the month string background. |
|
java.awt.Color |
getMonthStringForeground()
Returns the color used to paint the month string foreground. |
|
java.awt.Insets |
getMonthStringInsets()
Returns a copy of the insets used to paint the month string background. |
|
int |
getPreferredCols()
Returns the preferred number of columns to paint calendars in. |
|
int |
getPreferredRows()
Returns the preferred number of rows to paint calendars in. |
|
java.awt.Color |
getSelectedBackground()
Returns the selected background color. |
|
java.util.SortedSet<java.util.Date> |
getSelection()
Get the current selection |
|
java.util.Date |
getSelectionDate()
Returns the earliest selected date. |
|
DateSelectionModel.SelectionMode |
getSelectionMode()
Returns the current selection mode for this JXMonthView. |
|
DateSelectionModel |
getSelectionModel()
Returns the date selection model which drives this JXMonthView. |
|
java.util.TimeZone |
getTimeZone()
Gets the time zone. |
|
java.util.Date |
getToday()
Returns the start of today in this monthviews calendar coordinates. |
|
java.awt.Color |
getTodayBackground()
Returns the color used when painting the today background. |
|
MonthViewUI |
getUI()
|
|
java.lang.String |
getUIClassID()
|
|
java.util.Date |
getUpperBound()
Return the upper bound date that is allowed to be selected for this model. |
|
boolean |
hasFlaggedDates()
Returns a boolean indicating if this monthView has flagged dates. |
|
protected void |
incrementToday()
Increments today. |
|
boolean |
isAntialiased()
Returns true if anti-aliased text is enabled for this component, false otherwise. |
|
boolean |
isComponentInputMapEnabled()
Returns the componentInputMapEnabled property. |
|
boolean |
isFlaggedDate(java.util.Date date)
Identifies whether or not the date passed is a flagged date. |
|
boolean |
isSelected(java.util.Date date)
Returns true if the specified date falls within the _startSelectedDate and _endSelectedDate range. |
|
boolean |
isSelectionEmpty()
Return true if the selection is empty, false otherwise |
|
boolean |
isShowingLeadingDays()
Whether or not we're showing leading dates. |
|
boolean |
isShowingTrailingDays()
Whether or not we're showing trailing dates. |
|
boolean |
isShowingWeekNumber()
Returns whether or not this JXMonthView should display
week number. |
|
boolean |
isTraversable()
Returns whether or not the month view supports traversing months. |
|
boolean |
isUnselectableDate(java.util.Date date)
Identifies whether or not the date passed is an unselectable date. |
|
void |
removeActionListener(java.awt.event.ActionListener l)
Removes an ActionListener. |
|
void |
removeFlaggedDates(java.util.Date... flagged)
Unflags the given dates. |
|
void |
removeNotify()
|
|
void |
removeSelectionInterval(java.util.Date startDate,
java.util.Date endDate)
Removes the selection interval from the selection model. |
|
void |
setAntialiased(boolean antiAlias)
Turns on/off anti-aliased text for this component. |
|
void |
setBounds(java.awt.Rectangle r)
Moves and resizes this component to conform to the new bounding rectangle r. |
|
void |
setBoxPaddingX(int boxPaddingX)
Sets the number of pixels used to pad the left and right side of a day. |
|
void |
setBoxPaddingY(int boxPaddingY)
Sets the number of pixels used to pad the top and bottom of a day. |
|
void |
setComponentInputMapEnabled(boolean enabled)
Sets the component input map enablement property. |
|
void |
setDayForeground(int dayOfWeek,
java.awt.Color c)
Set the color to be used for painting the specified day of the week. |
|
void |
setDaysOfTheWeek(java.lang.String[] days)
Sets the String representation for each day of the week as used in the header of the day's grid. |
|
void |
setDaysOfTheWeekForeground(java.awt.Color c)
Sets the color used to draw the foreground of each day of the week. |
|
void |
setFirstDayOfWeek(int firstDayOfWeek)
Sets what the first day of the week is; e.g., Calendar.SUNDAY in US, Calendar.MONDAY
in France. |
|
void |
setFirstDisplayedDay(java.util.Date date)
Set the first displayed date. |
|
void |
setFlaggedDates(java.util.Date... flagged)
Replace all flags with the given dates. |
|
void |
setFlaggedDayForeground(java.awt.Color c)
Set the color to be used for painting the foreground of a flagged day. |
|
void |
setFont(java.awt.Font font)
Sets the font of this component. |
|
void |
setLocale(java.util.Locale locale)
Sets locale and resets text and format used to display months and days. |
|
void |
setLowerBound(java.util.Date lowerBound)
Set the lower bound date that is allowed to be selected. |
|
void |
setMonthStringBackground(java.awt.Color c)
Sets the color used to draw the background of the month string. |
|
void |
setMonthStringForeground(java.awt.Color c)
Sets the color used to draw the foreground of the month string. |
|
void |
setMonthStringInsets(java.awt.Insets insets)
Insets used to modify the width/height when painting the background of the month string area. |
|
void |
setPreferredCols(int cols)
The preferred number of columns to paint calendars. |
|
void |
setPreferredRows(int rows)
Sets the preferred number of rows to paint calendars. |
|
void |
setSelectedBackground(java.awt.Color c)
Sets the selected background color to c . |
|
void |
setSelectionDate(java.util.Date newDate)
Sets the model's selection to the given date or clears the selection if null. |
|
void |
setSelectionInterval(java.util.Date startDate,
java.util.Date endDate)
Sets the selection interval to the selection model. |
|
void |
setSelectionMode(DateSelectionModel.SelectionMode selectionMode)
Set the selection mode for this JXMonthView. |
|
void |
setSelectionModel(DateSelectionModel model)
Sets the date selection model to drive this monthView. |
|
void |
setShowingLeadingDays(boolean value)
Whether or not to show leading dates for a months displayed by this component. |
|
void |
setShowingTrailingDays(boolean value)
Whether or not to show trailing dates for the months displayed by this component. |
|
void |
setShowingWeekNumber(boolean showWeekNumber)
Set whether or not this JXMonthView will display week
numbers or not. |
|
void |
setTimeZone(java.util.TimeZone tz)
Sets the time zone with the given time zone value. |
|
protected void |
setToday(java.util.Date date)
Sets the date which represents today. |
|
void |
setTodayBackground(java.awt.Color c)
Sets the color used to draw the bounding box around today. |
|
void |
setTraversable(boolean traversable)
Set whether or not the month view will display buttons to allow the user to traverse to previous or next months. |
|
void |
setUI(MonthViewUI ui)
Sets the L&F object that renders this component. |
|
void |
setUnselectableDates(java.util.Date... unselectableDates)
Sets the dates that should be unselectable. |
|
void |
setUpperBound(java.util.Date upperBound)
Set the upper bound date that is allowed to be selected. |
|
protected void |
updateDatesAfterTimeZoneChange(java.util.TimeZone oldTimeZone)
All dates are "cleaned" relative to the timezone they had been set. |
|
protected void |
updateTodayFromCurrentTime()
Sets today from the current system time. |
|
void |
updateUI()
Resets the UI property with the value from the current look and feel. |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String COMMIT_KEY
public static final java.lang.String CANCEL_KEY
public static final java.lang.String BOX_PADDING_X
public static final java.lang.String BOX_PADDING_Y
public static final java.lang.String DAYS_OF_THE_WEEK
public static final java.lang.String SELECTION_MODEL
public static final java.lang.String TRAVERSABLE
public static final java.lang.String FLAGGED_DATES
public static final java.lang.String uiClassID
public static final int DAYS_IN_WEEK
public static final int MONTHS_IN_YEAR
protected java.util.Date modifiedStartDate
protected java.util.Date modifiedEndDate
protected java.awt.Insets _monthStringInsets
Constructor Detail |
---|
public JXMonthView()
JXMonthView
class using the
default Locale and the current system time as the first date to
display.
public JXMonthView(java.util.Locale locale)
JXMonthView
class using the
default Locale and the current system time as the first date to
display.
locale
- desired locale, if null the system default locale is usedpublic JXMonthView(java.util.Date firstDisplayedDate)
JXMonthView
class using the
default Locale and the given time as the first date to
display.
firstDisplayedDate
- The first month to display.public JXMonthView(java.util.Date firstDisplayedDate, DateSelectionModel model)
JXMonthView
class using the
default Locale, the given time as the first date to
display and the given selection model.
firstDisplayedDate
- The first month to display.model
- the selection model to use, if null a DefaultSelectionModel
is
created.public JXMonthView(java.util.Date firstDisplayedDay, DateSelectionModel model, java.util.Locale locale)
JXMonthView
class using the
given Locale, the given time as the first date to
display and the given selection model.
firstDisplayedDay
- model
- the selection model to use, if null a DefaultSelectionModel
is
created.locale
- desired locale, if null the system default locale is usedMethod Detail |
---|
public void setLocale(java.util.Locale locale)
PENDING JW: the following warning should be obsolete (installCalendar should take care) - check if it really is!
Warning: Since this resets any string labels that are cached in UI
(month and day names) and firstDayofWeek, use setDaysOfTheWeek
and/or
setFirstDayOfWeek after (re)setting locale.
setLocale
in class java.awt.Component
locale
- new Locale to be used for formattingsetDaysOfTheWeek(String[])
,
setFirstDayOfWeek(int)
public java.util.Calendar getCalendar()
java.lang.IllegalStateException
- if called before instantitation is completedpublic java.util.TimeZone getTimeZone()
TimeZone
used by the JXMonthView
.public void setTimeZone(java.util.TimeZone tz)
tz
- The TimeZone
.public int getFirstDayOfWeek()
Calendar.SUNDAY
in the U.S., Calendar.MONDAY
in France.
public void setFirstDayOfWeek(int firstDayOfWeek)
Calendar.SUNDAY
in US, Calendar.MONDAY
in France.
firstDayOfWeek
- The first day of the week.Calendar
protected java.util.Date getAnchorDate()
protected void updateDatesAfterTimeZoneChange(java.util.TimeZone oldTimeZone)
oldTimeZone
- the timezone before the changepublic java.util.Date getLastDisplayedDay()
public java.util.Date getFirstDisplayedDay()
public void setFirstDisplayedDay(java.util.Date date)
Calendar.DAY_OF_MONTH
field is reset to
1 and all other fields, with exception of the year and month,
are reset to 0.
date
- The first displayed date.public void ensureDateVisible(java.util.Date date)
date
into the visible region of the calendar. If
the date is greater than the last visible date it will become the last
visible date. While if it is less than the first visible date it will
become the first visible date. NOTE: this is the recommended method to scroll to a particular date, the functionally equivalent method taking a long as parameter will most probably be deprecated.
date
- Date to make visible, must not be null.#ensureDateVisible(long)
public java.util.Date getDayAtLocation(int x, int y)
x
- the x position of the location in pixely
- the y position of the location in pixel
protected void updateTodayFromCurrentTime()
protected void incrementToday()
protected void setToday(java.util.Date date)
date
- the date which should be used as today.public java.util.Date getToday()
public MonthViewUI getUI()
public void setUI(MonthViewUI ui)
ui
- UI to use for this JXMonthView
public void updateUI()
updateUI
in class javax.swing.JComponent
UIManager.getUI(JComponent)
public java.lang.String getUIClassID()
getUIClassID
in class javax.swing.JComponent
public DateSelectionModel getSelectionModel()
public void setSelectionModel(DateSelectionModel model)
model
- the selection model to use, must not be null.
java.lang.NullPointerException
- if model is nullpublic void clearSelection()
public boolean isSelectionEmpty()
public java.util.SortedSet<java.util.Date> getSelection()
public void addSelectionInterval(java.util.Date startDate, java.util.Date endDate)
startDate
- Start of date range to add to the selectionendDate
- End of date range to add to the selectionpublic void setSelectionInterval(java.util.Date startDate, java.util.Date endDate)
startDate
- Start of date range to set the selection toendDate
- End of date range to set the selection topublic void removeSelectionInterval(java.util.Date startDate, java.util.Date endDate)
startDate
- Start of the date range to remove from the selectionendDate
- End of the date range to remove from the selectionpublic DateSelectionModel.SelectionMode getSelectionMode()
public void setSelectionMode(DateSelectionModel.SelectionMode selectionMode)
selectionMode
- The selection mode to use for this JXMonthView
public java.util.Date getFirstSelectionDate()
public java.util.Date getLastSelectionDate()
public java.util.Date getSelectionDate()
public void setSelectionDate(java.util.Date newDate)
newDate
- the selection date to setpublic boolean isSelected(java.util.Date date)
date
- The date to check
public void setLowerBound(java.util.Date lowerBound)
lowerBound
- the lower bound, null means none.public void setUpperBound(java.util.Date upperBound)
upperBound
- the upper bound, null means none.public java.util.Date getLowerBound()
public java.util.Date getUpperBound()
public boolean isUnselectableDate(java.util.Date date)
date
- date which to test for unselectable status
public void setUnselectableDates(java.util.Date... unselectableDates)
NOTE: neither the given array nor any of its elements must be null.
unselectableDates
- zero or more not-null dates that should be
unselectable.
java.lang.NullPointerException
- if either the array or any of the elements
are nullpublic boolean isFlaggedDate(java.util.Date date)
date
- date which to test for flagged status
public void setFlaggedDates(java.util.Date... flagged)
NOTE: neither the given array nor any of its elements should be null. Currently, a null array will be tolerated to ease migration. A null has the same effect as clearFlaggedDates.
flagged
- the dates to be flaggedpublic void addFlaggedDates(java.util.Date... flagged)
flagged
- the dates to be flaggedpublic void removeFlaggedDates(java.util.Date... flagged)
flagged
- the dates to be unflaggedpublic void clearFlaggedDates()
public java.util.SortedSet<java.util.Date> getFlaggedDates()
public boolean hasFlaggedDates()
public void setShowingLeadingDays(boolean value)
value
- true if leading dates should be displayed, false otherwise.public boolean isShowingLeadingDays()
public void setShowingTrailingDays(boolean value)
value
- true if trailing dates should be displayed, false otherwise.public boolean isShowingTrailingDays()
public boolean isTraversable()
true
if month traversing is enabled.public void setTraversable(boolean traversable)
traversable
- set to true to enable month traversing, false
otherwise.public boolean isShowingWeekNumber()
JXMonthView
should display
week number.
true
if week numbers should be displayedpublic void setShowingWeekNumber(boolean showWeekNumber)
JXMonthView
will display week
numbers or not.
showWeekNumber
- true if week numbers should be displayed,
false otherwisepublic void setDaysOfTheWeek(java.lang.String[] days)
Calendar.SUNDAY
. If null, the representation provided
by the MonthViewUI is used.
The default value is the representation as
returned from the MonthViewUI.
days
- Array of characters that represents each day
java.lang.IllegalArgumentException
- if not null and days.length
!=
DAYS_IN_WEEKpublic java.lang.String[] getDaysOfTheWeek()
setDaysOfTheWeek(String[])
,
MonthViewUI
public boolean isAntialiased()
true
if anti-aliased text is enabled,
false
otherwise.public void setAntialiased(boolean antiAlias)
antiAlias
- true
for anti-aliased text,
false
to turn it off.public int getBoxPaddingX()
public void setBoxPaddingX(int boxPaddingX)
boxPaddingX
- Number of pixels applied to both sides of a daypublic int getBoxPaddingY()
public void setBoxPaddingY(int boxPaddingY)
boxPaddingY
- Number of pixels applied to top and bottom of a daypublic java.awt.Color getSelectedBackground()
public void setSelectedBackground(java.awt.Color c)
c
. The default color
is 138, 173, 209 (Blue-ish)
c
- Selected background.public java.awt.Color getTodayBackground()
public void setTodayBackground(java.awt.Color c)
JXMonthView
component.
c
- color to setpublic java.awt.Color getMonthStringBackground()
public void setMonthStringBackground(java.awt.Color c)
138, 173, 209 (Blue-ish)
.
c
- color to setpublic java.awt.Color getMonthStringForeground()
public void setMonthStringForeground(java.awt.Color c)
Color.WHITE
.
c
- color to setpublic void setDaysOfTheWeekForeground(java.awt.Color c)
c
- color to setpublic java.awt.Color getDaysOfTheWeekForeground()
public void setDayForeground(int dayOfWeek, java.awt.Color c)
dayOfWeek
- constant value defining the day of the week.c
- The color to be used for painting the numeric day of the week.public java.awt.Color getDayForeground(int dayOfWeek)
dayOfWeek
- The day of week to get the color for.
public void setFlaggedDayForeground(java.awt.Color c)
c
- The color to be used for painting.public java.awt.Color getFlaggedDayForeground()
public java.awt.Insets getMonthStringInsets()
public void setMonthStringInsets(java.awt.Insets insets)
insets
- Insetspublic int getPreferredCols()
PENDING JW: rename to a "full" name preferredColumnCount
public void setPreferredCols(int cols)
PENDING JW: rename to a "full" name preferredColumnCount and make bound property
cols
- The number of columns of calendars.public int getPreferredRows()
PENDING JW: rename to a "full" name preferredRowCount or maybe visibleRowCount to be consistent with JXTable/JXList
public void setPreferredRows(int rows)
PENDING JW: rename to a "full" name preferredRowCount and make bound property
rows
- The number of rows of calendars.public void setBounds(java.awt.Rectangle r)
PENDING JW: why ovrridden? super is identical
setBounds
in class java.awt.Component
r
- The new bounding rectangle for this componentpublic void setFont(java.awt.Font font)
setFont
in class javax.swing.JComponent
font
- The font to become this component's font; if this parameter
is null then this component will inherit the font of its parent.public void removeNotify()
removeNotify
in class javax.swing.JComponent
public void addNotify()
addNotify
in class javax.swing.JComponent
public void commitSelection()
Resets the model's adjusting property to false and fires an ActionEvent with the COMMIT_KEY action command.
PENDING: define what "commit selection" means ... currently only fires (to keep the picker happy).
cancelSelection()
,
DateSelectionModel.setAdjusting(boolean)
public void cancelSelection()
Resets the model's adjusting to false and fires an ActionEvent with the CANCEL_KEY action command.
commitSelection()
,
DateSelectionModel.setAdjusting(boolean)
public void setComponentInputMapEnabled(boolean enabled)
If enabled, the keybinding for WHEN_IN_FOCUSED_WINDOW are installed, otherwise not. Changing this property will install/clear the corresponding key bindings. Typically, clients which want to use the monthview in a popup, should enable these.
The default value is false.
enabled
- boolean to indicate whether the component
input map should be enabled.isComponentInputMapEnabled()
public boolean isComponentInputMapEnabled()
setComponentInputMapEnabled(boolean)
public void addActionListener(java.awt.event.ActionListener l)
l
- The ActionListener that is to be notifiedpublic void removeActionListener(java.awt.event.ActionListener l)
l
- The action listener to remove.public <T extends java.util.EventListener> T[] getListeners(java.lang.Class<T> listenerType)
getListeners
in class javax.swing.JComponent
protected void fireActionPerformed(java.lang.String actionCommand)
actionCommand
- the command for the created.@Deprecated protected void cleanupWeekSelectionDates(java.util.Date startDate, java.util.Date endDate)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |