Class pvWinJ.PVDate
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Canvas
|
+----pvWinJ.PVEdit
|
+----pvWinJ.PVDate
- public class PVDate
- extends PVEdit
Class PVDate is designed to display and edit a text string
that represents a date.
It inherits edit mode behavior and painting styles from the
PVEdit.
All aspects of painting and edit mode behavior can be customized
through get/setProperty().
PVDate supports TextListener, FocusListener, KeyListener and
MouseListener interfaces.
Example to insert an instance of the PVDate class in an applet
and set some properties:
public void init()
{
setSize(580, 400);
setLayout(null);
pvWinJ.PVDate date = new pvWinJ.PVDate();
add(date);
date.setShowCentury(false);
date.setLeadingZero(false);
date.setMonthFirst(false);
date.setText("2/23/88");
date.setSelectionOnFocus(true);
date.setBorder(pvWinJ.PVEdit.SUNKEN + 3);
date.setBackColor(getBackground().brighter());
date.setShadow(pvWinJ.PVEdit.RIGHT_BOTTOM);
date.setBounds(5, 10, 150, 25);
...
}
Notes:
The up/down arrows key will increment/decrement a current date
field.
Use the get/setBackColor() to get/set the background color rather
than the get/setBackground() methods.
When fontStyle is set to a LED.., then text is painted by the LED
build in font rather then the selected Font object.
When font with aureole is enabled, then the text 3D effect is
disabled.
PVDate()
- Constructor.
PVDate(Date)
- Constructor.
decrement()
- Decrement date by 1 day.
getDate()
- Get date as the Date data type.
getEnableArrows()
- Get an option to enable the up/down arrow keys.
getLeadingZero()
- Get date format of day/month fields.
getMonthFirst()
- Get date format to display day or month first.
getSeparator()
- Get a character for the field separator.
getShowCentury()
- Get a date format (show/hide century).
getShowYear()
- Get date format to show/hide year.
increment()
- Increment date by 1 day.
setDate(Date)
- Set date from the Date data type.
setEnableArrows(boolean)
- Enable increment/decrement of a date field on the up/down
arrow keys.
setLeadingZero(boolean)
- Set date format of day/month fields.
setMonthFirst(boolean)
- Set date format to display day or month first.
setSeparator(char)
- Set a character for the field separator.
setShowCentury(boolean)
- Set a date format (show/hide century).
setShowYear(boolean)
- Set date format to show/hide year.
setText(String)
- Set date from a text string.
shiftField(int,
boolean)
- Increment or decrement a date field by 1 day, month or
year.
PVDate
public PVDate(Date date)
- Constructor.
- Parameters:
- date - date.
Other properties are set:
autoScroll - false;
font - Ariel, PLAIN, size - 12;
fontStyle - 0(selected font);
borderStyle - 23(sunken);
insertEditMode - true;
editable - true;
alignment - 0(left justified);
odometerStyle - 0(solid color);
shadowStyle - 0(no shadow);
shadowWidth - 5;
text3D horizontal - 0;
text3D vertical - 0;
foreground - black;
backgroundColor - white;
borderColor - lightGray;
highlightColor - dark blue;
shadowColor - gray;
text3DColor - green.
PVDate
public PVDate()
- Constructor. The date is set to the null (text string
" / / ").
setSeparator
public void setSeparator(char separator)
- Set a character for the field separator.
- Parameters:
- separator - field separator.
Default value - '/'.
- See Also:
- getSeparator
getSeparator
public char getSeparator()
- Get a character for the field separator.
- Returns:
- Field separator.
- See Also:
- setSeparator
setShowYear
public void setShowYear(boolean showYear)
- Set date format to show/hide year.
- Parameters:
- showYear - option to show/hide year.
Value true will show year; value false - hide
year.
Default value - true.
- See Also:
- getShowYear
getShowYear
public boolean getShowYear()
- Get date format to show/hide year.
- Returns:
- Date format (show/hide year).
- See Also:
- setShowYear
setMonthFirst
public void setMonthFirst(boolean monthFirst)
- Set date format to display day or month first.
- Parameters:
- monthFirst - an option.
Value true will display month first and day
second; value false - day first and month second.
Default value - true.
- See Also:
- getMonthFirst
getMonthFirst
public boolean getMonthFirst()
- Get date format to display day or month first.
- Returns:
- Date format.
- See Also:
- setMonthFirst
setShowCentury
public void setShowCentury(boolean showCentury)
- Set a date format (show/hide century).
- Parameters:
- showCentury - option to set date format.
Value true will show century; value false - hide
century.
Default value - true.
- See Also:
- getShowCentury
getShowCentury
public boolean getShowCentury()
- Get a date format (show/hide century).
- Returns:
- Date format (show/hide century).
- See Also:
- setShowCentury
setLeadingZero
public void setLeadingZero(boolean leadingZero)
- Set date format of day/month fields. Add extra leading
zero in front of the day or the month field when field is
one digit long.
- Parameters:
- leadingZero - an option.
Value true will set format to dd/mm/y...; value
false - d/m/y...
Default value - true.
- See Also:
- getLeadingZero
getLeadingZero
public boolean getLeadingZero()
- Get date format of day/month fields.
- See Also:
- setLeadingZero
setEnableArrows
public void setEnableArrows(boolean enable)
- Enable increment/decrement of a date field on the up/down
arrow keys.
- Parameters:
- enable - an option.
Value true will enable keyboard arrows; value
false - disable arrows.
Default value is set to true.
- See Also:
- getEnableArrows, increment, decrement
getEnableArrows
public boolean getEnableArrows()
- Get an option to enable the up/down arrow keys.
- Returns:
- An option.
- See Also:
- setEnableArrows
setText
public synchronized void setText(String text)
- Set date from a text string.
- Parameters:
- text - new text string.
Examples of text strings: "8/23/97",
"08.23.1997".
- Overrides:
- setText
in class PVEdit
setDate
public void setDate(Date date)
- Set date from the Date data type.
- Parameters:
- date - variable of type Date.
- See Also:
- getDate
getDate
public Date getDate()
- Get date as the Date data type.
- Returns:
- The date built using a current text string or the
null, if the date is invalid.
- See Also:
- setDate
increment
public void increment()
- Increment date by 1 day.
- See Also:
- decrement, shiftField
decrement
public void decrement()
- Decrement date by 1 day.
- See Also:
- increment, shiftField
shiftField
public void shiftField(int field,
boolean increment)
- Increment or decrement a date field by 1 day, month or
year.
- Parameters:
- field - the date field id.
Values of the field: 0 - day, 1 - month, 2 -
year.
- increment - an option to increment or decrement a
field.
Value true - increment, value false - decrement.
- See Also:
- increment, decrement