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.


Constructor Index

 o PVDate()
Constructor.
 o PVDate(Date)
Constructor.

Method Index

 o decrement()
Decrement date by 1 day.
 o getDate()
Get date as the Date data type.
 o getEnableArrows()
Get an option to enable the up/down arrow keys.
 o getLeadingZero()
Get date format of day/month fields.
 o getMonthFirst()
Get date format to display day or month first.
 o getSeparator()
Get a character for the field separator.
 o getShowCentury()
Get a date format (show/hide century).
 o getShowYear()
Get date format to show/hide year.
 o increment()
Increment date by 1 day.
 o setDate(Date)
Set date from the Date data type.
 o setEnableArrows(boolean)
Enable increment/decrement of a date field on the up/down arrow keys.
 o setLeadingZero(boolean)
Set date format of day/month fields.
 o setMonthFirst(boolean)
Set date format to display day or month first.
 o setSeparator(char)
Set a character for the field separator.
 o setShowCentury(boolean)
Set a date format (show/hide century).
 o setShowYear(boolean)
Set date format to show/hide year.
 o setText(String)
Set date from a text string.
 o shiftField(int, boolean)
Increment or decrement a date field by 1 day, month or year.

Constructors

 o 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.

 o PVDate

 public PVDate()
Constructor. The date is set to the null (text string " / / ").

Methods

 o setSeparator

 public void setSeparator(char separator)
Set a character for the field separator.
Parameters:
separator - field separator.
Default value - '/'.
See Also:
getSeparator

 o getSeparator

 public char getSeparator()
Get a character for the field separator.
Returns:
Field separator.
See Also:
setSeparator

 o 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

 o getShowYear

 public boolean getShowYear()
Get date format to show/hide year.
Returns:
Date format (show/hide year).
See Also:
setShowYear

 o 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

 o getMonthFirst

 public boolean getMonthFirst()
Get date format to display day or month first.
Returns:
Date format.
See Also:
setMonthFirst

 o 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

 o getShowCentury

 public boolean getShowCentury()
Get a date format (show/hide century).
Returns:
Date format (show/hide century).
See Also:
setShowCentury

 o 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

 o getLeadingZero

 public boolean getLeadingZero()
Get date format of day/month fields.
See Also:
setLeadingZero

 o 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

 o getEnableArrows

 public boolean getEnableArrows()
Get an option to enable the up/down arrow keys.
Returns:
An option.
See Also:
setEnableArrows

 o 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

 o setDate

 public void setDate(Date date)
Set date from the Date data type.
Parameters:
date - variable of type Date.
See Also:
getDate

 o 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

 o increment

 public void increment()
Increment date by 1 day.
See Also:
decrement, shiftField

 o decrement

 public void decrement()
Decrement date by 1 day.
See Also:
increment, shiftField

 o 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