|
|||||||||
| Home >> All >> com >> theotherbell >> [ ui overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.theotherbell.ui
Class DatePicker

java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.theotherbell.ui.DatePicker
- All Implemented Interfaces:
- javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
- public final class DatePicker
- extends javax.swing.JPanel
GUI component that allows the user to choose a date from a calendar. Usage is illustrated in the sample code below:
JDialog dlg = new JDialog(new Frame(), true); DatePicker dp = new DatePicker(); dp.setHideOnSelect(false); dlg.getContentPane().add(dp); dlg.pack(); dlg.show(); System.out.println(dp.getDate().toString()); dlg.dispose(); System.exit(0);
- Version:
- 1.1a
| Nested Class Summary |
| Nested classes inherited from class javax.swing.JPanel |
javax.swing.JPanel.AccessibleJPanel |
| Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
private javax.swing.JButton |
backButton
When clicked, displays the previous month. |
private javax.swing.JButton |
cancelButton
When clicked, hides the calendar and sets the selected date to "empty". |
private javax.swing.JTextField[] |
dayHeadings
Column headings for the days of the week. |
private javax.swing.JTextField[][] |
daysInMonth
2-dimensional array for 6 weeks of 7 days each. |
private javax.swing.JButton |
forwardButton
When clicked, displays the next month. |
private static java.awt.Color |
gray
Disabled color. |
private boolean |
hideOnSelect
When true, the panel will be hidden as soon as a day is selected by clicking the day or clicking the Today button. |
private static java.awt.Color |
highlight
Highlighted color. |
private static java.awt.Insets |
insets
Insets for day components and small buttons. |
private static java.awt.Font |
largeFont
Large font. |
private javax.swing.JLabel |
monthAndYear
Displays the currently selected month and year. |
private java.util.GregorianCalendar |
originalDate
Tracks the original date set when the component was created. |
private java.util.GregorianCalendar |
selectedDate
Currently selected date. |
private java.awt.Component |
selectedDay
Most recently selected day component. |
private static java.awt.Font |
smallFont
Small font. |
private static int |
startX
X coordinate for upper left corner of week 1 day 1. |
private static int |
startY
Y coordinate for upper left corner of week 1 day 1. |
private javax.swing.JButton |
todayButton
When clicked, sets the selected day to the current date. |
private static java.awt.Color |
white
Enabled color. |
| 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.Container |
|
| 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 | |
DatePicker()
Default constructor that sets the currently selected date to the current date. |
|
DatePicker(java.util.Date initialDate)
Alternate constructor that sets the currently selected date to the specified date if non-null. |
|
| Method Summary | |
private void |
calculateCalendar()
Calculates the days of the month. |
private static int |
calculateDaysInMonth(java.util.Calendar c)
Calculates the number of days in the specified month. |
private static java.lang.String |
formatDateText(java.util.Date dt)
Returns a short string representation of the specified date (January, 2001). |
java.util.Date |
getDate()
Returns the currently selected date. |
private static java.util.GregorianCalendar |
getToday()
Returns the current date. |
private void |
init()
Initializes the panel components according to the current value of selectedDate. |
private void |
initButtons(boolean firstTime)
Initializes Today and Cancel buttons dependent on whether hideOnSelect is set; if the panel will stay open, the Cancel button is invisible. |
boolean |
isHideOnSelect()
Returns true if the panel will be made invisible after a day is selected. |
private void |
onBackClicked(java.awt.event.ActionEvent evt)
Event handler for the back button that decrements the currently selected month. |
private void |
onCancel(java.awt.event.ActionEvent evt)
Event handler for the Cancel button that unsets the currently selected date. |
private void |
onDayClicked(java.awt.event.MouseEvent evt)
Event handler that sets the currently selected date to the clicked day. |
private void |
onForwardClicked(java.awt.event.ActionEvent evt)
Event handler for the forward button that increments the currently selected month. |
private void |
onToday(java.awt.event.ActionEvent evt)
Event handler for the Today button that sets the currently selected date to the current date. |
void |
setHideOnSelect(boolean hideOnSelect)
Controls whether the panel will be made invisible after a day is selected. |
| Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
startX
private static final int startX
- X coordinate for upper left corner of week 1 day 1.
- See Also:
- Constant Field Values
startY
private static final int startY
- Y coordinate for upper left corner of week 1 day 1.
- See Also:
- Constant Field Values
smallFont
private static final java.awt.Font smallFont
- Small font.
largeFont
private static final java.awt.Font largeFont
- Large font.
insets
private static final java.awt.Insets insets
- Insets for day components and small buttons.
highlight
private static final java.awt.Color highlight
- Highlighted color.
white
private static final java.awt.Color white
- Enabled color.
gray
private static final java.awt.Color gray
- Disabled color.
selectedDay
private java.awt.Component selectedDay
- Most recently selected day component.
selectedDate
private java.util.GregorianCalendar selectedDate
- Currently selected date.
originalDate
private java.util.GregorianCalendar originalDate
- Tracks the original date set when the component was created.
hideOnSelect
private boolean hideOnSelect
- When true, the panel will be hidden as soon as a day is
selected by clicking the day or clicking the Today button.
backButton
private final javax.swing.JButton backButton
- When clicked, displays the previous month.
monthAndYear
private final javax.swing.JLabel monthAndYear
- Displays the currently selected month and year.
forwardButton
private final javax.swing.JButton forwardButton
- When clicked, displays the next month.
dayHeadings
private final javax.swing.JTextField[] dayHeadings
- Column headings for the days of the week.
daysInMonth
private final javax.swing.JTextField[][] daysInMonth
- 2-dimensional array for 6 weeks of 7 days each.
todayButton
private final javax.swing.JButton todayButton
- When clicked, sets the selected day to the current date.
cancelButton
private final javax.swing.JButton cancelButton
- When clicked, hides the calendar and sets the selected date to "empty".
| Constructor Detail |
DatePicker
public DatePicker()
- Default constructor that sets the currently selected date to the
current date.
DatePicker
public DatePicker(java.util.Date initialDate)
- Alternate constructor that sets the currently selected date to the
specified date if non-null.
| Method Detail |
isHideOnSelect
public boolean isHideOnSelect()
- Returns true if the panel will be made invisible after a day is
selected.
setHideOnSelect
public void setHideOnSelect(boolean hideOnSelect)
- Controls whether the panel will be made invisible after a day is
selected.
getDate
public java.util.Date getDate()
- Returns the currently selected date.
init
private void init()
- Initializes the panel components according to the current value
of selectedDate.
initButtons
private void initButtons(boolean firstTime)
- Initializes Today and Cancel buttons dependent on whether hideOnSelect
is set; if the panel will stay open, the Cancel button is invisible.
onToday
private void onToday(java.awt.event.ActionEvent evt)
- Event handler for the Today button that sets the currently selected
date to the current date.
onCancel
private void onCancel(java.awt.event.ActionEvent evt)
- Event handler for the Cancel button that unsets the currently selected date.
onForwardClicked
private void onForwardClicked(java.awt.event.ActionEvent evt)
- Event handler for the forward button that increments the currently
selected month.
onBackClicked
private void onBackClicked(java.awt.event.ActionEvent evt)
- Event handler for the back button that decrements the currently selected
month.
onDayClicked
private void onDayClicked(java.awt.event.MouseEvent evt)
- Event handler that sets the currently selected date to the clicked day.
getToday
private static java.util.GregorianCalendar getToday()
- Returns the current date.
calculateCalendar
private void calculateCalendar()
- Calculates the days of the month.
calculateDaysInMonth
private static int calculateDaysInMonth(java.util.Calendar c)
- Calculates the number of days in the specified month.
formatDateText
private static java.lang.String formatDateText(java.util.Date dt)
- Returns a short string representation of the specified date (January, 2001).
|
|||||||||
| Home >> All >> com >> theotherbell >> [ ui overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC