| ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Window | +--java.awt.Dialog | +--javax.swing.JDialog | +--com.gsoft.titration.client.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.
Inner Class Summary | |
private static class | DateChooser.FocusablePanel Custom panel that can receive the focus. |
Field Summary | |
private GregorianCalendar | calendar Auxiliary variable to compute dates. |
private JButton | cancel "Cancel" button. |
private JLabel | day Selected day. |
private final static String[] | DAYS Names of the days of the week. |
private JLabel[][] | days Calendar, as a matrix of labels. |
private final static Color | DAYS_FOREGROUND Text color of the days' numbers in the calendar. |
private FocusablePanel | daysGrid Day selection control. |
private final static Border | EMPTY_BORDER Empty border, used when the calendar does not have the focus. |
private final static int | FIRST_YEAR First year that can be selected. |
private final static Border | FOCUSED_BORDER Border used to highlight the selected day when the calendar has the focus. |
private final static int | LAST_YEAR Last year that can be selected. |
private int | lastDay Last day of the selected month. |
private JComboBox | month Month selection control. |
private final static 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 JButton | ok "Ok" button. |
private boolean | okClicked true if the "Ok" button was clicked to close thedialog box, false otherwise. |
private final static Color | SELECTED_DAY_BACKGROUND Text color of the selected day in the calendar. |
private final static Color | SELECTED_DAY_FOREGROUND Background color of the selected day in the calendar. |
private final static Color | WEEK_DAYS_FOREGROUND Text color of the days of the weeks, used as column headers in the calendar. |
private JComboBox | year Year selection control. |
Fields inherited from class javax.swing.JDialog |
rootPane, rootPaneCheckingEnabled, accessibleContext |
Fields inherited from class java.awt.Component |
TOP_ALIGNMENT, CENTER_ALIGNMENT, BOTTOM_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT |
Constructor Summary | |
DateChooser(Dialog owner, String title) Constructs a new DateChooser with the given title. | |
DateChooser(Dialog owner) Constructs a new DateChooser . | |
DateChooser(Frame owner, String title) Constructs a new DateChooser with the given title. | |
DateChooser(Frame owner) Constructs a new DateChooser . |
Method Summary | |
void | actionPerformed(ActionEvent e) Called when the "Ok" button is pressed. |
private void | construct() Initializes this DateChooser object. |
void | focusGained(FocusEvent e) Called when the calendar gains the focus. |
void | focusLost(FocusEvent e) Called when the calendar loses the focus. |
private int | getSelectedDay() Gets the selected day, as an int . |
void | itemStateChanged(ItemEvent e) Called when a new month or year is selected. |
void | keyPressed(KeyEvent e) Called when a key is pressed and the calendar has the focus. |
void | keyReleased(KeyEvent e) |
void | keyTyped(KeyEvent e) |
void | mouseClicked(MouseEvent e) Called when the mouse is clicked on a day in the calendar. |
void | mouseEntered(MouseEvent e) |
void | mouseExited(MouseEvent e) |
void | mousePressed(MouseEvent e) |
void | mouseReleased(MouseEvent e) |
Date | select(Date date) Selects a date. |
Date | select() Selects new date. |
private void | setSelected(JLabel newDay) Sets the selected day. |
private void | setSelected(int newDay) Sets the selected day. |
private void | update() Updates the calendar. |
Methods inherited from class javax.swing.JDialog |
dialogInit, createRootPane, processKeyEvent, processWindowEvent, setDefaultCloseOperation, getDefaultCloseOperation, update, setJMenuBar, getJMenuBar, isRootPaneCheckingEnabled, setRootPaneCheckingEnabled, addImpl, remove, setLayout, getRootPane, setRootPane, getContentPane, setContentPane, getLayeredPane, setLayeredPane, getGlassPane, setGlassPane, setLocationRelativeTo, paramString, getAccessibleContext |
Methods inherited from class java.awt.Dialog |
addNotify, isModal, setModal, getTitle, setTitle, show, hide, dispose, isResizable, setResizable |
Methods inherited from class java.awt.Window |
finalize, pack, toFront, toBack, getToolkit, getWarningString, getLocale, getInputContext, setCursor, getOwner, getOwnedWindows, addWindowListener, removeWindowListener, getListeners, processEvent, getFocusOwner, postEvent, isShowing, applyResourceBundle, applyResourceBundle, getGraphicsConfiguration |
Methods inherited from class java.awt.Container |
getComponentCount, countComponents, getComponent, getComponents, getInsets, insets, add, add, add, add, add, remove, removeAll, getLayout, doLayout, layout, invalidate, validate, validateTree, setFont, getPreferredSize, preferredSize, getMinimumSize, minimumSize, getMaximumSize, getAlignmentX, getAlignmentY, paint, print, paintComponents, printComponents, addContainerListener, removeContainerListener, processContainerEvent, deliverEvent, getComponentAt, locate, getComponentAt, findComponentAt, findComponentAt, removeNotify, isAncestorOf, list, list |
Methods inherited from class java.awt.Component |
getName, setName, getParent, getPeer, setDropTarget, getDropTarget, getTreeLock, isValid, isDisplayable, isVisible, isEnabled, setEnabled, enable, enable, disable, isDoubleBuffered, enableInputMethods, setVisible, show, getForeground, setForeground, getBackground, setBackground, getFont, setLocale, getColorModel, getLocation, getLocationOnScreen, location, setLocation, move, setLocation, getSize, size, setSize, resize, setSize, resize, getBounds, bounds, setBounds, reshape, setBounds, getX, getY, getWidth, getHeight, getBounds, getSize, getLocation, isOpaque, isLightweight, getGraphics, getFontMetrics, getCursor, paintAll, repaint, repaint, repaint, repaint, printAll, imageUpdate, createImage, createImage, prepareImage, prepareImage, checkImage, checkImage, contains, inside, contains, dispatchEvent, addComponentListener, removeComponentListener, addFocusListener, removeFocusListener, addHierarchyListener, removeHierarchyListener, addHierarchyBoundsListener, removeHierarchyBoundsListener, addKeyListener, removeKeyListener, addMouseListener, removeMouseListener, addMouseMotionListener, removeMouseMotionListener, addInputMethodListener, removeInputMethodListener, getInputMethodRequests, enableEvents, disableEvents, coalesceEvents, processComponentEvent, processFocusEvent, processMouseEvent, processMouseMotionEvent, processInputMethodEvent, processHierarchyEvent, processHierarchyBoundsEvent, handleEvent, mouseDown, mouseDrag, mouseUp, mouseMove, mouseEnter, mouseExit, keyDown, keyUp, action, gotFocus, lostFocus, isFocusTraversable, requestFocus, transferFocus, nextFocus, hasFocus, add, remove, toString, list, list, list, addPropertyChangeListener, removePropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, firePropertyChange, setComponentOrientation, getComponentOrientation |
Methods inherited from class java.lang.Object |
getClass, hashCode, equals, clone, notify, notifyAll, wait, wait, wait |
Field Detail |
private GregorianCalendar calendar
private JButton cancel
private JLabel day
private final static String[] DAYS
private JLabel[][] days
private final static Color DAYS_FOREGROUND
private FocusablePanel daysGrid
DateChooser
class.private final static Border EMPTY_BORDER
private final static int FIRST_YEAR
private final static Border FOCUSED_BORDER
private final static int LAST_YEAR
private int lastDay
private JComboBox month
private final static String[] MONTHS
private int offset
private JButton ok
private boolean okClicked
true
if the "Ok" button was clicked to close thefalse
otherwise.private final static Color SELECTED_DAY_BACKGROUND
private final static Color SELECTED_DAY_FOREGROUND
private final static Color WEEK_DAYS_FOREGROUND
private JComboBox year
Constructor Detail |
public DateChooser(Dialog owner, String title)
DateChooser
with the given title.public DateChooser(Dialog owner)
DateChooser
.public DateChooser(Frame owner, String title)
DateChooser
with the given title.public DateChooser(Frame owner)
DateChooser
.Method Detail |
public void actionPerformed(ActionEvent e)
private void construct()
DateChooser
object. Creates thepublic void focusGained(FocusEvent e)
public void focusLost(FocusEvent e)
private int getSelectedDay()
int
. Parses the textpublic void itemStateChanged(ItemEvent e)
public void keyPressed(KeyEvent e)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
public void mouseClicked(MouseEvent e)
public void mouseEntered(MouseEvent e)
public void mouseExited(MouseEvent e)
public void mousePressed(MouseEvent e)
public void mouseReleased(MouseEvent e)
public Date select(Date date)
null
if the userpublic Date select()
private void setSelected(JLabel newDay)
private void setSelected(int newDay)
private void update()
| ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |