[.home.]
[.hacks.]
[.java.]

Class Cal

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--Awt
                          |
                          +--Cal
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.util.EventListener, java.awt.event.FocusListener, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.event.KeyListener, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable

public class Cal
extends Awt
implements java.awt.event.ActionListener

(#)Cal.java

Version:
3.2 19-Mar-2004

A universal calendar widget to enter/display a date optionally time
Author:
Holger Pfaff
See Also:
Serialized Form

Field Summary
protected  java.util.GregorianCalendar cl
          holds current date/time
static int DATE
          bitmask for showing date
protected  Caption datl
          date label - disply current date set
protected  java.awt.Container datp
          date panel
protected  java.awt.Container dayp
          day panel
protected  Knob[] days
          knobs for day of month selection
protected  java.text.DateFormat df
          dateformat used for this widget
protected  int mode
          currend mode: TIME, DATE, DATE|TIME
protected  java.text.DateFormat tf
          timeformat used for this widget
static int TIME
          bitmask for showing time
protected  Caption timl
          time label - disply current time set
protected  java.awt.Container timp
          time panel
 
Fields inherited from class Awt
actionListener, Background, bg, big, bim, Black, BlueMask, Bold, Bolditalic, borderDepth, borderType, BOTTOM, Brighter, Bulk, BULK, C, Center, CENTER, ColorMask, componentStates, Darker, E, East, EFFECT_MASK, Esc, FILL, Flat, FontMask, fonts, FontSize0, FontSizeMask, Foreground, GreenMask, Href, HREF, Hrefend, innerInsets, insets, Italic, itemListener, jvendor, jversion, Larger, LEFT, minimumDimension, MISC_MASK, Monospaced, N, NE, None, NONE, North, NorthEast, NorthWest, Null, NW, Plain, POSITION_MASK, Raised, RAISED, RedMask, RIGHT, S, SansSerif, SE, Serif, Smaller, South, SouthEast, SouthWest, Sunken, SUNKEN, SW, Tab0, TabMask, TabSizeMask, TOP, Uline, ULINE, W, West, White
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Cal()
          default constructor - creates date date/time widget
Cal(int m)
          constructor - creates specified widget
Cal(int m, java.util.Date d)
          constructor - creates specified widget with specified initial date/time
Cal(int m, java.util.Date d, java.util.Locale l)
          constructor - creates specified widget with specified initial date/time and specified locale (language)
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          implement actionlistener to catch knobs pressed
 void add(int f, int v)
          increment/decrement current date/time
protected  java.util.TimeZone correctTZ(java.util.TimeZone tz)
          Java treats MET as "Middle Eastern Time" not as "Middle European time" as expected.
 java.util.Calendar getCalendar()
          get this widget's date/time as Calendar object
 java.util.Date getDate()
          get this widget's current date/time
 int getMode()
          get this widget's mode
 long getTime()
          get this widget's current time as seconds from 1970
 java.awt.Dimension measure()
          get this widget's required size
protected  void set()
          internally called if something has changed
 void set(int f, int v)
          set current date/time
 void setCalendar(java.util.Calendar c)
          set current date/time
 void setDate(java.util.Calendar c)
          set current date/time
 void setDate(java.util.Date d)
          set current date/time
 void setDate(java.lang.String d, java.text.DateFormat df)
          set current date/time from string using specified date format
 void setDate(java.lang.String d, java.lang.String df)
          set current date/time from string using specified date format
 void setMode(int m)
          set this widget mode - TIME, DATE or DATE|TIME
 java.lang.String toString(java.text.DateFormat df)
          get this widget's date/time using the specified date format
 java.lang.String toString(java.lang.String df)
          get this widget's date/time using the specified date format
 
Methods inherited from class Awt
addActionListener, addItemListener, addNotify, adjustmentValueChanged, Array2Insets, bold, bolditalic, brighter, centerWindow, Color2Esc, darker, dim, doHref, doMeasure, drawCaption, drawCaption, drawLine, drawRectangle, drawString, drawString, drawTriangle, error, exHref, exString, focusGained, focusLost, getAppletContext, getBG, getBGImage, getBGParent, getBGParentImage, getBorderDepth, getBorderRectangle, getBorderType, getColor, getColor, getFont, getFont, getFont, getInnerInsets, getInnerRectangle, getInsets, getMetrics, getMinimumSize, getMode, getPosition, getPreferredSize, getRectangle, getSelectedObjects, getTab, getTopComponent, invalidate, isBulk, isEffect, isFill, isHref, isMSJVM, isNS4JVM, isRaised, isSunken, isUline, italic, keyPressed, keyReleased, keyTyped, larger, loadImage, loadImageFromArchive, loadImageFromStream, loadImageFromURL, makeBim, measureCaption, measureString, monospaced, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, notifyActionListeners, notifyItemListeners, paint, paintBackground, paintBackground, paintBim, paintBorder, plain, refresh, refresh, refreshAll, removeActionListener, removeItemListener, sansserif, serif, setBackground, setBG, setBGIfNull, setBorderDepth, setBorderType, setBorderType, setBounds, setEnabled, setFont, setFont, setForeground, setInnerInsets, setInsets, setVisible, smaller, tile, tile, update, waitForImage
 
Methods inherited from class java.awt.Panel
getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getListeners, getMaximumSize, insets, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DATE

public static final int DATE
bitmask for showing date

See Also:
Constant Field Values

TIME

public static final int TIME
bitmask for showing time

See Also:
Constant Field Values

mode

protected int mode
currend mode: TIME, DATE, DATE|TIME


cl

protected java.util.GregorianCalendar cl
holds current date/time


df

protected java.text.DateFormat df
dateformat used for this widget


tf

protected java.text.DateFormat tf
timeformat used for this widget


days

protected Knob[] days
knobs for day of month selection


datp

protected java.awt.Container datp
date panel


dayp

protected java.awt.Container dayp
day panel


timp

protected java.awt.Container timp
time panel


datl

protected Caption datl
date label - disply current date set


timl

protected Caption timl
time label - disply current time set

Constructor Detail

Cal

public Cal()
default constructor - creates date date/time widget


Cal

public Cal(int m)
constructor - creates specified widget

Parameters:
m - mode bits: TIME DATE DATE|TIME

Cal

public Cal(int m,
           java.util.Date d)
constructor - creates specified widget with specified initial date/time

Parameters:
m - mode bits: TIME DATE DATE|TIME
d - date for initialization

Cal

public Cal(int m,
           java.util.Date d,
           java.util.Locale l)
constructor - creates specified widget with specified initial date/time and specified locale (language)

Parameters:
m - mode bits: TIME DATE DATE|TIME
d - date for initialization
l - locale to use
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
implement actionlistener to catch knobs pressed

Specified by:
actionPerformed in interface java.awt.event.ActionListener

add

public void add(int f,
                int v)
increment/decrement current date/time

Parameters:
f - field to change within calendar
v - value to add/remove

set

public void set(int f,
                int v)
set current date/time

Parameters:
f - field to set within calendar
v - value to set

setDate

public void setDate(java.util.Date d)
set current date/time

Parameters:
d - date to set

setDate

public void setDate(java.lang.String d,
                    java.lang.String df)
set current date/time from string using specified date format

Parameters:
d - date to set
df - date format to use

setDate

public void setDate(java.lang.String d,
                    java.text.DateFormat df)
set current date/time from string using specified date format

Parameters:
d - date to set
df - date format to use

getDate

public java.util.Date getDate()
get this widget's current date/time


getTime

public long getTime()
get this widget's current time as seconds from 1970


setDate

public void setDate(java.util.Calendar c)
set current date/time

Parameters:
c - date/time to use

setCalendar

public void setCalendar(java.util.Calendar c)
set current date/time

Parameters:
c - date/time to use

getCalendar

public java.util.Calendar getCalendar()
get this widget's date/time as Calendar object


set

protected void set()
internally called if something has changed


setMode

public void setMode(int m)
set this widget mode - TIME, DATE or DATE|TIME

Parameters:
m - mode bits: TIME DATE DATE|TIME

getMode

public int getMode()
get this widget's mode


toString

public java.lang.String toString(java.lang.String df)
get this widget's date/time using the specified date format

Parameters:
df - date format to use

toString

public java.lang.String toString(java.text.DateFormat df)
get this widget's date/time using the specified date format

Parameters:
df - date format to use

correctTZ

protected java.util.TimeZone correctTZ(java.util.TimeZone tz)
Java treats MET as "Middle Eastern Time" not as "Middle European time" as expected. For now just change MET to ECT


measure

public java.awt.Dimension measure()
get this widget's required size

Overrides:
measure in class Awt

[.home.]
[.hacks.]
[.java.]