com.darwinsys.swingui
Class CalIcon

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.darwinsys.swingui.CalIcon
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.swing.Icon

public class CalIcon
extends javax.swing.JComponent
implements javax.swing.Icon

Display one of those standard Calendar Page icons with Weekday, Day and Month. Can be used as the Icon in a JButton. Can include or exclude an updating Clock at the top (invoke constructor with value of true to include). However, it should be excluded when using as an Icon, and true when using as a Component.

Version:
$Id: CalIcon.java,v 1.4 2006/04/29 13:14:45 ian Exp $
Author:
Ian Darwin, http://www.darwinsys.com
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  Clock clock
          The Clock to show the time, if showTime
protected  java.awt.Dimension d
           
protected  java.awt.FontMetrics dayNameFM
          FontMetrics for displaying the time
protected  java.awt.Font dayNameFont
          Font for displaying the time
protected  java.awt.FontMetrics dayNumbFM
          FontMetrics for displaying the time
protected  java.awt.Font dayNumbFont
          Font for displaying the time
 java.lang.String[] days
          Days of the week
protected  java.awt.FontMetrics monNameFM
          FontMetrics for displaying the time
protected  java.awt.Font monNameFont
          Font for displaying the time
 java.lang.String[] mons
           
protected  java.util.Calendar myCal
          Our Calendar
protected  int RBH
          The size of the inner white box
protected  int RBW
          The size of the inner white box
protected  int RBX
          The x location of the inner box
protected  int RBY
          The y location of the inner box
protected  boolean showTime
          True if user wants the time shown
protected  int SIZE
          The size shalle be 64x64.
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
CalIcon(boolean showT)
          Construct the object with default arguments
CalIcon(java.util.Calendar c, boolean showT)
          Construct the object with a Calendar object
 
Method Summary
 int getIconHeight()
           
 int getIconWidth()
           
 java.awt.Dimension getMinimumSize()
           
 java.awt.Dimension getPreferredSize()
           
static void main(java.lang.String[] args)
           
 void paint(java.awt.Graphics g)
          Paint: draw the calendar page in the JComponent.
 void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
          paintIcon: draw the calendar page.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, 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

SIZE

protected final int SIZE
The size shalle be 64x64.

See Also:
Constant Field Values

d

protected final java.awt.Dimension d

RBW

protected final int RBW
The size of the inner white box

See Also:
Constant Field Values

RBH

protected final int RBH
The size of the inner white box

See Also:
Constant Field Values

RBX

protected final int RBX
The x location of the inner box


RBY

protected final int RBY
The y location of the inner box


myCal

protected java.util.Calendar myCal
Our Calendar


showTime

protected boolean showTime
True if user wants the time shown


clock

protected Clock clock
The Clock to show the time, if showTime


dayNumbFont

protected java.awt.Font dayNumbFont
Font for displaying the time


dayNumbFM

protected java.awt.FontMetrics dayNumbFM
FontMetrics for displaying the time


dayNameFont

protected java.awt.Font dayNameFont
Font for displaying the time


dayNameFM

protected java.awt.FontMetrics dayNameFM
FontMetrics for displaying the time


monNameFont

protected java.awt.Font monNameFont
Font for displaying the time


monNameFM

protected java.awt.FontMetrics monNameFM
FontMetrics for displaying the time


days

public java.lang.String[] days
Days of the week


mons

public java.lang.String[] mons
Constructor Detail

CalIcon

public CalIcon(boolean showT)
Construct the object with default arguments


CalIcon

public CalIcon(java.util.Calendar c,
               boolean showT)
Construct the object with a Calendar object

Method Detail

paint

public void paint(java.awt.Graphics g)
Paint: draw the calendar page in the JComponent. Delegates most work to paintIcon().

Overrides:
paint in class javax.swing.JComponent

paintIcon

public void paintIcon(java.awt.Component c,
                      java.awt.Graphics g,
                      int x,
                      int y)
paintIcon: draw the calendar page.

Specified by:
paintIcon in interface javax.swing.Icon

getIconWidth

public int getIconWidth()
Specified by:
getIconWidth in interface javax.swing.Icon

getIconHeight

public int getIconHeight()
Specified by:
getIconHeight in interface javax.swing.Icon

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class javax.swing.JComponent

getMinimumSize

public java.awt.Dimension getMinimumSize()
Overrides:
getMinimumSize in class javax.swing.JComponent

main

public static void main(java.lang.String[] args)


Copyright © 1996-2004 Ian F. Darwin. See license.html for usage license.