capella.GUI
Class LabelImage

java.lang.Object
  extended by java.awt.Component
      extended by capella.GUI.LabelImage
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class LabelImage
extends Component

A LabelImage object is a lightweight component for placing an image in a container.

For example the code:

 setLayout(new BorderLayout());
 add("Center",new LabelImage(INSERT_AN_URL_HERE,LabelImage.LEFT);
 

Since:
JDK1.1
Version:
1.0 (1998)
Author:
Jean-Baptiste Yunès (Jean-Baptiste.Yunes@liafa.jussieu.fr)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int BOTTOM
          Indicates that the label should be placed at the bottom.
static int CENTER
          Indicates that the label should be centered.
static int LEFT
          Indicates that the label should be placed on the left.
static int RIGHT
          Indicates that the label should be placed on the right.
static int TOP
          Indicates that the label should be placed on top.
 
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
LabelImage(String path)
          Constructs a centered label.
LabelImage(String path, int alignment)
          Constructs a label justified as desired.
LabelImage(URL url)
          Constructs a centered label.
LabelImage(URL url, int alignment)
          Constructs a label justified as desired.
 
Method Summary
 int getAlignment()
          Gets the current alignment for this label.
 Image getImage()
          Gets the current image.
 Dimension getPreferredSize()
          Gets the preferred size for this label.
 void paint(Graphics g)
          Paints this label.
 void setAlignment(int alignment)
          Sets the alignment for this label.
 void setImage(Image image)
          Sets the image for this label.
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CENTER

public static final int CENTER
Indicates that the label should be centered.

See Also:
Constant Field Values

LEFT

public static final int LEFT
Indicates that the label should be placed on the left.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
Indicates that the label should be placed on the right.

See Also:
Constant Field Values

TOP

public static final int TOP
Indicates that the label should be placed on top.

See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
Indicates that the label should be placed at the bottom.

See Also:
Constant Field Values
Constructor Detail

LabelImage

public LabelImage(String path)
Constructs a centered label.

Parameters:
path - the path of a local image-file.

LabelImage

public LabelImage(String path,
                  int alignment)
Constructs a label justified as desired.

Possible values for alignment are LabelImage.CENTER, LabelImage.LEFT, LabelImage.RIGHT, LabelImage.TOP and LabelImage.BOTTOM.

Parameters:
path - the path of a local image-file.
alignment - the alignment value.

LabelImage

public LabelImage(URL url)
Constructs a centered label.

Parameters:
url - the URL of an image.

LabelImage

public LabelImage(URL url,
                  int alignment)
Constructs a label justified as desired.

Possible values for alignment are LabelImage.CENTER, LabelImage.LEFT, LabelImage.RIGHT, LabelImage.TOP and LabelImage.BOTTOM.

Parameters:
url - the URL of an image.
alignment - the alignment value.
Method Detail

getImage

public Image getImage()
Gets the current image.

Returns:
the current image.
See Also:
setImage(java.awt.Image)

setImage

public void setImage(Image image)
Sets the image for this label.

Parameters:
image - the image to use.
Throws:
IllegalArgumentException - if an null object is given.
See Also:
getImage()

getAlignment

public int getAlignment()
Gets the current alignment for this label.

Possible values for alignment are LabelImage.CENTER, LabelImage.LEFT, LabelImage.RIGHT, LabelImage.TOP and LabelImage.BOTTOM.

Returns:
the current alignment.
See Also:
setAlignment(int)

setAlignment

public void setAlignment(int alignment)
Sets the alignment for this label.

Possible values for alignment are LabelImage.CENTER, LabelImage.LEFT, LabelImage.RIGHT, LabelImage.TOP and LabelImage.BOTTOM.

Parameters:
alignment - the desired alignment.
Throws:
IllegalArgumentException - if an illegal value for alignment is given.
See Also:
getAlignment()

paint

public void paint(Graphics g)
Paints this label.

Overrides:
paint in class Component
Parameters:
g - the graphics context to use for painting.

getPreferredSize

public Dimension getPreferredSize()
Gets the preferred size for this label.

Overrides:
getPreferredSize in class Component
Returns:
the size in a Dimension