|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
org.bibalex.daf.commongui.controls.DateChooser
public class DateChooser
Custom dialog box to enter dates. The DateChooser
class presents a calendar and allows the user to visually select a
day, month and year so that it is impossible to enter an invalid
date.
| Nested Class Summary | |
|---|---|
private static class |
DateChooser.FocusablePanel
Custom panel that can receive the focus. |
| Nested classes/interfaces inherited from class javax.swing.JDialog |
|---|
javax.swing.JDialog.AccessibleJDialog |
| Nested classes/interfaces inherited from class java.awt.Dialog |
|---|
java.awt.Dialog.AccessibleAWTDialog |
| Nested classes/interfaces inherited from class java.awt.Window |
|---|
java.awt.Window.AccessibleAWTWindow |
| 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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
private java.util.GregorianCalendar |
calendar
Auxiliary variable to compute dates. |
private javax.swing.JButton |
cancel
"Cancel" button. |
private javax.swing.JLabel |
day
Selected day. |
private javax.swing.JLabel[][] |
days
Calendar, as a matrix of labels. |
private static java.lang.String[] |
DAYS
Names of the days of the week. |
private static java.awt.Color |
DAYS_FOREGROUND
Text color of the days' numbers in the calendar. |
private DateChooser.FocusablePanel |
daysGrid
Day selection control. |
private static javax.swing.border.Border |
EMPTY_BORDER
Empty border, used when the calendar does not have the focus. |
private static int |
FIRST_YEAR
First year that can be selected. |
private static javax.swing.border.Border |
FOCUSED_BORDER
Border used to highlight the selected day when the calendar has the focus. |
private static int |
LAST_YEAR
Last year that can be selected. |
private int |
lastDay
Last day of the selected month. |
private javax.swing.JComboBox |
month
Month selection control. |
private static java.lang.String[] |
MONTHS
Names of the months. |
private int |
offset
Day of the week (0=Sunday) corresponding to the first day of the selected month. |
private javax.swing.JButton |
ok
"Ok" button. |
private boolean |
okClicked
true if the "Ok" button was clicked to close the
dialog box, false otherwise. |
private static java.awt.Color |
SELECTED_DAY_BACKGROUND
Text color of the selected day in the calendar. |
private static java.awt.Color |
SELECTED_DAY_FOREGROUND
Background color of the selected day in the calendar. |
private static java.awt.Color |
WEEK_DAYS_FOREGROUND
Text color of the days of the weeks, used as column headers in the calendar. |
private javax.swing.JComboBox |
year
Year selection control. |
| Fields inherited from class javax.swing.JDialog |
|---|
accessibleContext, rootPane, rootPaneCheckingEnabled |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface javax.swing.WindowConstants |
|---|
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
DateChooser(java.awt.Dialog owner)
Constructs a new DateChooser. |
|
DateChooser(java.awt.Dialog owner,
java.lang.String title)
Constructs a new DateChooser with the given title. |
|
DateChooser(java.awt.Frame owner)
Constructs a new DateChooser. |
|
DateChooser(java.awt.Frame owner,
java.lang.String title)
Constructs a new DateChooser with the given title. |
|
| Method Summary | |
|---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
Called when the "Ok" button is pressed. |
private void |
construct()
Initializes this DateChooser object. |
void |
focusGained(java.awt.event.FocusEvent e)
Called when the calendar gains the focus. |
void |
focusLost(java.awt.event.FocusEvent e)
Called when the calendar loses the focus. |
private int |
getSelectedDay()
Gets the selected day, as an int. |
void |
itemStateChanged(java.awt.event.ItemEvent e)
Called when a new month or year is selected. |
void |
keyPressed(java.awt.event.KeyEvent e)
Called when a key is pressed and the calendar has the focus. |
void |
keyReleased(java.awt.event.KeyEvent e)
(non-Javadoc) |
void |
keyTyped(java.awt.event.KeyEvent e)
(non-Javadoc) |
void |
mouseClicked(java.awt.event.MouseEvent e)
Called when the mouse is clicked on a day in the calendar. |
void |
mouseEntered(java.awt.event.MouseEvent e)
(non-Javadoc) |
void |
mouseExited(java.awt.event.MouseEvent e)
(non-Javadoc) |
void |
mousePressed(java.awt.event.MouseEvent e)
(non-Javadoc) |
void |
mouseReleased(java.awt.event.MouseEvent e)
(non-Javadoc) |
java.util.Date |
select()
Selects new date. |
java.util.Date |
select(java.util.Date date)
Selects a date. |
private void |
setSelected(int newDay)
Sets the selected day. |
private void |
setSelected(javax.swing.JLabel newDay)
Sets the selected day. |
private void |
update()
Updates the calendar. |
| Methods inherited from class javax.swing.JDialog |
|---|
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update |
| Methods inherited from class java.awt.Dialog |
|---|
addNotify, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show |
| Methods inherited from class java.awt.Window |
|---|
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, toBack, toFront |
| Methods inherited from class java.awt.Container |
|---|
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final java.lang.String[] MONTHS
private static final java.lang.String[] DAYS
private static final java.awt.Color WEEK_DAYS_FOREGROUND
private static final java.awt.Color DAYS_FOREGROUND
private static final java.awt.Color SELECTED_DAY_FOREGROUND
private static final java.awt.Color SELECTED_DAY_BACKGROUND
private static final javax.swing.border.Border EMPTY_BORDER
private static final javax.swing.border.Border FOCUSED_BORDER
private static final int FIRST_YEAR
private static final int LAST_YEAR
private java.util.GregorianCalendar calendar
private javax.swing.JLabel[][] days
private DateChooser.FocusablePanel daysGrid
DateChooser class.
private javax.swing.JComboBox month
private javax.swing.JComboBox year
private javax.swing.JButton ok
private javax.swing.JButton cancel
private int offset
days), corresponding to a given day.
private int lastDay
private javax.swing.JLabel day
private boolean okClicked
true if the "Ok" button was clicked to close the
dialog box, false otherwise.
| Constructor Detail |
|---|
public DateChooser(java.awt.Dialog owner,
java.lang.String title)
DateChooser with the given title.
owner - owner dialogtitle - dialog titlepublic DateChooser(java.awt.Dialog owner)
DateChooser.
owner - owner dialog
public DateChooser(java.awt.Frame owner,
java.lang.String title)
DateChooser with the given title.
owner - owner frametitle - dialog titlepublic DateChooser(java.awt.Frame owner)
DateChooser.
owner - owner frame| Method Detail |
|---|
private void construct()
DateChooser object. Creates the
controls, registers listeners and initializes the dialog box.
private int getSelectedDay()
int. Parses the text
of the selected label in the calendar to get the day.
private void setSelected(javax.swing.JLabel newDay)
newDay - day to selectprivate void setSelected(int newDay)
newDay - day to selectprivate void update()
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed in interface java.awt.event.ActionListenere - The ActionEvent that occured.public void focusGained(java.awt.event.FocusEvent e)
focusGained in interface java.awt.event.FocusListenere - The FocusEvent that occured.public void focusLost(java.awt.event.FocusEvent e)
focusLost in interface java.awt.event.FocusListenere - The FocusEvent that occured.public void itemStateChanged(java.awt.event.ItemEvent e)
itemStateChanged in interface java.awt.event.ItemListenere - The ItemEvent that occured.public void keyPressed(java.awt.event.KeyEvent e)
keyPressed in interface java.awt.event.KeyListenere - The KeyEvent that occured.public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked in interface java.awt.event.MouseListenere - The MouseEvent that occured.public void keyReleased(java.awt.event.KeyEvent e)
keyReleased in interface java.awt.event.KeyListenerKeyListener.keyReleased(java.awt.event.KeyEvent)public void keyTyped(java.awt.event.KeyEvent e)
keyTyped in interface java.awt.event.KeyListenerKeyListener.keyTyped(java.awt.event.KeyEvent)public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered in interface java.awt.event.MouseListenerMouseListener.mouseEntered(java.awt.event.MouseEvent)public void mouseExited(java.awt.event.MouseEvent e)
mouseExited in interface java.awt.event.MouseListenerMouseListener.mouseExited(java.awt.event.MouseEvent)public void mousePressed(java.awt.event.MouseEvent e)
mousePressed in interface java.awt.event.MouseListenerMouseListener.mousePressed(java.awt.event.MouseEvent)public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased in interface java.awt.event.MouseListenerMouseListener.mouseReleased(java.awt.event.MouseEvent)public java.util.Date select(java.util.Date date)
date - initial date
null if the user
press "Cancel" or closes the dialog boxpublic java.util.Date select()
select(Date) with the
system date as the parameter.
select(Date)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||