com.sas.swing.visuals
Class CalendarDayButton

com.sas.swing.visuals.CalendarDayButton
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.SwingConstants

public class CalendarDayButton

The CalendarDayButton class extends the JButton to provide a specialized representation of a day of the month. This class is written specifically for use with with the CalendarPanel, although it may be used elsewhere as applicable. A day has an associated date, which provides the number to be shown in the button, and the full date is shown as a tooltip for the button. Use the setText() methods to set the date. The class supports three modes for the button: normal, selected and disabled. Disabled days are not selectable by the user. The selected day is rendered with a blue border to make it stand out from other days. Use the setType(int) method to specify the mode.

See Also:
Serialized Form

Field Summary
protected  java.awt.Color backgroundDisabled
           
protected  java.awt.Color backgroundHoover
           
protected  java.awt.Color backgroundNormal
           
protected  java.awt.Color backgroundToday
           
protected  java.awt.Color CALENDAR_FORECOLOR
           
protected  java.util.GregorianCalendar date
           
protected  java.lang.String dateFormat
           
static int DISABLED
          A disabled display mode for a calendar day.
protected  boolean enabled
           
protected  java.awt.Font fontDisabled
           
protected  java.awt.Font fontNormal
           
protected  java.awt.Font fontToday
           
protected  java.awt.Color foregroundDisabled
           
protected  java.awt.Color foregroundNormal
           
protected  java.awt.Color foregroundToday
           
protected  boolean isSelected
           
protected  boolean mouseOver
           
static int NORMAL
          The normal, enabled display mode for a calendar day.
protected  java.awt.Color outlineColor
           
static int OUTLINED
          An outlined, enabled display mode for a calendar day.
protected  int type
           
 
Constructor Summary
CalendarDayButton()
          Default constructor.
CalendarDayButton(java.util.GregorianCalendar aDate)
          Constructor that takes a specified date as the initial selected date.
 
Method Summary
protected  void addListeners()
          Add Listeners to the class
 boolean canSelect()
          Deprecated. This property is no longer needed or available.
 java.util.GregorianCalendar getDate()
          Returns the date for this button.
 java.awt.Color getOutlineColor()
          Returns the color used for the outline when the component's type is set to OUTLINED.
protected  void init()
           
protected  void initializeUI()
           
protected  boolean isEffectivelyEnabled()
          Returns true if the component is effectively enabled; that is, if it's enabled at the component level and its type is not marked as DISABLED.
 boolean isSelected()
          Returns whether or not this button is selected.
protected  void paintComponent(java.awt.Graphics g)
          Need to paint this component's background in the case where it is selected.
protected  void setBackground()
           
protected  void setBorder()
           
 void setCanSelect(boolean selectable)
          Deprecated. This property is no longer needed or available.
 void setEnabled(boolean mode)
          Sets the enabled state of this component.
 void setForeColor(java.awt.Color color)
          Method to set the foreground color of the component.
 void setOutlineColor(java.awt.Color color)
          Sets the color used for the outline when the component's type is set to OUTLINED.
 void setSelected(boolean selected)
          Set this button as the selected button.
 void setSelected(boolean selected, boolean fireChangeEvent)
          Set this button as the selected button.
 void setText(java.util.GregorianCalendar aDate)
          Sets the date for this button using a GregorianCalendar representation of the date.
 void setText(java.lang.String ddMMyyyy)
          Sets the date for this button using a string representation of the date.
 void setType(int type)
          Sets the type of this text field.
 java.lang.String toString()
           
 

Field Detail

date

protected java.util.GregorianCalendar date

CALENDAR_FORECOLOR

protected java.awt.Color CALENDAR_FORECOLOR

isSelected

protected boolean isSelected

mouseOver

protected boolean mouseOver

NORMAL

public static final int NORMAL
The normal, enabled display mode for a calendar day.

See Also:
Constant Field Values

OUTLINED

public static final int OUTLINED
An outlined, enabled display mode for a calendar day.

See Also:
Constant Field Values

DISABLED

public static final int DISABLED
A disabled display mode for a calendar day.

See Also:
Constant Field Values

type

protected int type

enabled

protected boolean enabled

outlineColor

protected java.awt.Color outlineColor

backgroundHoover

protected java.awt.Color backgroundHoover

foregroundNormal

protected java.awt.Color foregroundNormal

backgroundNormal

protected java.awt.Color backgroundNormal

fontNormal

protected java.awt.Font fontNormal

foregroundToday

protected java.awt.Color foregroundToday

backgroundToday

protected java.awt.Color backgroundToday

fontToday

protected java.awt.Font fontToday

foregroundDisabled

protected java.awt.Color foregroundDisabled

backgroundDisabled

protected java.awt.Color backgroundDisabled

fontDisabled

protected java.awt.Font fontDisabled

dateFormat

protected java.lang.String dateFormat
Constructor Detail

CalendarDayButton

public CalendarDayButton()
Default constructor.


CalendarDayButton

public CalendarDayButton(java.util.GregorianCalendar aDate)
Constructor that takes a specified date as the initial selected date.

Parameters:
aDate - The date to use as the intial selected date.
Method Detail

init

protected void init()

initializeUI

protected void initializeUI()
                     throws java.lang.Exception
Throws:
java.lang.Exception

setType

public void setType(int type)
Sets the type of this text field. Valid values are: NORMAL: A regular, selectable day OUTLINED: A selectable day with a border (default blue) around the number DISABLED: An unselectable, grayed-out day

Parameters:
type - The value to set for this field's type.

setBorder

protected void setBorder()

setBackground

protected void setBackground()

setSelected

public void setSelected(boolean selected)
Set this button as the selected button. The selected button will be highlighted and represents the user's selection.

Overrides:
setSelected in class javax.swing.AbstractButton
Parameters:
selected - The value representing whether or not this field is the selected one.

setSelected

public void setSelected(boolean selected,
                        boolean fireChangeEvent)
Set this button as the selected button. The selected button will be highlighted and represents the user's selection.

Parameters:
selected - The value representing whether or not this field is the selected one.
fireChangeEvent - Set to true to fire the "selectedState" propertyChangeEvent, false otherwise.

isSelected

public boolean isSelected()
Returns whether or not this button is selected.

Overrides:
isSelected in class javax.swing.AbstractButton
Returns:
A boolean representing the selected state.

setCanSelect

public void setCanSelect(boolean selectable)
Deprecated. This property is no longer needed or available.

Sets whether or not this day is selectable.


canSelect

public boolean canSelect()
Deprecated. This property is no longer needed or available.

Returns whether or not this day is selectable.


setText

public void setText(java.lang.String ddMMyyyy)
Sets the date for this button using a string representation of the date.

Overrides:
setText in class javax.swing.AbstractButton
Parameters:
ddMMyyyy - the date in the ddMMyyyy String format.

setText

public void setText(java.util.GregorianCalendar aDate)
Sets the date for this button using a GregorianCalendar representation of the date.

Parameters:
aDate - the date in a GregorianCalendar format.

getDate

public java.util.GregorianCalendar getDate()
Returns the date for this button.

Returns:
the date of this button.

toString

public java.lang.String toString()
Overrides:
toString in class java.awt.Component

addListeners

protected void addListeners()
Add Listeners to the class


setForeColor

public void setForeColor(java.awt.Color color)
Method to set the foreground color of the component.

Parameters:
color - the color to use.

setOutlineColor

public void setOutlineColor(java.awt.Color color)
Sets the color used for the outline when the component's type is set to OUTLINED.

Parameters:
color - The color to use for the outline

getOutlineColor

public java.awt.Color getOutlineColor()
Returns the color used for the outline when the component's type is set to OUTLINED.

Returns:
The color used for the outline.

setEnabled

public void setEnabled(boolean mode)
Sets the enabled state of this component.

Overrides:
setEnabled in class javax.swing.AbstractButton
Parameters:
mode - Set to true to enable the component, false otherwise.

paintComponent

protected void paintComponent(java.awt.Graphics g)
Need to paint this component's background in the case where it is selected.

Overrides:
paintComponent in class javax.swing.JComponent

isEffectivelyEnabled

protected boolean isEffectivelyEnabled()
Returns true if the component is effectively enabled; that is, if it's enabled at the component level and its type is not marked as DISABLED.

Returns:
True if the component is effectively enabled, false otherwise.



Copyright © 2009 SAS Institute Inc. All Rights Reserved.