com.wildcrest.j2printerworks
Class J2Label

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JLabel
                  extended bycom.wildcrest.j2printerworks.J2Label
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.swing.SwingConstants

public class J2Label
extends javax.swing.JLabel

A subclass of JLabel with a default Font of Serif,PLAIN,10, default foreground Color black, and default background Color white and opague, useful for making HTML JLabels that work consistently across all JDKs 1.2.x and later.

This subclass is useful for defining JLabel instances when using HTML so that you can overcome a series of problems that make it difficult to use JLabel consistently across different JDK versions. These problems include:
    Under JDK 1.3 and 1.3.1 the default foreground color is blue, under JDK 1.2 and also 1.4 and later it is black
    Under JDK 1.4 and later the default Font is BOLD, previously it was PLAIN (and since HTML lacks a "plain" command, this locks you into BOLD)
    Under JDK 1.4 and later, calling setFont controls the initial HTML font, previously it was ignored
    Under JDK 1.4 and later, the <font size=n> tag results in text the same size as in browsers, previously it was one size too big

J2Label addresses these problems by always making the foreground Color black, and making the default font PLAIN, and under JDK 1.3 and 1.3.1 modifying the HTML to set the initial font. The default font is set to Serif,PLAIN,10, which is the same as the J2Printer default String font for headers and footers.

In addition, because of the <font size=n> problem, we recommend you specify all HTML fonts in relative size, e.g.
    <font size=+3> is approximately 36 point
    <font size=+2> is approximately 24 point
    <font size=+1> is approximately 18 point
    <font size=+0> is approximately 14 point
    <font size=-1> is approximately 12 point
    <font size=-2> is approximately 10 point
    <font size=-3> is approximately 8 point

Using relative sizes for all HTML JLabel (and JTextPane) instances will help you make your output look the same under all JDKs. You may also find it useful to use the HTML tags <big> and <small>.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JLabel
javax.swing.JLabel.AccessibleJLabel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JLabel
labelFor
 
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 javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
J2Label()
          Same as JLabel but with a default Font of Serif,PLAIN,10 and default Color black
J2Label(javax.swing.Icon image)
          Same as JLabel but with a default Font of Serif,PLAIN,10 and default Color black
J2Label(javax.swing.Icon image, int horizontalAlignment)
          Same as JLabel but with a default Font of Serif,PLAIN,10 and default Color black
J2Label(java.lang.String text)
          Same as JLabel but with a default Font of Serif,PLAIN,10 and default Color black
J2Label(java.lang.String text, javax.swing.Icon icon, int horizontalAlignment)
          Same as JLabel but with a default Font of Serif,PLAIN,10, default foreground Color black, and default background Color white and opaque.
J2Label(java.lang.String text, int horizontalAlignment)
          Same as JLabel but with a default Font of Serif,PLAIN,10 and default Color black
 
Methods inherited from class javax.swing.JLabel
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
 

Constructor Detail

J2Label

public J2Label(java.lang.String text,
               javax.swing.Icon icon,
               int horizontalAlignment)
Same as JLabel but with a default Font of Serif,PLAIN,10, default foreground Color black, and default background Color white and opaque.


J2Label

public J2Label(java.lang.String text,
               int horizontalAlignment)
Same as JLabel but with a default Font of Serif,PLAIN,10 and default Color black


J2Label

public J2Label(java.lang.String text)
Same as JLabel but with a default Font of Serif,PLAIN,10 and default Color black


J2Label

public J2Label(javax.swing.Icon image,
               int horizontalAlignment)
Same as JLabel but with a default Font of Serif,PLAIN,10 and default Color black


J2Label

public J2Label(javax.swing.Icon image)
Same as JLabel but with a default Font of Serif,PLAIN,10 and default Color black


J2Label

public J2Label()
Same as JLabel but with a default Font of Serif,PLAIN,10 and default Color black