|
||||||||||
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
javax.swing.text.JTextComponent
javax.swing.JTextField
javax.swing.JFormattedTextField
edu.wisc.ssec.mcidasv.data.dateChooser.JTextFieldDateEditor
public class JTextFieldDateEditor
JTextFieldDateEditor is the default editor used by JDateChooser. It is a formatted text field, that colores valid dates green/black and invalid dates red. The date format patten and mask can be set manually. If not set, the MEDIUM pattern of a SimpleDateFormat with regards to the actual locale is used.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JFormattedTextField |
---|
JFormattedTextField.AbstractFormatter, JFormattedTextField.AbstractFormatterFactory |
Nested classes/interfaces inherited from class javax.swing.JTextField |
---|
JTextField.AccessibleJTextField |
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent |
---|
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBinding |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
private Calendar |
calendar
|
protected Color |
darkGreen
|
protected Date |
date
|
protected SimpleDateFormat |
dateFormatter
|
protected String |
datePattern
|
protected DateUtil |
dateUtil
|
private int |
hours
|
private boolean |
ignoreDatePatternChange
|
private boolean |
isMaskVisible
|
protected MaskFormatter |
maskFormatter
|
protected String |
maskPattern
|
private int |
millis
|
private int |
minutes
|
protected char |
placeholder
|
private int |
seconds
|
private static long |
serialVersionUID
|
Fields inherited from class javax.swing.JFormattedTextField |
---|
COMMIT, COMMIT_OR_REVERT, PERSIST, REVERT |
Fields inherited from class javax.swing.JTextField |
---|
notifyAction |
Fields inherited from class javax.swing.text.JTextComponent |
---|
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY |
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 javax.swing.SwingConstants |
---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JTextFieldDateEditor()
|
|
JTextFieldDateEditor(boolean showMask,
String datePattern,
String maskPattern,
char placeholder)
|
|
JTextFieldDateEditor(String datePattern,
String maskPattern,
char placeholder)
|
Method Summary | |
---|---|
void |
actionPerformed(ActionEvent e)
Validates the typed date and sets it (only if it is valid). |
void |
caretUpdate(CaretEvent event)
After any user input, the value of the textfield is proofed. |
private void |
checkText()
|
String |
createMaskFromDatePattern(String datePattern)
Creates a mask from a date pattern. |
void |
focusGained(FocusEvent e)
|
void |
focusLost(FocusEvent focusEvent)
|
Date |
getDate()
Returns the date. |
String |
getDateFormatString()
Returns tha date format string. |
Date |
getMaxSelectableDate()
Gets the minimum selectable date. |
Date |
getMinSelectableDate()
Gets the maximum selectable date. |
Dimension |
getPreferredSize()
Returns the preferred size. |
JComponent |
getUiComponent()
Returns the UI component, e.g. the actual JTextField implementing the editor. |
boolean |
isMaskVisible()
Returns true, if the mask is visible. |
static void |
main(String[] s)
Creates a JFrame with a JCalendar inside and can be used for testing. |
void |
setDate(Date date)
Sets the date. |
protected void |
setDate(Date date,
boolean firePropertyChange)
Sets the date. |
void |
setDateFormatString(String dateFormatString)
Sets the date format string, e.g. |
void |
setEnabled(boolean b)
Enables and disabled the compoment. |
void |
setLocale(Locale locale)
Sets the locale. |
void |
setMaskVisible(boolean isMaskVisible)
Sets the mask visible. |
void |
setMaxSelectableDate(Date max)
Sets the maximum selectable date. |
void |
setMinSelectableDate(Date min)
Sets the minimum selectable date. |
void |
setSelectableDateRange(Date min,
Date max)
Sets a valid date range for selectable dates. |
Methods inherited from class javax.swing.JFormattedTextField |
---|
commitEdit, getActions, getFocusLostBehavior, getFormatter, getFormatterFactory, getUIClassID, getValue, invalidEdit, isEditValid, processFocusEvent, processInputMethodEvent, setDocument, setFocusLostBehavior, setFormatter, setFormatterFactory, setValue |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface edu.wisc.ssec.mcidasv.data.dateChooser.IDateEditor |
---|
addPropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, removePropertyChangeListener |
Field Detail |
---|
private static final long serialVersionUID
protected Date date
protected SimpleDateFormat dateFormatter
protected MaskFormatter maskFormatter
protected String datePattern
protected String maskPattern
protected char placeholder
protected Color darkGreen
protected DateUtil dateUtil
private boolean isMaskVisible
private boolean ignoreDatePatternChange
private int hours
private int minutes
private int seconds
private int millis
private Calendar calendar
Constructor Detail |
---|
public JTextFieldDateEditor()
public JTextFieldDateEditor(String datePattern, String maskPattern, char placeholder)
public JTextFieldDateEditor(boolean showMask, String datePattern, String maskPattern, char placeholder)
Method Detail |
---|
public Date getDate()
IDateEditor
getDate
in interface IDateEditor
public void setDate(Date date)
IDateEditor
setDate
in interface IDateEditor
date
- the date to setprotected void setDate(Date date, boolean firePropertyChange)
date
- the datefirePropertyChange
- true, if the date property should be fired.public void setDateFormatString(String dateFormatString)
IDateEditor
setDateFormatString
in interface IDateEditor
dateFormatString
- the date format stringpublic String getDateFormatString()
IDateEditor
getDateFormatString
in interface IDateEditor
public JComponent getUiComponent()
IDateEditor
getUiComponent
in interface IDateEditor
public void caretUpdate(CaretEvent event)
caretUpdate
in interface CaretListener
event
- the caret eventpublic void focusLost(FocusEvent focusEvent)
focusLost
in interface FocusListener
private void checkText()
public void focusGained(FocusEvent e)
focusGained
in interface FocusListener
public void setLocale(Locale locale)
IDateEditor
setLocale
in interface IDateEditor
setLocale
in class Component
locale
- the locale to setpublic String createMaskFromDatePattern(String datePattern)
datePattern
- the date pattern
public boolean isMaskVisible()
public void setMaskVisible(boolean isMaskVisible)
isMaskVisible
- true, if the mask should be visiblepublic Dimension getPreferredSize()
getPreferredSize
in class JTextField
public void actionPerformed(ActionEvent e)
actionPerformed
in interface ActionListener
public void setEnabled(boolean b)
setEnabled
in interface IDateEditor
setEnabled
in class JComponent
b
- true, if the UI component should be enabled.public Date getMaxSelectableDate()
IDateEditor
getMaxSelectableDate
in interface IDateEditor
public Date getMinSelectableDate()
IDateEditor
getMinSelectableDate
in interface IDateEditor
public void setMaxSelectableDate(Date max)
IDateEditor
setMaxSelectableDate
in interface IDateEditor
max
- maximum selectable datepublic void setMinSelectableDate(Date min)
IDateEditor
setMinSelectableDate
in interface IDateEditor
min
- minimum selectable datepublic void setSelectableDateRange(Date min, Date max)
IDateEditor
setSelectableDateRange
in interface IDateEditor
min
- the minimum selectable date or null (then the minimum date should be
set to 01\01\0001)max
- the maximum selectable date or null (then the maximum date should be
set to 01\01\9999)public static void main(String[] s)
s
- The command line arguments
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |