Book Home Java Enterprise in a Nutshell Search this book

Chapter 9. The java.awt Package

The java.awt package is the main package of the AWT, or Abstract Windowing Toolkit. It contains classes for graphics, including the Java 2D graphics capabilities introduced in the Java 2 platform, and also defines the basic graphical user interface (GUI) framework for Java. java.awt also includes a number of heavyweight GUI objects, many of which have been superseded by the javax.swing package. java.awt also has a number of important subpackages.

The most important graphics classes in java.awt are Graphics and its Java 2D extension, Graphics2D. These classes represent a drawing surface, maintain a set of drawing attributes, and define methods for drawing and filling lines, shapes, and text. Classes that represent graphics attributes include Color, Font, Paint, Stroke, and Composite. The Image class and Shape interface represent things that you can draw using a Graphics object and the various graphics attributes. Figure 9-1 shows the graphics classes of this package.

figure

Figure 9-1. Graphics classes of the java.awt package

The most important class for GUIs is Component, which represents a single graphical element in a GUI. Container is a kind of component that can contain other components. The LayoutManager interface and its various implementations are used to position components within their containers. Figure 9-2 shows the GUI classes of this package, and Figure 9-3 shows the event, exception, and security classes.

figure

Figure 9-2. GUI classes of the java.awt package

figure

Figure 9-3. Event, exception, and security classes of the java.awt package

See Chapter 4, "Graphics with AWT and Java 2D", for an introduction to Java graphics with AWT and Java 2D and Chapter 2, "Swing and AWTArchitecture", for an introduction to the GUI framework defined by the java.awt package.

ActiveEventJava 1.2
java.awt

This interface is implemented by events that know how to dispatch themselves. When the event dispatch system encounters an ActiveEvent on the event queue, it simply invokes the dispatch() method of the event, instead of attempting to dispatch the event on its own. This interface is implemented by java.awt.event.InvocationEvent, which is used by the invokeLater() and invokeAndWait() methods of EventQueue.

public abstract interface ActiveEvent {
// Public Instance Methods
public abstract void dispatch ();
}

Implementations: java.awt.event.InvocationEvent

AdjustableJava 1.1
java.awtPJ1.1

This interface defines the methods that should be implemented by an object that maintains a user-adjustable numeric value. The adjustable value has specified minimum and maximum values, and it may be incremented or decremented either a unit at a time or a block at a time. An Adjustable object generates an AdjustmentEvent when it is adjusted and maintains a list of AdjustmentListener objects interested in being notified when such an event occurs.

This interface abstracts the essential functionality of the Scrollbar and javax.swing.JScrollBar components.

public abstract interface Adjustable {
// Public Constants
public static final int HORIZONTAL ; =0
public static final int VERTICAL ; =1
// Event Registration Methods (by event name)
public abstract void addAdjustmentListener (java.awt.event.AdjustmentListener l);
public abstract void removeAdjustmentListener (java.awt.event.AdjustmentListener l);
// Property Accessor Methods (by property name)
public abstract int getBlockIncrement ();
public abstract void setBlockIncrement (int b);
public abstract int getMaximum ();
public abstract void setMaximum (int max);
public abstract int getMinimum ();
public abstract void setMinimum (int min);
public abstract int getOrientation ();
public abstract int getUnitIncrement ();
public abstract void setUnitIncrement (int u);
public abstract int getValue ();
public abstract void setValue (int v);
public abstract int getVisibleAmount ();
public abstract void setVisibleAmount (int v);
}

Implementations: Scrollbar, javax.swing.JScrollBar

Passed To: java.awt.event.AdjustmentEvent.AdjustmentEvent(), java.awt.peer.ScrollPanePeer.{setUnitIncrement(), setValue()}

Returned By: ScrollPane.{getHAdjustable(), getVAdjustable()}, java.awt.event.AdjustmentEvent.getAdjustable()

AlphaCompositeJava 1.2
java.awt

This implementation of the Composite interface blends colors according to their levels of alpha transparency. AlphaComposite does not have a public constructor, but you can obtain a shared immutable instance by calling the static getInstance() method, specifying the desired compositing rule (one of the eight integer constants defined by the class), and specifying an alpha value. Alternatively, if you use an alpha value of 1.0, you can simply use one of the eight predefined AlphaComposite constants. Once you have obtained an AlphaComposite object, you use it by passing it to the setComposite() method of a Graphics2D object.

The most common way to use an AlphaComposite object is to specify the SRC_OVER compositing rule and an alpha value greater than 0 but less than 1. This causes the source colors you draw to be given the specified level of alpha transparency, so that they are blended with whatever colors already exist on the screen, making the destination colors appear to show through the translucent source colors. This technique allows you to achieve transparency effects using opaque colors when you are drawing onto a drawing surface, like a screen, that does not have an alpha channel.

The other compositing rules of AlphaComposite are best understood when both the source (your drawing) and the destination (the drawing surface) have alpha channels. For example, you can create translucent Color objects with the four-argument version of the Color() constructor, and you can create an off-screen image with an alpha channel by passing the constant TYPE_INT_ARGB to the java.awt.image.BufferedImage() constructor. (Once your compositing operation has been performed in an off-screen image with an alpha channel, you can view the results by copying the contents of the image to the screen, of course.) When your source and destination have alpha channels built in, you do not usually specify an alpha value for the AlphaComposite itself. If you do, however, the transparency values of the source colors are multiplied by this alpha value.

AlphaComposite supports the following compositing rules:

SRC

Replace the colors of the destination with the colors of the source, ignoring the destination colors and the transparency of the source.

SRC_OVER

Combine the source and destination colors combined based on the transparency of the source, so that the source appears to be drawn over the destination.

DST_OVER

Combine the source and destination colors based on the transparency of the destination, so that the source appears to be drawn underneath the destination.

SRC_IN

Draw the colors of the source using the transparency values of the destination, completely ignoring the colors of the destination.

SRC_OUT

Draw the colors of the source using the inverse transparency values of the destination.

DST_IN

Modify the colors of the destination using the alpha values of the source and ignoring the colors of the source.

DST_OUT

Modify the colors of the destination using the inverted alpha values of the source and ignoring the colors of the source.

CLEAR

Ignore the color and transparency of both the destination and the source. This clears the destination by making it a fully transparent black.

public final class AlphaComposite implements Composite {
// No Constructor
// Public Constants
public static final AlphaComposite Clear ;
public static final int CLEAR ; =1
public static final int DST_IN ; =6
public static final int DST_OUT ; =8
public static final int DST_OVER ; =4
public static final AlphaComposite DstIn ;
public static final AlphaComposite DstOut ;
public static final AlphaComposite DstOver ;
public static final AlphaComposite Src ;
public static final int SRC ; =2
public static final int SRC_IN ; =5
public static final int SRC_OUT ; =7
public static final int SRC_OVER ; =3
public static final AlphaComposite SrcIn ;
public static final AlphaComposite SrcOut ;
public static final AlphaComposite SrcOver ;
// Public Class Methods
public static AlphaComposite getInstance (int rule);
public static AlphaComposite getInstance (int rule, float alpha);
// Public Instance Methods
public float getAlpha ();
public int getRule ();
// Methods Implementing Composite
public CompositeContext createContext (java.awt.image.ColorModel srcColorModel, java.awt.image.ColorModel dstColorModel, RenderingHints hints);
// Public Methods Overriding Object
public boolean equals (Object obj);
public int hashCode ();
}

Hierarchy: Object-->AlphaComposite(Composite)

Returned By: AlphaComposite.getInstance()

Type Of: AlphaComposite.{Clear, DstIn, DstOut, DstOver, Src, SrcIn, SrcOut, SrcOver}

AWTErrorJava 1.0
java.awtserializable error PJ1.1

Signals that an error has occurred in the java.awt package.

public class AWTError extends Error {
// Public Constructors
public AWTError (String msg);
}

Hierarchy: Object-->Throwable(Serializable)-->Error-->AWTError

AWTEventJava 1.1
java.awtserializable event PJ1.1

This abstract class serves as the root event type for all AWT events in Java 1.1 and supersedes the Event class that was used in Java 1.0.

Each AWTEvent has a source object, as all EventObject objects do. You can query the source of an event with the inherited getSource() method. The AWTEvent class adds an event type, or ID, for every AWT event. Use getID() to query the type of an event. Subclasses of AWTEvent define various constants for this type field.

The various _MASK constants are used by applets and custom components that call the enableEvents() method of Component to receive various event types without having to register EventListener objects.

public abstract class AWTEvent extends java.util.EventObject {
// Public Constructors
public AWTEvent (Event event);
public AWTEvent (Object source, int id);
// Public Constants
public static final long ACTION_EVENT_MASK ; =128
public static final long ADJUSTMENT_EVENT_MASK ; =256
public static final long COMPONENT_EVENT_MASK ; =1
public static final long CONTAINER_EVENT_MASK ; =2
public static final long FOCUS_EVENT_MASK ; =4
1.2public static final long INPUT_METHOD_EVENT_MASK ; =2048
public static final long ITEM_EVENT_MASK ; =512
public static final long KEY_EVENT_MASK ; =8
public static final long MOUSE_EVENT_MASK ; =16
public static final long MOUSE_MOTION_EVENT_MASK ; =32
public static final int RESERVED_ID_MAX ; =1999
public static final long TEXT_EVENT_MASK ; =1024
public static final long WINDOW_EVENT_MASK ; =64
// Public Instance Methods
public int getID ();
public String paramString ();
// Public Methods Overriding EventObject
public String toString ();
// Protected Methods Overriding Object
1.2protected void finalize () throws Throwable;
// Protected Instance Methods
protected void consume ();
protected boolean isConsumed ();
// Protected Instance Fields
protected boolean consumed ;
protected int id ;
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->AWTEvent

Subclasses: java.awt.event.ActionEvent, java.awt.event.AdjustmentEvent, java.awt.event.ComponentEvent, java.awt.event.InputMethodEvent, java.awt.event.InvocationEvent, java.awt.event.ItemEvent, java.awt.event.TextEvent, javax.swing.event.AncestorEvent, javax.swing.event.InternalFrameEvent

Passed To: Too many methods to list.

Returned By: Component.coalesceEvents(), EventQueue.{getNextEvent(), peekEvent()}

AWTEventMulticasterJava 1.1
java.awtPJ1.1

AWTEventMulticaster is a convenience class used when writing a custom AWT component. It provides an easy way to maintain a list of AWT EventListener objects and notify the listeners on that list when an event occurs.

AWTEventMulticaster implements each of the event listener interfaces defined in the java.awt.event package, which means that an AWTEventMulticaster object can serve as any desired type of event listener. (It also means that the class defines quite a few methods.) AWTEventMulticaster implements what amounts to a linked list of EventListener objects. When you invoke one of the EventListener methods of an AWTEventMulticaster, it invokes the same method on all of the EventListener objects in the linked list.

Rather than instantiate an AWTEventMulticaster object directly, you use the static add() and remove() methods of the class to add and remove EventListener objects from the linked list. Calling add() or remove() returns an AWTEventMulticaster with the appropriate EventListener object registered or deregistered. Using an AWTEventMulticaster is somewhat non-intuitive, so here is some example code that shows its use:

public class MyList extends Component {   // a class that sends ItemEvents
  // The head of a linked list of AWTEventMulticaster objects
  protected ItemListener listener = null;
  public void addItemListener(ItemListener l) {      // add a listener
    listener = AWTEventMulticaster.add(listener, l);
  }
  public void removeItemListener(ItemListener l) {   // remove a listener
    listener = AWTEventMulticaster.remove(listener, l);
  }
  protected void fireItemEvent(ItemEvent e) {        // notify all listeners
    if (listener != null) listener.itemStateChanged(e);
  }
  // The rest of the class goes here
}
public class AWTEventMulticaster implements java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.ComponentListener, java.awt.event.ContainerListener, java.awt.event.FocusListener, java.awt.event.InputMethodListener, java.awt.event.ItemListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.TextListener, java.awt.event.WindowListener {
// Protected Constructors
protected AWTEventMulticaster (java.util.EventListener a, java.util.EventListener b);
// Public Class Methods
public static java.awt.event.ActionListener add (java.awt.event.ActionListener a, java.awt.event.ActionListener b);
public static java.awt.event.AdjustmentListener add (java.awt.event.AdjustmentListener a, java.awt.event.AdjustmentListener b);
public static java.awt.event.ComponentListener add (java.awt.event.ComponentListener a, java.awt.event.ComponentListener b);
public static java.awt.event.ContainerListener add (java.awt.event.ContainerListener a, java.awt.event.ContainerListener b);
public static java.awt.event.FocusListener add (java.awt.event.FocusListener a, java.awt.event.FocusListener b);
1.2public static java.awt.event.InputMethodListener add (java.awt.event.InputMethodListener a, java.awt.event.InputMethodListener b);
public static java.awt.event.ItemListener add (java.awt.event.ItemListener a, java.awt.event.ItemListener b);
public static java.awt.event.KeyListener add (java.awt.event.KeyListener a, java.awt.event.KeyListener b);
public static java.awt.event.MouseListener add (java.awt.event.MouseListener a, java.awt.event.MouseListener b);
public static java.awt.event.MouseMotionListener add (java.awt.event.MouseMotionListener a, java.awt.event.MouseMotionListener b);
public static java.awt.event.TextListener add (java.awt.event.TextListener a, java.awt.event.TextListener b);
public static java.awt.event.WindowListener add (java.awt.event.WindowListener a, java.awt.event.WindowListener b);
public static java.awt.event.ActionListener remove (java.awt.event.ActionListener l, java.awt.event.ActionListener oldl);
public static java.awt.event.AdjustmentListener remove (java.awt.event.AdjustmentListener l, java.awt.event.AdjustmentListener oldl);
public static java.awt.event.ComponentListener remove (java.awt.event.ComponentListener l, java.awt.event.ComponentListener oldl);
public static java.awt.event.ContainerListener remove (java.awt.event.ContainerListener l, java.awt.event.ContainerListener oldl);
public static java.awt.event.FocusListener remove (java.awt.event.FocusListener l, java.awt.event.FocusListener oldl);
1.2public static java.awt.event.InputMethodListener remove (java.awt.event.InputMethodListener l, java.awt.event.InputMethodListener oldl);
public static java.awt.event.ItemListener remove (java.awt.event.ItemListener l, java.awt.event.ItemListener oldl);
public static java.awt.event.KeyListener remove (java.awt.event.KeyListener l, java.awt.event.KeyListener oldl);
public static java.awt.event.MouseListener remove (java.awt.event.MouseListener l, java.awt.event.MouseListener oldl);
public static java.awt.event.MouseMotionListener remove (java.awt.event.MouseMotionListener l, java.awt.event.MouseMotionListener oldl);
public static java.awt.event.TextListener remove (java.awt.event.TextListener l, java.awt.event.TextListener oldl);
public static java.awt.event.WindowListener remove (java.awt.event.WindowListener l, java.awt.event.WindowListener oldl);
// Protected Class Methods
protected static java.util.EventListener addInternal (java.util.EventListener a, java.util.EventListener b);
protected static java.util.EventListener removeInternal (java.util.EventListener l, java.util.EventListener oldl);
protected static void save (java.io.ObjectOutputStream s, String k, java.util.EventListener l) throws java.io.IOException;
// Methods Implementing ActionListener
public void actionPerformed (java.awt.event.ActionEvent e);
// Methods Implementing AdjustmentListener
public void adjustmentValueChanged (java.awt.event.AdjustmentEvent e);
// Methods Implementing ComponentListener
public void componentHidden (java.awt.event.ComponentEvent e);
public void componentMoved (java.awt.event.ComponentEvent e);
public void componentResized (java.awt.event.ComponentEvent e);
public void componentShown (java.awt.event.ComponentEvent e);
// Methods Implementing ContainerListener
public void componentAdded (java.awt.event.ContainerEvent e);
public void componentRemoved (java.awt.event.ContainerEvent e);
// Methods Implementing FocusListener
public void focusGained (java.awt.event.FocusEvent e);
public void focusLost (java.awt.event.FocusEvent e);
// Methods Implementing InputMethodListener
1.2public void caretPositionChanged (java.awt.event.InputMethodEvent e);
1.2public void inputMethodTextChanged (java.awt.event.InputMethodEvent e);
// Methods Implementing ItemListener
public void itemStateChanged (java.awt.event.ItemEvent e);
// Methods Implementing KeyListener
public void keyPressed (java.awt.event.KeyEvent e);
public void keyReleased (java.awt.event.KeyEvent e);
public void keyTyped (java.awt.event.KeyEvent e);
// Methods Implementing MouseListener
public void mouseClicked (java.awt.event.MouseEvent e);
public void mouseEntered (java.awt.event.MouseEvent e);
public void mouseExited (java.awt.event.MouseEvent e);
public void mousePressed (java.awt.event.MouseEvent e);
public void mouseReleased (java.awt.event.MouseEvent e);
// Methods Implementing MouseMotionListener
public void mouseDragged (java.awt.event.MouseEvent e);
public void mouseMoved (java.awt.event.MouseEvent e);
// Methods Implementing TextListener
public void textValueChanged (java.awt.event.TextEvent e);
// Methods Implementing WindowListener
public void windowActivated (java.awt.event.WindowEvent e);
public void windowClosed (java.awt.event.WindowEvent e);
public void windowClosing (java.awt.event.WindowEvent e);
public void windowDeactivated (java.awt.event.WindowEvent e);
public void windowDeiconified (java.awt.event.WindowEvent e);
public void windowIconified (java.awt.event.WindowEvent e);
public void windowOpened (java.awt.event.WindowEvent e);
// Protected Instance Methods
protected java.util.EventListener remove (java.util.EventListener oldl);
protected void saveInternal (java.io.ObjectOutputStream s, String k) throws java.io.IOException;
// Protected Instance Fields
protected final java.util.EventListener a ;
protected final java.util.EventListener b ;
}

Hierarchy: Object-->AWTEventMulticaster(java.awt.event.ActionListener(java.util.EventListener),java.awt.event.AdjustmentListener(java.util.EventListener),java.awt.event.ComponentListener(java.util.EventListener),java.awt.event.ContainerListener(java.util.EventListener),java.awt.event.FocusListener(java.util.EventListener),java.awt.event.InputMethodListener(java.util.EventListener),java.awt.event.ItemListener(java.util.EventListener),java.awt.event.KeyListener(java.util.EventListener),java.awt.event.MouseListener(java.util.EventListener),java.awt.event.MouseMotionListener(java.util.EventListener),java.awt.event.TextListener(java.util.EventListener),java.awt.event.WindowListener(java.util.EventListener))

AWTExceptionJava 1.0
java.awtserializable checked PJ1.1

Signals that an exception has occurred in the java.awt package.

public class AWTException extends Exception {
// Public Constructors
public AWTException (String msg);
}

Hierarchy: Object-->Throwable(Serializable)-->Exception-->AWTException

Thrown By: Cursor.getSystemCustomCursor()

AWTPermissionJava 1.2
java.awtserializable permission

This class encapsulates permissions for performing various AWT-related operations; applications do not typically use it. The name, or target, of a permission should be one of the following values: "accessClipboard", "accessEventQueue", "listenToAllAWTEvents", or "showWindowWithoutWarningBanner". Alternatively, a name of "*" implies all of these values. AWTPermission does not use actions, so the actions argument to the constructor should be null.

public final class AWTPermission extends java.security.BasicPermission {
// Public Constructors
public AWTPermission (String name);
public AWTPermission (String name, String actions);
}

Hierarchy: Object-->java.security.Permission(java.security.Guard,Serializable)-->java.security.BasicPermission(Serializable)-->AWTPermission

BasicStrokeJava 1.2
java.awt

This class defines properties that control how lines are drawn. By default, lines are one-pixel wide and solid. To change these attributes, pass a BasicStroke (or another implementation of Stroke) to the setStroke() method of a Graphics2D object. BasicStroke supports the following line attribute properties:

lineWidth

The thickness of the line.

endCap

The end cap style of the line. CAP_BUTT specifies that a line ends exactly at its end points, without caps. CAP_SQUARE causes a line to end with square caps that extend beyond the end points by a distance equal to one-half of the line width. CAP_ROUND specifies that a line ends with round caps with a radius of one-half of the line width.

lineJoin

The join style when two line segments meet at the vertex of a shape. JOIN_MITER specifies that the outside edges of the two line segments are extended as far as necessary until they intersect. JOIN_BEVEL causes the outside corners of the vertex to be joined with a straight line. JOIN_ROUND specifies that the vertex is rounded with a curve that has a radius of half the line width.

miterLimit

The maximum length of the miter used to connect two intersecting line segments. When two lines intersect at an acute angle and the line join style is JOIN_MITER, the length of the miter gets progressively longer as the angle between the lines gets smaller. This property imposes a maximum length on the miter; beyond this length, the miter is squared off.

dashArray

The pattern of dashes and spaces that make up a dashed line. This attribute is an array, where the first element and all the additional odd elements specify the lengths of dashes. The second element and all the additional even elements specify the lengths of the spaces. When the dash pattern is complete, it starts over at the beginning of the array, of course.

dashPhase

The distance into the dash pattern that line drawing begins. Note that this value is not an index into the dash array, but a distance. For example, if you've specified a dash of length 5 followed by a space of length 3 and want to begin your line with the space rather than the dash, you set this property to 5.

See Stroke for a discussion of how line drawing is performed in Java 2D.

public class BasicStroke implements Stroke {
// Public Constructors
public BasicStroke ();
public BasicStroke (float width);
public BasicStroke (float width, int cap, int join);
public BasicStroke (float width, int cap, int join, float miterlimit);
public BasicStroke (float width, int cap, int join, float miterlimit, float[ ] dash, float dash_phase);
// Public Constants
public static final int CAP_BUTT ; =0
public static final int CAP_ROUND ; =1
public static final int CAP_SQUARE ; =2
public static final int JOIN_BEVEL ; =2
public static final int JOIN_MITER ; =0
public static final int JOIN_ROUND ; =1
// Property Accessor Methods (by property name)
public float[ ] getDashArray (); default:null
public float getDashPhase (); default:0.0
public int getEndCap (); default:2
public int getLineJoin (); default:0
public float getLineWidth (); default:1.0
public float getMiterLimit (); default:10.0
// Methods Implementing Stroke
public Shape createStrokedShape (Shape s);
// Public Methods Overriding Object
public boolean equals (Object obj);
public int hashCode ();
}

Hierarchy: Object-->BasicStroke(Stroke)

BorderLayoutJava 1.0
java.awtserializable layout manager PJ1.1

A LayoutManager that arranges components that have been added to their Container (using the Container.add() method) with the names "North", "South", "East", "West", and "Center". These named components are arranged along the edges and in the center of the container. The hgap and vgap arguments to the BorderLayout constructor specify the desired horizontal and vertical spacing between adjacent components.

In Java 1.1, five constants were defined to represent these strings. In Java 1.2, an additional four constants have been added to represent the four sides of the container in a way that is independent of writing direction. For example, BEFORE_LINE_BEGINS is the same as WEST in locales where text is drawn from left to right, but is the same as EAST in locales where text is drawn from right to left.

Note that an application should never call the LayoutManager methods of this class directly; the Container for which the BorderLayout is registered does this.

In Java 1.1, five constants were defined to represent these strings. In Java 1.2, an additional four constants have been added to represent the four sides of the container in a way that is independent of writing direction. For example, BEFORE_LINE_BEGINS is the same as WEST in locales where text is drawn from left to right but is the same as EAST in locales where text is drawn right to left.

public class BorderLayout implements LayoutManager2, Serializable {
// Public Constructors
public BorderLayout ();
public BorderLayout (int hgap, int vgap);
// Public Constants
1.2public static final String AFTER_LAST_LINE ; ="Last"
1.2public static final String AFTER_LINE_ENDS ; ="After"
1.2public static final String BEFORE_FIRST_LINE ; ="First"
1.2public static final String BEFORE_LINE_BEGINS ; ="Before"
1.1public static final String CENTER ; ="Center"
1.1public static final String EAST ; ="East"
1.1public static final String NORTH ; ="North"
1.1public static final String SOUTH ; ="South"
1.1public static final String WEST ; ="West"
// Property Accessor Methods (by property name)
1.1public int getHgap (); default:0
1.1public void setHgap (int hgap);
1.1public int getVgap (); default:0
1.1public void setVgap (int vgap);
// Methods Implementing LayoutManager
public void layoutContainer (Container target);
public Dimension minimumLayoutSize (Container target);
public Dimension preferredLayoutSize (Container target);
public void removeLayoutComponent (Component comp);
// Methods Implementing LayoutManager2
1.1public void addLayoutComponent (Component comp, Object constraints);
1.1public float getLayoutAlignmentX (Container parent);
1.1public float getLayoutAlignmentY (Container parent);
1.1public void invalidateLayout (Container target); empty
1.1public Dimension maximumLayoutSize (Container target);
// Public Methods Overriding Object
public String toString ();
// Deprecated Public Methods
#public void addLayoutComponent (String name, Component comp); Implements:LayoutManager
}

Hierarchy: Object-->BorderLayout(LayoutManager2(LayoutManager),Serializable)

ButtonJava 1.0
java.awtserializable AWT component PJ1.1

This class represents a GUI push button that displays a specified textual label. Use setActionCommand() to specify an identifying string that is included in the ActionEvent events generated by the button.

public class Button extends Component {
// Public Constructors
public Button ();
public Button (String label);
// Event Registration Methods (by event name)
1.1public void addActionListener (java.awt.event.ActionListener l); synchronized
1.1public void removeActionListener (java.awt.event.ActionListener l); synchronized
// Property Accessor Methods (by property name)
1.1public String getActionCommand (); default:""
1.1public void setActionCommand (String command);
public String getLabel (); default:""
public void setLabel (String label);
// Public Methods Overriding Component
public void addNotify ();
// Protected Methods Overriding Component
protected String paramString ();
1.1protected void processEvent (AWTEvent e);
// Protected Instance Methods
1.1protected void processActionEvent (java.awt.event.ActionEvent e);
}

Hierarchy: Object-->Component(java.awt.image.ImageObserver,MenuContainer,Serializable)-->Button

Passed To: Toolkit.createButton()

CanvasJava 1.0
java.awtserializable AWT component PJ1.1

A Component that does no default drawing or event handling on its own. You can subclass it to display any kind of drawing or image and handle any kind of user input event. Canvas inherits the event-handling methods of its superclass. In Java 1.1, you can also subclass Component directly to create a lightweight component, instead of having to subclass Canvas.

public class Canvas extends Component {
// Public Constructors
public Canvas ();
1.2public Canvas (GraphicsConfiguration config);
// Public Methods Overriding Component
public void addNotify ();
public void paint (Graphics g);
}

Hierarchy: Object-->Component(java.awt.image.ImageObserver,MenuContainer,Serializable)-->Canvas

Passed To: Toolkit.createCanvas()

CardLayoutJava 1.0
java.awtserializable layout manager PJ1.1

A LayoutManager that makes each of the components it manages as large as the container and ensures that only one is visible at a time. The standard LayoutManager methods are called by the Container object and should not be called directly by applet or application code. first(), last(), next(), previous(), and show() make a particular Component in the Container visible. The names with which the components are added to the container are used only by the show() method.

public class CardLayout implements LayoutManager2, Serializable {
// Public Constructors
public CardLayout ();
public CardLayout (int hgap, int vgap);
// Property Accessor Methods (by property name)
1.1public int getHgap (); default:0
1.1public void setHgap (int hgap);
1.1public int getVgap (); default:0
1.1public void setVgap (int vgap);
// Public Instance Methods
public void first (Container parent);
public void last (Container parent);
public void next (Container parent);
public void previous (Container parent);
public void show (Container parent, String name);
// Methods Implementing LayoutManager
public void layoutContainer (Container parent);
public Dimension minimumLayoutSize (Container parent);
public Dimension preferredLayoutSize (Container parent);
public void removeLayoutComponent (Component comp);
// Methods Implementing LayoutManager2
1.1public void addLayoutComponent (Component comp, Object constraints);
1.1public float getLayoutAlignmentX (Container parent);
1.1public float getLayoutAlignmentY (Container parent);
1.1public void invalidateLayout (Container target); empty
1.1public Dimension maximumLayoutSize (Container target);
// Public Methods Overriding Object
public String toString ();
// Deprecated Public Methods
#public void addLayoutComponent (String name, Component comp); Implements:LayoutManager
}

Hierarchy: Object-->CardLayout(LayoutManager2(LayoutManager),Serializable)

CheckboxJava 1.0
java.awtserializable AWT component PJ1.1

This class represents a GUI checkbox with a textual label. The Checkbox maintains a boolean state--whether it is checked or not. The checkbox may optionally be part of a CheckboxGroup that enforces radio button behavior.

public class Checkbox extends Component implements ItemSelectable {
// Public Constructors
public Checkbox ();
public Checkbox (String label);
1.1public Checkbox (String label, boolean state);
public Checkbox (String label, CheckboxGroup group, boolean state);
1.1public Checkbox (String label, boolean state, CheckboxGroup group);
// Event Registration Methods (by event name)
1.1public void addItemListener (java.awt.event.ItemListener l); Implements:ItemSelectable synchronized
1.1public void removeItemListener (java.awt.event.ItemListener l); Implements:ItemSelectable synchronized
// Property Accessor Methods (by property name)
public CheckboxGroup getCheckboxGroup (); default:null
public void setCheckboxGroup (CheckboxGroup g);
public String getLabel (); default:""
public void setLabel (String label);
1.1public Object[ ] getSelectedObjects (); Implements:ItemSelectable default:null
public boolean getState (); default:false
public void setState (boolean state);
// Methods Implementing ItemSelectable
1.1public void addItemListener (java.awt.event.ItemListener l); synchronized
1.1public Object[ ] getSelectedObjects (); default:null
1.1public void removeItemListener (java.awt.event.ItemListener l); synchronized
// Public Methods Overriding Component
public void addNotify ();
// Protected Methods Overriding Component
protected String paramString ();
1.1protected void processEvent (AWTEvent e);
// Protected Instance Methods
1.1protected void processItemEvent (java.awt.event.ItemEvent e);
}

Hierarchy: Object-->Component(java.awt.image.ImageObserver,MenuContainer,Serializable)-->Checkbox(ItemSelectable)

Passed To: CheckboxGroup.{setCurrent(), setSelectedCheckbox()}, Toolkit.createCheckbox()

Returned By: CheckboxGroup.{getCurrent(), getSelectedCheckbox()}

CheckboxGroupJava 1.0
java.awtserializable PJ1.1

A CheckboxGroup object enforces mutual exclusion (also known as radio button behavior) among any number of Checkbox buttons. A Checkbox component can specify a CheckboxGroup object when created or with its setCheckboxGroup() method. If a Checkbox within a CheckboxGroup object is selected, the CheckboxGroup ensures that the previously selected Checkbox becomes unselected.

public class CheckboxGroup implements Serializable {
// Public Constructors
public CheckboxGroup ();
// Property Accessor Methods (by property name)
1.1public Checkbox getSelectedCheckbox (); default:null
1.1public void setSelectedCheckbox (Checkbox box);
// Public Methods Overriding Object
public String toString ();
// Deprecated Public Methods
#public Checkbox getCurrent (); default:null
#public void setCurrent (Checkbox box); synchronized
}

Hierarchy: Object-->CheckboxGroup(Serializable)

Passed To: Checkbox.{Checkbox(), setCheckboxGroup()}, java.awt.peer.CheckboxPeer.setCheckboxGroup()

Returned By: Checkbox.getCheckboxGroup()

CheckboxMenuItemJava 1.0
java.awtserializable AWT component PJ1.1(opt)

This class represents a checkbox with a textual label in a GUI menu. It maintains a boolean state--whether it is checked or not. See also MenuItem.

public class CheckboxMenuItem extends MenuItem implements ItemSelectable {
// Public Constructors
1.1public CheckboxMenuItem ();
public CheckboxMenuItem (String label);
1.1public CheckboxMenuItem (String label, boolean state);
// Event Registration Methods (by event name)
1.1public void addItemListener (java.awt.event.ItemListener l); Implements:ItemSelectable synchronized
1.1public void removeItemListener (java.awt.event.ItemListener l); Implements:ItemSelectable synchronized
// Property Accessor Methods (by property name)
1.1public Object[ ] getSelectedObjects (); Implements:ItemSelectable synchronized default:null
public boolean getState (); default:false
public void setState (boolean b); synchronized
// Methods Implementing ItemSelectable
1.1public void addItemListener (java.awt.event.ItemListener l); synchronized
1.1public Object[ ] getSelectedObjects (); synchronized default:null
1.1public void removeItemListener (java.awt.event.ItemListener l); synchronized
// Public Methods Overriding MenuItem
public void addNotify ();
public String paramString ();
// Protected Methods Overriding MenuItem
1.1protected void processEvent (AWTEvent e);
// Protected Instance Methods
1.1protected void processItemEvent (java.awt.event.ItemEvent e);
}

Hierarchy: Object-->MenuComponent(Serializable)-->MenuItem-->CheckboxMenuItem(ItemSelectable)

Passed To: Toolkit.createCheckboxMenuItem()

ChoiceJava 1.0
java.awtserializable AWT component PJ1.1

This class represents an option menu or dropdown list. The addItem() method adds an item with the specified label to a Choice menu. getSelectedIndex() returns the numerical position of the selected item in the menu, while getSelectedItem() returns the label of the selected item.

public class Choice extends Component implements ItemSelectable {
// Public Constructors
public Choice ();
// Event Registration Methods (by event name)
1.1public void addItemListener (java.awt.event.ItemListener l); Implements:ItemSelectable synchronized
1.1public void removeItemListener (java.awt.event.ItemListener l); Implements:ItemSelectable synchronized
// Property Accessor Methods (by property name)
1.1public int getItemCount (); default:0
public int getSelectedIndex (); default:-1
public String getSelectedItem (); synchronized default:null
1.1public Object[ ] getSelectedObjects (); Implements:ItemSelectable synchronized default:null
// Public Instance Methods
1.1public void add (String item);
public void addItem (String item);
public String getItem (int index);
1.1public void insert (String item, int index);
1.1public void remove (String item);
1.1public void remove (int position);
1.1public void removeAll ();
public void select (String str); synchronized
public void select (int pos); synchronized
// Methods Implementing ItemSelectable
1.1public void addItemListener (java.awt.event.ItemListener l); synchronized
1.1public Object[ ] getSelectedObjects (); synchronized default:null
1.1public void removeItemListener (java.awt.event.ItemListener l); synchronized
// Public Methods Overriding Component
public void addNotify ();
// Protected Methods Overriding Component
protected String paramString ();
1.1protected void processEvent (AWTEvent e);
// Protected Instance Methods
1.1protected void processItemEvent (java.awt.event.ItemEvent e);
// Deprecated Public Methods
#public int countItems ();
}

Hierarchy: Object-->Component(java.awt.image.ImageObserver,MenuContainer,Serializable)-->Choice(ItemSelectable)

Passed To: Toolkit.createChoice()

ColorJava 1.0
java.awtserializable PJ1.1

This class describes a color in terms of the individual components of that color. These components are either float values that range between 0 and 1 or 8-bit integers that range from 0 to 255. Prior to Java 1.2, only the RGB (red, green, blue) color space was supported. With the advent of Java 2D, the Color class has been extended to support alpha transparency and arbitrary java.awt.color.ColorSpace objects. In addition, the Java 1.2 Color class implements the Paint interface and is used to perform Java 2D drawing and filling operations that use solid colors.

Color objects can be obtained in a number of ways. The Color() constructors allow color components to be directly specified. The class also defines several color constants. The SystemColor subclass defines other useful Color constants that are related to standard colors used on the system desktop. The static methods HSBtoRGB() and RGBtoHSB() convert between the RGB color space and the HSB (hue, saturation, brightness) color space and can be used to create colors specified using the more intuitive HSB color components. brighter() and darker() return variants on the current color and are useful for creating shading effects.

An RGB color can be expressed as a 24-bit number, where the top 8 bits specifies the red component, the middle 8 bits specifies the green component, and the low 8 bits specifies the blue component. Colors are often represented using a string representation of this 24-bit number. It is particularly common to use a hexadecimal representation for a color, since it keeps the red, green, and blue components distinct. For example, the string "0xFF0000" represents a bright red color: the red component has a value of 255, and both the green and blue components are 0. The static decode() method converts color strings encoded in this way to Color objects. Each getColor() method looks up the specified key in the system properties list and then decodes the value and returns the resulting Color or the specified default color, if no color is found in the properties list.

getRGB() returns the red, green, and blue components of a color as a 24-bit number. getRed(), getBlue(), getGreen(), and getAlpha() return the individual components of a color as integers. getComponents() is a generalized method that returns the color and transparency components of a color in a float array, using an optionally specified ColorSpace. getColorComponents() is similar but returns only the color components, not the transparency component. getRGBComponents() returns the color and alpha components as float values using the RGB color space. getRGBColorComponents() does the same but does not return the alpha component. Each of these methods either fills in the elements of a float[] array you provide or allocates one of its own, if you pass null.

public class Color implements Paint, Serializable {
// Public Constructors
public Color (int rgb);
1.2public Color (int rgba, boolean hasalpha);
1.2public Color (java.awt.color.ColorSpace cspace, float[ ] components, float alpha);
public Color (float r, float g, float b);
public Color (int r, int g, int b);
1.2public Color (int r, int g, int b, int a);
1.2public Color (float r, float g, float b, float a);
// Public Constants
public static final Color black ;
public static final Color blue ;
public static final Color cyan ;
public static final Color darkGray ;
public static final Color gray ;
public static final Color green ;
public static final Color lightGray ;
public static final Color magenta ;
public static final Color orange ;
public static final Color pink ;
public static final Color red ;
public static final Color white ;
public static final Color yellow ;
// Public Class Methods
1.1public static Color decode (String nm) throws NumberFormatException;
public static Color getColor (String nm);
public static Color getColor (String nm, Color v);
public static Color getColor (String nm, int v);
public static Color getHSBColor (float h, float s, float b);
public static int HSBtoRGB (float hue, float saturation, float brightness);
public static float[ ] RGBtoHSB (int r, int g, int b, float[ ] hsbvals);
// Property Accessor Methods (by property name)
1.2public int getAlpha ();
public int getBlue ();
1.2public java.awt.color.ColorSpace getColorSpace ();
public int getGreen ();
public int getRed ();
public int getRGB ();
1.2public int getTransparency (); Implements:Transparency
// Public Instance Methods
public Color brighter ();
public Color darker ();
1.2public float[ ] getColorComponents (float[ ] compArray);
1.2public float[ ] getColorComponents (java.awt.color.ColorSpace cspace, float[ ] compArray);
1.2public float[ ] getComponents (float[ ] compArray);
1.2public float[ ] getComponents (java.awt.color.ColorSpace cspace, float[ ] compArray);
1.2public float[ ] getRGBColorComponents (float[ ] compArray);
1.2public float[ ] getRGBComponents (float[ ] compArray);
// Methods Implementing Paint
1.2public PaintContext createContext (java.awt.image.ColorModel cm, Rectangle r, java.awt.geom.Rectangle2D r2d, java.awt.geom.AffineTransform xform, RenderingHints hints); synchronized
// Methods Implementing Transparency
1.2public int getTransparency ();
// Public Methods Overriding Object
public boolean equals (Object obj);
public int hashCode ();
public String toString ();
}

Hierarchy: Object-->Color(Paint(Tra