Generated by
JDiff

java.awt Documentation Differences

This file contains all the changes in documentation in the package java.awt as colored differences. Deletions are shown like this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

Class AWTError

Thrown when a serious Abstract Window Toolkit error has occurred. @version 1.12 0213 12/0203/0001 @author Arthur van Hoff

Class AWTEvent

The root event class for all AWT events. This class and its subclasses supercede the original java.awt.Event class. Subclasses of this root AWTEvent class defined outside of the java.awt.event package should define event ID values greater than the value defined by RESERVED_ID_MAX.

The event masks defined in this class are needed by Component subclasses which are using Component.enableEvents() to select for event types not selected by registered listeners. If a listener is registered on a component the appropriate event mask is already set internally by the component.

The masks are also used to specify to which types of events an AWTEventListener should listen. The masks are bitwise-ORed together and passed to Toolkit.addAWTEventListener. @see Component#enableEvents @see Toolkit#addAWTEventListener @see java.awt.event.ActionEvent @see java.awt.event.AdjustmentEvent @see java.awt.event.ComponentEvent @see java.awt.event.ContainerEvent @see java.awt.event.FocusEvent @see java.awt.event.InputMethodEvent @see java.awt.event.InvocationEvent @see java.awt.event.ItemEvent @see java.awt.event.HierarchyEvent @see java.awt.event.KeyEvent @see java.awt.event.MouseEvent @see java.awt.event.MouseWheelEvent @see java.awt.event.PaintEvent @see java.awt.event.TextEvent @see java.awt.event.WindowEvent @author Carl Quinn @author Amy Fowler @version 1.38 0248 12/1103/0001 @since 1.1

Class AWTEvent, String paramString()

Returns a string representing the state of this eventEvent. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null. @return a string representation of this event.

Class AWTEventMulticaster

A class which implements efficient and thread-safe multi-cast event dispatching for the AWT events defined in the java.awt.event package. This class will manage an immutable structure consisting of a chain of event listeners and will dispatch events to those listeners. Because the structure is immutable it is safe to use this API to add/remove listeners during the process of an event dispatch operation. An example of how this class could be used to implement a new component which fires "action" events:
 public myComponent extends Component { ActionListener actionListener = null; public synchronized void addActionListener(ActionListener l) { actionListener = AWTEventMulticaster.add(actionListener l); } public synchronized void removeActionListener(ActionListener l) { actionListener = AWTEventMulticaster.remove(actionListener l); } public void processEvent(AWTEvent e) { // when event occurs which causes "action" semantic if (actionListener = null) { actionListener.actionPerformed(new ActionEvent()); } } 
@author John Rose @author Amy Fowler @version 1.25 0231 12/0203/0001 @since 1.1

Class AWTException

Signals that an Absract Window Toolkit exception has occurred. @version 1.13 0214 12/0203/0001 @author Arthur van Hoff

Class AWTPermission

This class is for AWT permissions. An AWTPermission contains a target name but no actions list; you either have the named permission or you don't.

The target name is the name of the AWT permission (see below). The naming convention follows the hierarchical property naming convention. Also an asterisk could be used to represent all AWT permissions.

The following table lists all the possible AWTPermission target names and for each provides a description of what the permission allows and a discussion of the risks of granting code the permission.

Permission Target Name What the Permission Allows Risks of Allowing this Permission
accessClipboard Posting and retrieval of information to and from the AWT clipboard This would allow malfeasant code to share potentially sensitive or confidential information.
accessEventQueue Access to the AWT event queue After retrieving the AWT event queue malicious code may peek at and even remove existing events from its event queue as well as post bogus events which may purposefully cause the application or applet to misbehave in an insecure manner.
listenToAllAWTEvents Listen to all AWT events system-wide After adding an AWT event listener malicious code may scan all AWT events dispatched in the system allowing it to read all user input (such as passwords). Each AWT event listener is called from within the context of that event queue's EventDispatchThread so if the accessEventQueue permission is also enabled malicious code could modify the contents of AWT event queues system-wide causing the application or applet to misbehave in an insecure manner.
showWindowWithoutWarningBanner Display of a window without also displaying a banner warning that the window was created by an applet Without this warning an applet may pop up windows without the user knowing that they belong to an applet. Since users may make security-sensitive decisions based on whether or not the window belongs to an applet (entering a username and password into a dialog box for example) disabling this warning banner may allow applets to trick the user into entering such information.
readDisplayPixels Readback of pixels from the display screen Interfaces such as the java.awt.Composite interface or the java.awt.Robot class allow arbitrary code to examine pixels on the display enable malicious code to snoop on the activities of the user.
createRobot Create java.awt.Robot objects The java.awt.Robot object allows code to generate native-level mouse and keyboard events as well as read the screen. It could allow malicious code to control the system run other programs read the display and deny mouse and keyboard access to the user.
fullScreenExclusive Enter full-screen exclusive mode Entering full-screen exclusive mode allows direct access to low-level graphics card memory. This could be used to spoof the system since the program is in direct control of rendering.
@see java.security.BasicPermission @see java.security.Permission @see java.security.Permissions @see java.security.PermissionCollection @see java.lang.SecurityManager @version 1.18 0221 12/0203/0001 @author Marianne Mueller @author Roland Schemers

Class AWTPermission, constructor AWTPermission(String)

Creates a new AWTPermission with the specified name. The name is the symbolic name of the AWTPermission such as "topLevelWindow" "systemClipboard" etc. An asterisk may be used to indicate all AWT permissions. @param name the name of the AWTPermission.
Class AWTPermission, constructor AWTPermission(String, String)

Creates a new AWTPermission object with the specified name. The name is the symbolic name of the AWTPermission and the actions Stringstring is currently unused and should be null. This constructor exists for use by the Policy object to instantiate new Permissionpermission objects. @param name the name of the AWTPermission. @param actions should be null.

Class ActiveEvent

An interface for events that know how dispatch themselves. By implementing this interface an event can be placed upon the event queue and its dispatch() method will be called when the event is dispatched using the EventDispatchThread.

This is a very useful mechanism for avoiding deadlocks. If a thread is executing in a critical section (i.e. it has entered one or more monitors) calling other synchronized code may cause deadlocks. To avoid the potential deadlocks an ActiveEvent can be created to run the second section of code at later time. If there is contention on the monitor the second thread will simply block until the first thread has finished its work and exited its monitors.

For security reasons it is often desirable to use an ActiveEvent to avoid calling untrusted code from a critical thread. For instance peer implementations can use this facility to avoid making calls into user code from a system thread. Doing so avoids potential deadlocks and denial-of-service attacks. @author Timothy Prinzing @version 1.9 0210 12/0203/0001 @since 1.2


Class Adjustable

The interface for objects which have an adjustable numeric value contained within a bounded range of values. @version 1.10 0214 12/0203/0001 @author Amy Fowler @author Tim Prinzing
Class Adjustable, void addAdjustmentListener(AdjustmentListener)

AddAdds a listener to recievereceive adjustment events when the value of the adjustable object changes. @param l the listener to recievereceive events @see AdjustmentEvent
Class Adjustable, int getBlockIncrement()

Gets the block value increment for the adjustable object. @return the block value increment for the adjustable object
Class Adjustable, int getMaximum()

Gets the maximum value of the adjustable object. @return the maximum value of the adjustable object
Class Adjustable, int getMinimum()

Gets the minimum value of the adjustable object. @return the minimum value of the adjustable object
Class Adjustable, int getOrientation()

Gets the orientation of the adjustable object. @return the orientation of the adjustable object; either HORIZONTAL VERTICAL or NO_ORIENTATION
Class Adjustable, int getUnitIncrement()

Gets the unit value increment for the adjustable object. @return the unit value increment for the adjustable object
Class Adjustable, int getValue()

Gets the current value of the adjustable object. @return the current value of the adjustable object
Class Adjustable, int getVisibleAmount()

Gets the length of the propertionalproportional indicator. @return the length of the proportional indicator
Class Adjustable, void setVisibleAmount(int)

Sets the length of the proportionlproportional indicator of the adjustable object. @param v the length of the indicator
Class Adjustable, int HORIZONTAL

TheIndicates that the Adjustable has horizontal orientation.
Class Adjustable, int VERTICAL

TheIndicates that the Adjustable has vertical orientation.

Class AlphaComposite

This AlphaComposite class implements the basic alpha compositing rules for combining source and destination pixels to achieve blending and transparency effects with graphics and images. The rules implemented by this class are a subsetthe set of the Porter-Duff rules described in T. Porter and T. Duff "Compositing Digital Images" SIGGRAPH 84 253-259.

If any input does not have an alpha channel an alpha value of 1.0 which is completely opaque is assumed for all pixels. A constant alpha value can also be specified to be multiplied with the alpha value of the source pixels.

The following abbreviations are used in the description of the rules:

The color and alpha components produced by the compositing operation are calculated as follows:

 Cd = Cs*Fs + Cd*Fd Ad = As*Fs + Ad*Fd 
where Fs and Fd are specified by each rule. The above equations assume that both source and destination pixels have the color components premultiplied by the alpha component. Similarly the equations expressed in the definitions of compositing rules below assume premultiplied alpha.

For performance reasons it is preferrable that Rasters passed to the compose method of a CompositeContext object created by the AlphaComposite class have premultiplied data. If either source or destination Rasters are not premultiplied however appropriate conversions are performed before and after the compositing operation.

The alpha resulting from the compositing operation is stored in the destination if the destination has an alpha channel. Otherwise the resulting color is divided by the resulting alpha before being stored in the destination and the alpha is discarded. If the alpha value is 0.0 the color values are set to 0.0. @see Composite @see CompositeContext @version 10 Feb 1997

Class AlphaComposite, AlphaComposite getInstance(int)

Creates an AlphaComposite object with the specified rule. @param rule the compositing rule @throws IllegalArgumentException if rule is not one of the following: #CLEAR #SRC #DST #SRC_OVER #DST_OVER #SRC_IN #DST_IN #SRC_OUT or #DST_OUT #SRC_ATOP #DST_ATOP or #XOR

Class BasicStroke

The BasicStroke class defines a basic set of rendering attributes for the outlines of graphics primitives which are rendered with a Graphics2D object that has its Stroke attribute set to this BasicStroke. The rendering attributes defined by BasicStroke describe the shape of the mark made by a pen drawn along the outline of a Shape and the decorations applied at the ends and joins of path segments of the Shape. These rendering attributes include:
width
The pen width measured perpendicularly to the pen trajectory.
end caps
The decoration applied to the ends of unclosed subpaths and dash segments. Subpaths that start and end on the same point are still considered unclosed if they do not have a CLOSE segment. See SEG_CLOSE for more information on the CLOSE segment. The three different decorations are: #CAP_BUTT #CAP_ROUND and #CAP_SQUARE
line joins
The decoration applied at the intersection of two path segments and at the intersection of the endpoints of a subpath that is closed using SEG_CLOSE The three different decorations are: #JOIN_BEVEL #JOIN_MITER and #JOIN_ROUND
miter limit
The limit to trim a line join that has a JOIN_MITER decoration. A line join is trimmed when the ratio of miter length to stroke width is greater than the miterlimit value. The miter length is the diagonal length of the miter which is the distance between the inside corner and the outside corner of the intersection. The smaller the angle formed by two line segments the longer the miter length and the sharper the angle of intersection. The default miterlimit value of 10.0f causes all angles less than 11 degrees to be trimmed. Trimming miters converts the decoration of the line join to bevel.
dash attributes
The definition of how to make a dash pattern by alternating between opaque and transparent sections.
All attributes that specify measurements and distances controlling the shape of the returned outline are measured in the same coordinate system as the original unstroked Shape argument. When a Graphics2D object uses a Stroke object to redefine a path during the execution of one of its draw methods the geometry is supplied in its original form before the Graphics2D transform attribute is applied. Therefore attributes such as the pen width are interpreted in the user space coordinate system of the Graphics2D object and are subject to the scaling and shearing effects of the user-space-to-device-space transform in that particular Graphics2D. For example the width of a rendered shape's outline is determined not only by the width attribute of this BasicStroke but also by the transform attribute of the Graphics2D object. Consider this code:
// sets the Graphics2D object's Tranform attribute g2d.scale(10 10); // sets the Graphics2D object's Stroke attribute g2d.setStroke(new BasicStroke(1.5f));
Assuming there are no other scaling transforms added to the Graphics2D object the resulting line will be approximately 15 pixels wide. As the example code demonstrates a floating-point line offers better precision especially when large transforms are used with a Graphics2D object. When a line is diagonal the exact width depends on how the rendering pipeline chooses which pixels to fill as it traces the theoretical widened outline. The choice of which pixels to turn on is affected by the antialiasing attribute because the antialiasing rendering pipeline can choose to color partially-covered pixels.

For more information on the user space coordinate system and the rendering process see the Graphics2D class comments. @see Graphics2D @version 1.37 0212/0903/01 @author Jim Graham


Class BorderLayout

A border layout lays out a container arranging and resizing its components to fit in five regions: north south east west and center. Each region may contain no more than one component and is identified by a corresponding constant: NORTH SOUTH EAST WEST and CENTER. When adding a component to a container with a border layout use one of these five constants for example:
 Panel p = new Panel(); p.setLayout(new BorderLayout()); p.add(new Button("Okay") BorderLayout.SOUTH); 
As a convenience BorderLayout interprets the absence of a string specification the same as the constant CENTER:
 Panel p2 = new Panel(); p2.setLayout(new BorderLayout()); p2.add(new TextArea()); // Same as p.add(new TextArea() BorderLayout.CENTER); 

In addition BorderLayout supports fourthe relative positioning constants BEFORE_FIRSTPAGE_LINESTART AFTERPAGE_LAST_LINEEND BEFORE_LINE_BEGINSSTART and AFTER_LINE_ENDSEND. In a container whose ComponentOrientation is set to ComponentOrientation.LEFT_TO_RIGHT these constants map to NORTH SOUTH WEST and EAST respectively.

MixingFor compatibility with previous releases BorderLayout also includes the two typesrelative positioning ofconstants BEFORE_FIRST_LINE AFTER_LAST_LINE BEFORE_LINE_BEGINS and AFTER_LINE_ENDS. These are equivalent to PAGE_START PAGE_END LINE_START and LINE_END respectively. For consistency with the relative positioning constants used by other components the latter constants are preferred.

Mixing both absolute and relative positioning constants can lead to unpredicable results. If you use both types the relative constants will take precedence. For example if you add components using both the NORTH and BEFORE_FIRSTPAGE_LINESTART constants in a container whose orientation is LEFT_TO_RIGHT only the BEFORE_FIRSTPAGE_LINESTART will be layed out.

NOTE: Currently (in the Java 2 platform v1.2) BorderLayout does not support vertical orientations. The isVertical setting on the container's ComponentOrientation is not respected.

The components are laid out according to their preferred sizes and the constraints of the container's size. The NORTH and SOUTH components may be stretched horizontally; the EAST and WEST components may be stretched vertically; the CENTER component may stretch both horizontally and vertically to fill any space left over.

Here is an example of five buttons in an applet laid out using the BorderLayout layout manager:

The code for this applet is as follows:


 import java.awt.*; import java.applet.Applet; public class buttonDir extends Applet { public void init() { setLayout(new BorderLayout()); add(new Button("North") BorderLayout.NORTH); add(new Button("South") BorderLayout.SOUTH); add(new Button("East") BorderLayout.EAST); add(new Button("West") BorderLayout.WEST); add(new Button("Center") BorderLayout.CENTER); } } 

@version 1.45 0249 12/0203/0001 @author Arthur van Hoff @see java.awt.Container#add(String Component) @see java.awt.ComponentOrientation @since JDK1.0

Class BorderLayout, String AFTER_LAST_LINE

The componentSynonym for comes after thePAGE_END. last line of theExists for compatibility with layout'sprevious contentversions. For Western top-to-bottom left-to-rightPAGE_END orientations this is equivalent to SOUTHpreferred. @see java.awt.Component#getComponentOrientationPAGE_END @since 1.2
Class BorderLayout, String AFTER_LINE_ENDS

TheSynonym component goes at the end of the line direction for the layoutLINE_END. For WesternExists top-to-bottomfor left-to-rightcompatibility orientations thiswith previous isversions. equivalentLINE_END to EASTis preferred. @see java.awt.Component#getComponentOrientationLINE_END @since 1.2
Class BorderLayout, String BEFORE_FIRST_LINE

The componentSynonym for comes before thePAGE_START. first line of theExists for compatibility with layout'sprevious contentversions. For Western top-to-bottom left-to-rightPAGE_START orientations this is equivalent to NORTHpreferred. @see java.awt.Component#getComponentOrientationPAGE_START @since 1.2
Class BorderLayout, String BEFORE_LINE_BEGINS

TheSynonym component goes at the beginning of the line direction for the layoutLINE_START. For WesternExists top-to-bottomfor left-to-rightcompatibility orientations thiswith previous isversions. equivalentLINE_START to WESTis preferred. @see java.awt.Component#getComponentOrientationLINE_START @since 1.2

Class Button

This class creates a labeled button. The application can cause some action to happen when the button is pushed. This image depicts three views of a "Quit" button as it appears under the Solaris operating system:

The first view shows the button as it appears normally. The second view shows the button when it has input focus. Its outline is darkened to let the user know that it is an active object. The third view shows the button when the user clicks the mouse over the button and thus requests that an action be performed.

The gesture of clicking on a button with the mouse is associated with one instance of ActionEvent which is sent out when the mouse is both pressed and released over the button. If an application is interested in knowing when the button has been pressed but not released as a separate gesture it can specialize processMouseEvent or it can register itself as a listener for mouse events by calling addMouseListener. Both of these methods are defined by Component the abstract superclass of all components.

When a button is pressed and released AWT sends an instance of ActionEvent to the button by calling processEvent on the button. The button's processEvent method receives all events for the button; it passes an action event along by calling its own processActionEvent method. The latter method passes the action event on to any action listeners that have registered an interest in action events generated by this button.

If an application wants to perform some action based on a button being pressed and released it should implement ActionListener and register the new listener to receive events from this button by calling the button's addActionListener method. The application can make use of the button's action command as a messaging protocol. @version 1.58 0368 12/1403/0001 @author Sami Shaio @see java.awt.event.ActionEvent @see java.awt.event.ActionListener @see java.awt.Component#processMouseEvent @see java.awt.Component#addMouseListener @since JDK1.0

Class Button, constructor Button()

Constructs a Button with no label. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless
Class Button, constructor Button(String)

Constructs a Button with the specified label. @param label A string label for the button. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless
Class Button, void addActionListener(ActionListener)

Adds the specified action listener to receive action events from this button. Action events occur when a user presses or releases the mouse over this button. If l is null no exception is thrown and no action is performed. @param l the action listener @see java.awt.event.ActionListener#removeActionListener @see #getActionListeners @see java.awt.Button#removeActionListenerevent.ActionListener @since JDK1.1
Class Button, AccessibleContext getAccessibleContext()

Gets the AccessibleContext associated with this Button. For buttons the AccessibleContext takes the form of an AccessibleAWTButton. A new AccessibleAWTButton instance is created if necessary. @return an AccessibleAWTButton that serves as the AccessibleContext of this Button @beaninfo expert: true description: The AccessibleContext associated with this Button.
Class Button, EventListener[] getListeners(Class)

ReturnReturns an array of all the listenersobjects that were addedcurrently registered as toFooListeners the Buttonupon this withButton. addXXXListener()FooListeners where XXX isare registered using the nameaddFooListener ofmethod.

You can specify the listenerType argument. For example to get all ofwith a class literal such as theFooListener.class. ActionListener(s)For forexample theyou can query givena Button b onefor its wouldaction writelisteners with the following code:

 ActionListener[] als = (ActionListener[])(b.getListeners(ActionListener.class)) ;
If no such listenerlisteners exist list exists thenthis method returns an empty array is returned. @param listenerType Typethe type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener @return allan array of theall objects registered as FooListeners on this button or an empty array if no such listeners of the specifiedhave been added type@exception supported byClassCastException if thislistenerType
buttondoesn't specify a class or interface that implements java.util.EventListener @see #getActionListeners @since 1.3
Class Button, String paramString()

Returns the parametera string representing the state of this buttonButton. This stringmethod is usefulintended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null. @return the parameter string of this button.
Class Button, void processActionEvent(ActionEvent)

Processes action events occurring on this button by dispatching them to any registered ActionListener objects.

This method is not called unless action events are enabled for this button. Action events are enabled when one of the following occurs:

Note that if the event parameter is null the behavior is unspecified and may result in an exception. @param e the action event. @see java.awt.event.ActionListener @see java.awt.Button#addActionListener @see java.awt.Component#enableEvents @since JDK1.1

Class Button, void processEvent(AWTEvent)

Processes events on this button. If an event is an instance of ActionEvent this method invokes the processActionEvent method. Otherwise it invokes processEvent on the superclass.

Note that if the event parameter is null the behavior is unspecified and may result in an exception. @param e the event. @see java.awt.event.ActionEvent @see java.awt.Button#processActionEvent @since JDK1.1

Class Button, void removeActionListener(ActionListener)

Removes the specified action listener so that it no longer receives action events from this button. Action events occur when a user presses or releases the mouse over this button. If l is null no exception is thrown and no action is performed. @param l the action listener @see java.awt.event.ActionListener#addActionListener @see #getActionListeners @see java.awt.Button#addActionListenerevent.ActionListener @since JDK1.1

Class Canvas

A Canvas component represents a blank rectangular area of the screen onto which the application can draw or from which the application can trap input events from the user.

An application must subclass the Canvas class in order to get useful functionality such as creating a custom component. The paint method must be overridden in order to perform custom graphics on the canvas. @version 1.28 0332 12/1503/0001 @author Sami Shaio @since JDK1.0

Class Canvas, void paint(Graphics)

ThisPaints method is called to repaint this canvas.

Most applications that subclass Canvas should override this method in order to perform some useful operation. The paint method provided by Canvas redraws this(typically canvas'scustom rectangle inpainting of the background colorcanvas). The graphics context's origin (0default  0)operation is the top-leftsimply corner of thisto clear the canvas. ItsApplications clipping region is the area of the contextthat override this method need not call super.paint(g). @param g the graphicsspecified Graphics context. @see java.awt.#update(Graphics) @see Component#paint(Graphics)

Class Canvas, void update(Graphics)

Updates this componentcanvas.

The AWT callsThis themethod updateis methodcalled in response to a call to repaintupdate or paint. You can assume that theThe backgroundcanvas is notfirst cleared. The updatemethod of Component does the following: Clears this component by filling it with the background color. Sets the color of the graphics context to be the foregroundand color of thisthen completely redrawn component.by Callscalling this componentcanvas's paint method to completely redraw this component. Note: The origin of the graphics context itsapplications that override this method should either call super.update(0  0g) coordinate point is the top-left corner of this component. The clipping regionor ofincorporate the graphicsfunctionality context is thedescribed bounding rectangle of this componentabove into their own code. @param g the specified context to use forGraphics updating.context @see java.awt.Component#paint(Graphics) @see java.awt.Component#repaintupdate(Graphics) @since JDK1.0


Class CardLayout

A CardLayout object is a layout manager for a container. It treats each component in the container as a card. Only one card is visible at a time and the container acts as a stack of cards. The first component added to a CardLayout object is the visible component when the container is first displayed.

The ordering of cards is determined by the container's own internal ordering of its component objects. CardLayout defines a set of methods that allow an application to flip through these cards sequentially or to show a specified card. The CardLayouCardLayout#addLayoutComponent method can be used to associate a string identifier with a given card for fast random access. @version 1.30 0635 12/3003/0001 @author Arthur van Hoff @see java.awt.Container @since JDK1.0

Class CardLayout, void removeLayoutComponent(Component)

Removes the specified component from the layout. If the card was visible on top the next card underneath it is shown. @param comp the component to be removed. @see java.awt.Container#remove(java.awt.Component) @see java.awt.Container#removeAll()

Class Checkbox

A check box is a graphical component that can be in either an "on" (true) or "off" (false) state. Clicking on a check box changes its state from "on" to "off " or from "off" to "on."

The following code example creates a set of check boxes in a grid layout:


 setLayout(new GridLayout(3 1)); add(new Checkbox("one" null true)); add(new Checkbox("two")); add(new Checkbox("three")); 

This image depicts the check boxes and grid layout created by this code example:

The button labeled one is in the "on" state and the other two are in the "off" state. In this example which uses the GridLayout class the states of the three check boxes are set independently.

Alternatively several check boxes can be grouped together under the control of a single object using the CheckboxGroup class. In a check box group at most one button can be in the "on" state at any given time. Clicking on a check box to turn it on forces any other check box in the same group that is on into the "off" state. @version 1.59 0372 12/1403/0001 @author Sami Shaio @see java.awt.GridLayout @see java.awt.CheckboxGroup @since JDK1.0

Class Checkbox, constructor Checkbox()

Creates a check box with no label. The state of this check box is set to "off " and it is not part of any check box group. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless
Class Checkbox, constructor Checkbox(String)

Creates a check box with the specified label. The state of this check box is set to "off " and it is not part of any check box group. @param label a string label for this check box or null for no label. @exception HeadlessException if GraphicsEnvironment.isHeadless returns true @see java.awt.GraphicsEnvironment#isHeadless
Class Checkbox, constructor Checkbox(String, CheckboxGroup, boolean)

ConstructsCreates a Checkboxcheck box with the specified label set toin the specified statecheck box group and inset to the specified check box groupstate. @param label a string label for this check box or null for no label. @param group a check box group for this check box or null for no group. @param state the initial state of this check box. @exception HeadlessException if GraphicsEnvironment.isHeadless returns true @see java.awt.GraphicsEnvironment#isHeadless @since JDK1.1
Class Checkbox, constructor Checkbox(String, boolean)

Creates a check box with the specified label and sets the specified state. This check box is not part of any check box group. @param label a string label for this check box or null for no label. @param state the initial state of this check box @exception HeadlessException if GraphicsEnvironment.isHeadless returns true @see java.awt.GraphicsEnvironment#isHeadless
Class Checkbox, constructor Checkbox(String, boolean, CheckboxGroup)

CreatesConstructs a check boxCheckbox with the specified label inset to the specified check box groupstate and set toin the specified statecheck box group. @param label a string label for this check box or null for no label. @param state the initial state of this check box. @param group a check box group for this check box or null for no group. @exception HeadlessException if GraphicsEnvironment.isHeadless returns true @see java.awt.GraphicsEnvironment#isHeadless @since JDK1.1
Class Checkbox, void addItemListener(ItemListener)

Adds the specified item listener to receive item events from this check box. Item events are sent to listeners in response to user input but not in response to calls to setState(). If l is null no exception is thrown and no action is performed. @param l the item listener @see java.awt.event.ItemEvent#removeItemListener @see #getItemListeners @see #setState @see java.awt.event.ItemListenerItemEvent @see java.awt.Checkbox#removeItemListenerevent.ItemListener @since JDK1.1
Class Checkbox, CheckboxGroup getCheckboxGroup()

Determines this check box's group. @return this check box's group or null if the check box is not part of a check box group. @see java.awt.Checkbox#setCheckboxGroup
Class Checkbox, String getLabel()

Gets the label of this check box. @return the label of this check box or null if this check box has no label. @see java.awt.Checkbox#setLabel
Class Checkbox, EventListener[] getListeners(Class)

ReturnReturns an array of all the listenersobjects that were addedcurrently registered as toFooListeners the Checkboxupon this withCheckbox. addXXXListener()FooListeners where XXX isare registered using the nameaddFooListener ofmethod.

You can specify the listenerType argument. For example to get all ofwith a class literal such as theFooListener.class. ItemListener(s)For forexample theyou can query givena Checkbox c onefor its woulditem writelisteners with the following code:

 ItemListener[] ils = (ItemListener[])(c.getListeners(ItemListener.class)) ;
If no such listenerlisteners exist list exists thenthis method returns an empty array is returned. @param listenerType Typethe type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener @return allan array of theall objects registered as FooListeners on this checkbox or an empty array if no such listeners of the specifiedhave been added type@exception supported byClassCastException if thislistenerType
checkboxdoesn't specify a class or interface that implements java.util.EventListener @see #getItemListeners @since 1.3
Class Checkbox, boolean getState()

Determines whether this check box is in the "on" or "off" state. The boolean value true indicates the "on" state and false indicates the "off" state. @return the state of this check box as a boolean value. @see java.awt.Checkbox#setState
Class Checkbox, String paramString()

Returns the parametera string representing the state of this check boxCheckbox. This stringmethod is usefulintended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null. @return the parameter string of this check box.
Class Checkbox, void processEvent(AWTEvent)

Processes events on this check box. If the event is an instance of ItemEvent this method invokes the processItemEvent method. Otherwise it calls its superclass's processEvent method.

Note that if the event parameter is null the behavior is unspecified and may result in an exception. @param e the event. @see java.awt.event.ItemEvent @see java.awt.Checkbox#processItemEvent @since JDK1.1

Class Checkbox, void processItemEvent(ItemEvent)

Processes item events occurring on this check box by dispatching them to any registered ItemListener objects.

This method is not called unless item events are enabled for this component. Item events are enabled when one of the following occurs:

Note that if the event parameter is null the behavior is unspecified and may result in an exception. @param e the item event. @see java.awt.event.ItemEvent @see java.awt.event.ItemListener @see java.awt.Checkbox#addItemListener @see java.awt.Component#enableEvents @since JDK1.1

Class Checkbox, void removeItemListener(ItemListener)

Removes the specified item listener so that the item listener no longer receives item events from this check box. If l is null no exception is thrown and no action is performed. @param l the item listener @see java.awt.event.ItemEvent#addItemListener @see #getItemListeners @see java.awt.event.ItemListenerItemEvent @see java.awt.Checkbox#addItemListenerevent.ItemListener @since JDK1.1
Class Checkbox, void setCheckboxGroup(CheckboxGroup)

Sets this check box's group to be the specified check box group. If this check box is already in a different check box group it is first taken out of that group. @param g the new check box group or null to remove this check box from any check box group. @see java.awt.Checkbox#getCheckboxGroup
Class Checkbox, void setLabel(String)

Sets this check box's label to be the string argument. @param label a string to set as the new label or null for no label. @see java.awt.Checkbox#getLabel
Class Checkbox, void setState(boolean)

Sets the state of this check box to the specified state. The boolean value true indicates the "on" state and false indicates the "off" state.

Note that this method should be primarily used to initialize the state of the checkbox. Programmatically setting the state of the checkbox will not trigger an ItemEvent. The only way to trigger an ItemEvent is by user interaction. @param state the boolean state of the check box. @see java.awt.Checkbox#getState


Class CheckboxGroup

The CheckboxGroup class is used to group together a set of Checkbox buttons.

Exactly one check box button in a CheckboxGroup can be in the "on" state at any given time. Pushing any button sets its state to "on" and forces any other button that is in the "on" state into the "off" state.

The following code example produces a new check box group with three check boxes:


 setLayout(new GridLayout(3 1)); CheckboxGroup cbg = new CheckboxGroup(); add(new Checkbox("one" cbg true)); add(new Checkbox("two" cbg false)); add(new Checkbox("three" cbg false)); 

This image depicts the check box group created by this example:

@version 1.29 0230 12/0203/0001 @author Sami Shaio @see java.awt.Checkbox @since JDK1.0


Class CheckboxMenuItem

This class represents a check box that can be included in a menu. ClickingSelecting on the check box in the menu changes its state from "on" to "off" or from "off" to "on."

The following picture depicts a menu which contains an instance of CheckBoxMenuItem:

The item labeled Check shows a check box menu item in its "off" state.

When a check box menu item is selected AWT sends an item event to the item. Since the event is an instance of ItemEvent the processEvent method examines the event and passes it along to processItemEvent. The latter method redirects the event to any ItemListener objects that have registered an interest in item events generated by this menu item. @version 1.49 0362 12/1403/0001 @author Sami Shaio @see java.awt.event.ItemEvent @see java.awt.event.ItemListener @since JDK1.0

Class CheckboxMenuItem, constructor CheckboxMenuItem()

Create a check box menu item with an empty label. The item's state is initially set to "off." @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @since JDK1.1
Class CheckboxMenuItem, constructor CheckboxMenuItem(String)

Create a check box menu item with the specified label. The item's state is initially set to "off." @param label a string label for the check box menu item or null for an unlabeled menu item. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless
Class CheckboxMenuItem, constructor CheckboxMenuItem(String, boolean)

Create a check box menu item with the specified label and state. @param label a string label for the check box menu item or null for an unlabeled menu item. @param state the initial state of the menu item where true indicates "on" and false indicates "off." @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @since JDK1.1
Class CheckboxMenuItem, void addItemListener(ItemListener)

Adds the specified item listener to receive item events from this check box menu item. Item events are sent in response to user actions but not in response to calls to setState(). If l is null no exception is thrown and no action is performed. @param l the item listener @see java.awt.event.ItemEvent#removeItemListener @see #getItemListeners @see #setState @see java.awt.event.ItemListenerItemEvent @see java.awt.Choice#removeItemListenerevent.ItemListener @since JDK1.1
Class CheckboxMenuItem, EventListener[] getListeners(Class)

ReturnReturns an array of all the listenersobjects that were addedcurrently registered as toFooListeners the CheckboxMenuItemupon this withCheckboxMenuItem. addXXXListener()FooListeners where XXX isare registered using the nameaddFooListener ofmethod.

You can specify the listenerType argument. For example to get all ofwith a class literal such as theFooListener.class. ItemListener(s)For forexample theyou can givenquery a CheckboxMenuItem c onefor its item listeners with wouldthe following writecode:

 ItemListener[] ils = (ItemListener[])(c.getListeners(ItemListener.class)) ;
If no such listenerlisteners exist list exists thenthis method returns an empty array is returned. @param listenerType Typethe type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener @return allan array of theall objects registered as FooListeners on this checkbox menuitem or an empty array if no such listeners of the specifiedhave been added type@exception supported byClassCastException if thislistenerType
checkboxdoesn't menuspecify itema class or interface that implements java.util.EventListener @see #getItemListeners @since 1.3
Class CheckboxMenuItem, boolean getState()

Determines whether the state of this check box menu item is "on" or "off." @return the state of this check box menu item where true indicates "on" and false indicates "off." @see java.awt.CheckboxMenuItem#setState
Class CheckboxMenuItem, String paramString()

Returns the parametera string representing the state of this check box menu itemCheckBoxMenuItem. This stringmethod is usefulintended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null. @return the parameter string of this check box menu item.
Class CheckboxMenuItem, void processEvent(AWTEvent)

Processes events on this check box menu item. If the event is an instance of ItemEvent this method invokes the processItemEvent method. If the event is not an item event it invokes processEvent on the superclass.

Check box menu items currently support only item events.

Note that if the event parameter is null the behavior is unspecified and may result in an exception. @param e the event @see java.awt.event.ItemEvent @see java.awt.CheckboxMenuItem#processItemEvent @since JDK1.1

Class CheckboxMenuItem, void processItemEvent(ItemEvent)

Processes item events occurring on this check box menu item by dispatching them to any registered ItemListener objects.

This method is not called unless item events are enabled for this menu item. Item events are enabled when one of the following occurs:

Note that if the event parameter is null the behavior is unspecified and may result in an exception. @param e the item event. @see java.awt.event.ItemEvent @see java.awt.event.ItemListener @see java.awt.CheckboxMenuItem#addItemListener @see java.awt.MenuItem#enableEvents @since JDK1.1

Class CheckboxMenuItem, void removeItemListener(ItemListener)

Removes the specified item listener so that it no longer receives item events from this check box menu item. If l is null no exception is thrown and no action is performed. @param l the item listener @see java.awt.event.ItemEvent#addItemListener @see #getItemListeners @see java.awt.event.ItemListenerItemEvent @see java.awt.Choice#addItemListenerevent.ItemListener @since JDK1.1
Class CheckboxMenuItem, void setState(boolean)

Sets this check box menu item to the specifed state. The boolean value true indicates "on" while false indicates "off." @param

Note bthat this method should be primarily used to initialize the booleanstate of the check box menu item. Programmatically setting the state of thisthe check box menu item will not trigger an ItemEvent. The only way to trigger an ItemEvent is by user interaction. @param b true if the check box menu item is on otherwise false @see java.awt.CheckboxMenuItem#getState


Class Choice

The Choice class presents a pop-up menu of choices. The current choice is displayed as the title of the menu.

The following code example produces a pop-up menu:


 Choice ColorChooser = new Choice(); ColorChooser.add("Green"); ColorChooser.add("Red"); ColorChooser.add("Blue"); 

After this choice menu has been added to a panel it appears as follows in its normal state:

In the picture "Green" is the current choice. Pushing the mouse button down on the object causes a menu to appear with the current choice highlighted.

Some native platforms do not support arbitrary resizing of Choice components and the behavior of setSize()/getSize() is bound by such limitations. Native GUI Choice components' size are often bound by such attributes as font size and length of items contained within the Choice.

@version 1.64 0378 12/1403/0001 @author Sami Shaio @author Arthur van Hoff @since JDK1.0

Class Choice, constructor Choice()

Creates a new choice menu. The menu initially has no items in it.

By default the first item added to the choice menu becomes the selected item until a different selection is made by the user by calling one of the select methods. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.ChoiceGraphicsEnvironment#isHeadless @see #select(int) @see java.awt.Choice#select(java.lang.String)

Class Choice, void add(String)

Adds an item to this Choice menu. @param item the item to be added @exception NullPointerException if the item's value is null. @since JDK1.1
Class Choice, void addItem(String)

Obsolete as of Java 2 platform v1.1. Please use the add method instead.

Adds an item to this Choice menu. @param item the item to be added @exception NullPointerException Ifif the item's value is equal to null.

Class Choice, void addItemListener(ItemListener)

Adds the specified item listener to receive item events from this Choice menu. Item events are sent in response to user input but not in response to calls to select. If l is null no exception is thrown and no action is performed. @param l the item listener. @see java.awt.event.ItemEvent#removeItemListener @see #getItemListeners @see #select @see java.awt.event.ItemListenerItemEvent @see java.awt.Choice#removeItemListenerevent.ItemListener @since JDK1.1
Class Choice, void addNotify()

Creates the Choice's peer. This peer allows us to change the look of the Choice without changing its functionality. @see java.awt.Toolkit#createChoice(java.awt.Choice) @see java.awt.Component#getToolkit()
Class Choice, AccessibleContext getAccessibleContext()

Gets the AccessibleContext associated with this Choice. For Choice components the AccessibleContext takes the form of an AccessibleAWTChoice. A new AccessibleAWTChoice instance is created if necessary. @return an AccessibleAWTChoice that serves as the AccessibleContext of this Choice
Class Choice, String getItem(int)

Gets the string at the specified index in this Choice menu. @param index the index at which to begin. @see java.awt.Choice#getItemCount
Class Choice, int getItemCount()

Returns the number of items in this Choice menu. @seereturn java.awt.the number of items in this Choice menu @see #getItem @since JDK1.1
Class Choice, EventListener[] getListeners(Class)

ReturnReturns an array of all the listenersobjects that were addedcurrently registered as toFooListeners the Choiceupon this withChoice. addXXXListener()FooListeners where XXX isare registered using the nameaddFooListener ofmethod.

You can specify the listenerType argument. For example to get all ofwith a class literal such as theFooListener.class. ItemListener(s)For forexample theyou can query givena Choice c onefor its woulditem writelisteners with the following code:

 ItemListener[] ils = (ItemListener[])(c.getListeners(ItemListener.class)) ;
If no such listenerlisteners exist list exists thenthis method returns an empty array is returned. @param listenerType Typethe type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener @return allan array of theall objects registered as FooListeners on this choice or an empty array if no such listeners of the specifiedhave been added type@exception supported byClassCastException if thislistenerType
choicedoesn't specify a class or interface that implements java.util.EventListener @see #getItemListeners @since 1.3
Class Choice, String getSelectedItem()

Gets a representation of the current choice as a string. @return a string representation of the currently selected item in this choice menu. @see java.awt.Choice#getSelectedIndex
Class Choice, Object[] getSelectedObjects()

Returns an array (length 1) containing the currently selected item. If this choice has no items returns null. @see ItemSelectable
Class Choice, void insert(String, int)

Inserts the item into this choice at the specified position. Existing items at an index greater than or equal to index are shifted up by one to accommodate the new item. If index is greater than or equal to the number of items in this choice item is added to the end of this choice.

If the item is the first one being added to the choice then the item becomes selected. Otherwise if the selected item was one of the items shifted the first item in the choice becomes the selected item. If the selected item was no among those shifted it remains the selected item. @param item the non-null item to be inserted @param index the position at which the item should be inserted @exception IllegalArgumentException if index is less than 0.

Class Choice, String paramString()

Returns the parametera string representing the state of this choiceChoice menu. This stringmethod is usefulintended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null. @return the parameter string of this Choice menu.
Class Choice, void processEvent(AWTEvent)

Processes events on this choice. If the event is an instance of ItemEvent it invokes the processItemEvent method. Otherwise it calls its superclass's processEvent method.

Note that if the event parameter is null the behavior is unspecified and may result in an exception. @param e the event. @see java.awt.event.ItemEvent @see java.awt.Choice#processItemEvent @since JDK1.1

Class Choice, void processItemEvent(ItemEvent)

Processes item events occurring on this Choice menu by dispatching them to any registered ItemListener objects.

This method is not called unless item events are enabled for this component. Item events are enabled when one of the following occurs:

Note that if the event parameter is null the behavior is unspecified and may result in an exception. @param e the item event. @see java.awt.event.ItemEvent @see java.awt.event.ItemListener @see java.awt.Choice#addItemListener @see java.awt.Component#enableEvents @since JDK1.1

Class Choice, void remove(String)

RemoveRemoves the first occurrence of item from the Choice menu. If the item being removed is the currently selected item then the first item in the choice becomes the selected item. Otherwise the currently selected item remains selected (and the selected index is updated accordingly). @param item the item to remove from this Choice menu. @exception IllegalArgumentException if the item doesn't exist in the choice menu. @since JDK1.1
Class Choice, void remove(int)

Removes an item from the choice menu at the specified position. If the item being removed is the currently selected item then the first item in the choice becomes the selected item. Otherwise the currently selected item remains selected (and the selected index is @param position the position of the item. @throws IndexOutOfBoundsException if the specified position is out of bounds @since JDK1.1
Class Choice, void removeAll()

Removes all items from the choice menu. @see java.awt.Choice#remove @since JDK1.1
Class Choice, void removeItemListener(ItemListener)

Removes the specified item listener so that it no longer receives item events from this Choice menu. If l is null no exception is thrown and no action is performed. @param l the item listener. @see java.awt.event.ItemEvent#addItemListener @see #getItemListeners @see java.awt.event.ItemListenerItemEvent @see java.awt.Choice#addItemListenerevent.ItemListener @since JDK1.1
Class Choice, void select(String)

Sets the selected item in this Choice menu to be the item whose name is equal to the specified string. If more than one item matches (is equal to) the specified string the one with the smallest index is selected.

Note that this method should be primarily used to initially select an item in this component. Programmatically calling this method will not trigger an ItemEvent. The only way to trigger an ItemEvent is by user interaction. @param str the specified string @see java.awt.Choice#getSelectedItem @see java.awt.Choice#getSelectedIndex

Class Choice, void select(int)

Sets the selected item in this Choice menu to be the item at the specified position.

Note that this method should be primarily used to initially select an item in this component. Programmatically calling this method will not trigger an ItemEvent. The only way to trigger an ItemEvent is by user interaction. @param pos the positon of the selected item. @exception IllegalArgumentException if the specified position is invalid.greater than the number of items or less than zero @see java.awt.Choice#getSelectedItem @see java.awt.Choice#getSelectedIndex


Class Component

A component is an object having a graphical representation that can be displayed on the screen and that can interact with the user. Examples of components are the buttons checkboxes and scrollbars of a typical graphical user interface.

The Component class is the abstract superclass of the nonmenu-related Abstract Window Toolkit components. Class Component can also be extended directly to create a lightweight component. A lightweight component is a component that is not associated with a native opaque window.

Serialization

It is important to note that only AWT listeners which conform to the Serializable protocol will be saved when the object is stored. If an AWT object has listeners that aren't marked serializable they will be dropped at writeObject time. Developers will need as always to consider the implications of making an object serializable. One situation to watch out for is this:
 import java.awt.*; import java.awt.event.*; import java.io.Serializable; class MyApp implements ActionListener Serializable { BigObjectThatShouldNotBeSerializedWithAButton bigOne; Button aButton = new Button(); MyApp() { // Oops now aButton has a listener with a reference // to bigOne aButton.addActionListener(this); } public void actionPerformed(ActionEvent e) { System.out.println("Hello There"); } } 
In this example serializing aButton by itself will cause MyApp and everything it refers to to be serialized as well. The problem is that the listener is serializable by coincidence not by design. To separate the decisions about MyApp and the ActionListener being serializable one can use a nested class as in the following example:
 import java.awt.*; import java.awt.event.*; import java.io.Serializable; class MyApp java.io.Serializable { BigObjectThatShouldNotBeSerializedWithAButton bigOne; Button aButton = new Button(); class MyActionListener implements ActionListener { public void actionPerformed(ActionEvent e) { System.out.println("Hello There"); } } MyApp() { aButton.addActionListener(new MyActionListener()); } } 
@version 1.265 02330 12/2803/0001 @author Arthur van Hoff @author Sami Shaio

Class Component.AccessibleAWTComponent, boolean contains(Point)

Checks whether the specified point is within this object's bounds where the point's x and y coordinates are defined to be relative to the coordinate system of the object. @param p the Point relative to the coordinate system of the object @return true if object contains Point; otherwise false
Class Component.AccessibleAWTComponent, Accessible getAccessibleAt(Point)

Returns the Accessible child if one exists contained at the local coordinate Point. Otherwise returns null. @param p Thethe point defining the top-left corner of the Accessible given in the coordinate space of the object's parent. @return the Accessible if it exists at the specified location; else null
Class Component.AccessibleAWTComponent, Accessible getAccessibleChild(int)

ReturnReturns the nth Accessible child of the object. @param i zero-based index of child @return the nth Accessible child of the object
Class Component.AccessibleAWTComponent, int getAccessibleChildrenCount()

Returns the number of accessible children in the object. If all of the children of this object implement Accessible thanthen this method should return the number of children of this object. @return the number of accessible children in the object.
Class Component.AccessibleAWTComponent, AccessibleComponent getAccessibleComponent()

GetGets the AccessibleComponent associated with this object if one exists. Otherwise return null. @return the component
Class Component.AccessibleAWTComponent, String getAccessibleDescription()

GetGets the accessible description of this object. This should be a concise localized description of what this object is - what is its meaning to the user. If the object has a tooltip the tooltip text may be an appropriate string to return assuming it contains a concise description of the object (instead of just the name of the object - e.g. a "Save" icon on a toolbar that had "save" as the tooltip text shouldn't return the tooltip text as the description but something like "Saves the current text document" instead). @return the localized description of the object -- can be null if this object does not have a description @see javax.accessibility.AccessibleContext#setAccessibleDescription
Class Component.AccessibleAWTComponent, int getAccessibleIndexInParent()

GetGets the index of this object in its accessible parent. @return the index of this object in its parent; or -1 if this object does not have an accessible parent. @see #getAccessibleParent
Class Component.AccessibleAWTComponent, String getAccessibleName()

GetGets the accessible name of this object. This should almost never return java.awt.Component.getName() as that generally isn't a localized name and doesn't have meaning for the user. If the object is fundamentally a text object (e.g. a menu item) the accessible name should be the text of the object (e.g. "save"). If the object has a tooltip the tooltip text may also be an appropriate String to return. @return the localized name of the object -- can be null if this object does not have a name @see javax.accessibility.AccessibleContext#setAccessibleName
Class Component.AccessibleAWTComponent, Accessible getAccessibleParent()

GetGets the Accessible parent of this object. If the parent of this object implements Accessible this method should simply return getParent(). @return the Accessible parent of this object -- can be null if this object does not have an Accessible parent
Class Component.AccessibleAWTComponent, AccessibleRole getAccessibleRole()

GetGets the role of this object. @return an instance of AccessibleRole describing the role of the object @see javax.accessibility.AccessibleRole
Class Component.AccessibleAWTComponent, AccessibleStateSet getAccessibleStateSet()

GetGets the state of this object. @return an instance of AccessibleStateSet containing the current state set of the object @see javax.accessibility.AccessibleState
Class Component.AccessibleAWTComponent, Color getBackground()

GetGets the background color of this object. @return the background color if supported of the object; otherwise null
Class Component.AccessibleAWTComponent, Rectangle getBounds()

Gets the bounds of this object in the form of a Rectangle object. The bounds specify this object's width height and location relative to its parent. @return Aa rectangle indicating this component's bounds; null if this object is not on the screen.
Class Component.AccessibleAWTComponent, Cursor getCursor()

GetGets the Cursor of this object. @return the Cursor if supported of the object; otherwise null
Class Component.AccessibleAWTComponent, Font getFont()

GetGets the Font of this object. @return the Font if supported for the object; otherwise null
Class Component.AccessibleAWTComponent, FontMetrics getFontMetrics(Font)

GetGets the FontMetrics of this object. @param f the Font @return the FontMetrics if supported the object; otherwise null @see #getFont
Class Component.AccessibleAWTComponent, Color getForeground()

GetGets the foreground color of this object. @return the foreground color if supported of the object; otherwise null
Class Component.AccessibleAWTComponent, Locale getLocale()

ReturnReturns the locale of this object. @return the locale of this object
Class Component.AccessibleAWTComponent, Point getLocation()

Gets the location of the object relative to the parent in the form of a point specifying the object's top-left corner in the screen's coordinate space. @return Anan instance of Point representing the top-left corner of the objectsobject's bounds in the coordinate space of the screen; null if this object or its parent are not on the screen
Class Component.AccessibleAWTComponent, Point getLocationOnScreen()

Returns the location of the object on the screen. @return location of object on screen -- can be null if this object is not on the screen
Class Component.AccessibleAWTComponent, Dimension getSize()

Returns the size of this object in the form of a Dimension object. The height field of the Dimension object contains this objects's height and the width field of the Dimension object contains this object's width. @return Aa Dimension object that indicates the size of this component; null if this object is not on the screen
Class Component.AccessibleAWTComponent, boolean isEnabled()

DetermineDetermines if the object is enabled. @return true if object is enabled; otherwise false
Class Component.AccessibleAWTComponent, boolean isShowing()

DetermineDetermines if the object is showing. This is determined by checking the visibility of the object and ancestors of the object. Note: this will return true even if the object is obscured by another (for example it happens to be underneath a menu that was pulled down). @return true if object is showing; otherwise false
Class Component.AccessibleAWTComponent, boolean isVisible()

DetermineDetermines if the object is visible. Note: this means that the object intends to be visible; however it may not in fact be showing on the screen because one of the objects that this object is contained by is not visible. To determine if an object is showing on the screen use isShowing(). @return true if object is visible; otherwise false
Class Component.AccessibleAWTComponent, void setBackground(Color)

SetSets the background color of this object. (For transparency see isOpaque.) @param c the new Color for the background @see Component#isOpaque
Class Component.AccessibleAWTComponent, void setBounds(Rectangle)

Sets the bounds of this object in the form of a Rectangle object. The bounds specify this object's width height and location relative to its parent. @param Aa rectangle indicating this component's bounds
Class Component.AccessibleAWTComponent, void setCursor(Cursor)

SetSets the Cursor of this object. @param c the new Cursor for the object
Class Component.AccessibleAWTComponent, void setEnabled(boolean)

SetSets the enabled state of the object. @param b if true enables this object; otherwise disables it
Class Component.AccessibleAWTComponent, void setFont(Font)

SetSets the Font of this object. @param f the new Font for the object
Class Component.AccessibleAWTComponent, void setForeground(Color)

SetSets the foreground color of this object. @param c the new Color for the foreground
Class Component.AccessibleAWTComponent, void setLocation(Point)

Sets the location of the object relative to the parent. @param p the coordinates of the object
Class Component.AccessibleAWTComponent, void setSize(Dimension)

Resizes this object so that it has width width and height. @param d - Thethe dimension specifying the new size of the object.
Class Component.AccessibleAWTComponent, void setVisible(boolean)

SetSets the visible state of the object. @param b if true shows this object; otherwise hides it

Class Component, void add(PopupMenu)

Adds the specified popup menu to the component. @param popup the popup menu to be added to the component. @see java.awt.Component#remove(java.awt.MenuComponent) @since JDK1.1
Class Component, void addComponentListener(ComponentListener)

Adds the specified component listener to receive component events from this component. If listener l is null no exception is thrown and no action is performed. @param l the component listenerlistene. @see java.awt.event.ComponentEvent @see java.awt.event.ComponentListener @see java.awt.Component#removeComponentListener @see #getComponentListeners @since JDK1.1
Class Component, void addFocusListener(FocusListener)

Adds the specified focus listener to receive focus events from this component when this component gains input focus. If listener l is null no exception is thrown and no action is performed. @param l the focus listener. @see java.awt.event.FocusEvent @see java.awt.event.FocusListener @see java.awt.Component#removeFocusListener @see #getFocusListeners @since JDK1.1
Class Component, void addHierarchyBoundsListener(HierarchyBoundsListener)

Adds the specified hierarchy bounds listener to receive hierarchy bounds events from this component when the hierarchy to which this container belongs changes. If listener l is null no exception is thrown and no action is performed. @param l the hierarchy bounds listener. @see java.awt.event.HierarchyEvent @see java.awt.event.HierarchyBoundsListener @see java.awt.Component#removeHierarchyBoundsListener @see #getHierarchyBoundsListeners @since 1.3
Class Component, void addHierarchyListener(HierarchyListener)

Adds the specified hierarchy listener to receive hierarchy changed events from this component when the hierarchy to which this container belongs changes. If listener l is null no exception is thrown and no action is performed. @param l the hierarchy listener. @see java.awt.event.HierarchyEvent @see java.awt.event.HierarchyListener @see java.awt.Component#removeHierarchyListener @see #getHierarchyListeners @since 1.3
Class Component, void addInputMethodListener(InputMethodListener)

Adds the specified input method listener to receive input method events from this component. A component will only receive input method events from input methods if it also overrides getInputMethodRequests to return an InputMethodRequests instance. If listener l is null no exception is thrown and no action is performed. @param l the input method listener. @see java.awt.event.InputMethodEvent @see java.awt.event.InputMethodListener @see java.awt.Component#removeInputMethodListener @see java.awt.Component#getInputMethodListeners @see #getInputMethodRequests @since 1.2
Class Component, void addKeyListener(KeyListener)

Adds the specified key listener to receive key events from this component. If l is null no exception is thrown and no action is performed. @param l the key listener. @see java.awt.event.KeyEvent @see java.awt.event.KeyListener @see java.awt.Component#removeKeyListener @see #getKeyListeners @since JDK1.1
Class Component, void addMouseListener(MouseListener)

Adds the specified mouse listener to receive mouse events from this component. If listener l is null no exception is thrown and no action is performed. @param l the mouse listener. @see java.awt.event.MouseEvent @see java.awt.event.MouseListener @see java.awt.Component#removeMouseListener @see #getMouseListeners @since JDK1.1
Class Component, void addMouseMotionListener(MouseMotionListener)

Adds the specified mouse motion listener to receive mouse motion events from this component. If listener l is null no exception is thrown and no action is performed. @param l the mouse motion listener. @see java.awt.event.MouseMotionEvent @see java.awt.event.MouseMotionListener @see java.awt.Component#removeMouseMotionListener @see #getMouseMotionListeners @since JDK1.1
Class Component, void addNotify()

Makes this Component displayable by connecting it to a native screen resource. This method is called internally by the toolkit and should not be called directly by programs. @see java.awt.Component#isDisplayable @see java.awt.Component#removeNotify @since JDK1.0
Class Component, void addPropertyChangeListener(PropertyChangeListener)

AddAdds a PropertyChangeListener to the listener list. The listener is registered for all bound properties. A PropertyChangeEvent will getof this class including the firedfollowing: in Note that if this Component is inheriting a bound property then no event will be fired in response to a change in the inherited property.

If listener is null no exception is thrown and no action is performed. @param listener Thethe PropertyChangeListener to be added @see #removePropertyChangeListener @see #getPropertyChangeListeners @see #addPropertyChangeListener(java.lang.String java.beans.PropertyChangeListener)

Class Component, void addPropertyChangeListener(String, PropertyChangeListener)

AddAdds a PropertyChangeListener to the listener list for a specific property. The listenerspecified willproperty may be invokeduser-defined only whenor one aof the callfollowing: on Note that specificif this Component is inheriting a bound property then no event will be fired in response to a change in the inherited property.

If listener is null no exception is thrown and no action is performed. @param propertyName The nameone of the property to listennames listed on.above @param listener Thethe PropertyChangeListener to be added @see #removePropertyChangeListener(java.lang.String) @see #getPropertyChangeListeners(java.lang.String) @see #addPropertyChangeListener(java.beans.PropertyChangeListener)

Class Component, int checkImage(Image, ImageObserver)

Returns the status of the construction of a screen representation of the specified image.

This method does not cause the image to begin loading. An application must use the prepareImage method to force the loading of an image.

Information on the flags returned by this method can be found with the discussion of the ImageObserver interface. @param image the Image object whose status is being checked. @param observer the ImageObserver object to be notified as the image is being prepared. @return the bitwise inclusive OR of ImageObserver flags indicating what information about the image is currently available. @see java.awt.Component#prepareImage(java.awt.Image int int java.awt.image.ImageObserver) @see java.awt.Toolkit#checkImage(java.awt.Image int int java.awt.image.ImageObserver) @see java.awt.image.ImageObserver @since JDK1.0

Class Component, int checkImage(Image, int, int, ImageObserver)

Returns the status of the construction of a screen representation of the specified image.

This method does not cause the image to begin loading. An application must use the prepareImage method to force the loading of an image.

The checkImage method of Component calls its peer's checkImage method to calculate the flags. If this component does not yet have a peer the component's toolkit's checkImage method is called instead.

Information on the flags returned by this method can be found with the discussion of the ImageObserver interface. @param image the Image object whose status is being checked. @param width the width of the scaled version whose status is to be checked. @param height the height of the scaled version whose status is to be checked. @param observer the ImageObserver object to be notified as the image is being prepared. @return the bitwise inclusive OR of ImageObserver flags indicating what information about the image is currently available. @see java.awt.Component#prepareImage(java.awt.Image int int java.awt.image.ImageObserver) @see java.awt.Toolkit#checkImage(java.awt.Image int int java.awt.image.ImageObserver) @see java.awt.image.ImageObserver @since JDK1.0

Class Component, AWTEvent coalesceEvents(AWTEvent, AWTEvent)

Potentially coalesce an event being posted with an existing event. This method is called by EventQueue.postEvent if an event with the same ID as the event to be posted is found in the queue (both events must have this component as their source). This method either returns a coalesced event which replaces the existing event (and the new event is then discarded) or null to indicate that no combining should be done (add the second event to the end of the queue). Either event parameter may be modified and returned as the other one is discarded unless null is returned.

This implementation of coalesceEvents coalesces two event types: mouse move (and drag) events and paint (and update) events. For mouse move events the last event is always returned causing intermediate moves to be discarded. For paint events the new event is coalesced into a complex RepaintArea in the peer. The new EventAWTEvent is always returned. @param existingEvent the event already on the EventQueue. @param newEvent the event being posted to the EventQueue. @return a coalesced event or null indicating that no coalescing was done.

Class Component, boolean contains(Point)

Checks whether this component "contains" the specified point where the point's x and y coordinates are defined to be relative to the coordinate system of this component. @param p the point. @see java.awt.Component#getComponentAt(java.awt.Point) @since JDK1.1
Class Component, boolean contains(int, int)

Checks whether this component "contains" the specified point where x and y are defined to be relative to the coordinate system of this component. @param x the x coordinate of the point. @param y the y coordinate of the point. @see java.awt.Component#getComponentAt(int int) @since JDK1.1
Class Component, Image createImage(ImageProducer)

Creates an image from the specified image producer. @param producer the image producer @return the image produced. @since JDK1.0
Class Component, Image createImage(int, int)

Creates an off-screen drawable image to be used for double buffering. @param width the specified width. @param height the specified height. @return an off-screen drawable image which can be used for double buffering. The return value may be null if the component is not displayable. This will always happen if GraphicsEnvironment.isHeadless() returns true. @see #isDisplayable @see GraphicsEnvironment#isHeadless @since JDK1.0
Class Component, void disableEvents(long)

Disables the events defined by the specified event mask parameter from being delivered to this component. @param eventsToDisable the event mask defining the event types @see java.awt.Component#enableEvents @since JDK1.1
Class Component, void dispatchEvent(AWTEvent)

Dispatches an event to this component or one of its sub components. Calls processEvent() before returning for 1.1-style events which have been enabled for the Component. @param e the event
Class Component, void enableEvents(long)

Enables the events defined by the specified event mask parameter to be delivered to this component.

Event types are automatically enabled when a listener for that event type is added to the component.

This method only needs to be invoked by subclasses of Component which desire to have the specified event types delivered to processEvent regardless of whether or not a listener is registered. @param eventsToEnable the event mask defining the event types. @see java.awt.Component#processEvent @see java.awt.Component#disableEvents @see AWTEvent @since JDK1.1

Class Component, void enableInputMethods(boolean)

Enables or disables input method support for this component. If input method support is enabled and the component also processes key events incoming events are offered to the current input method and will only be processed by the component or dispatched to its listeners if the input method does not consume them. By default input method support is enabled. @param enable true to enable false to disable. @see java.awt.Component#processKeyEvent @since 1.2
Class Component, AccessibleContext getAccessibleContext()

GetGets the AccessibleContext associated with this Component. The method implemented by this base class returns null. Classes that extend Component should implement this method to return the AccessibleContext associated with the subclass. @return the AccessibleContext of this Component
Class Component, Color getBackground()

Gets the background color of this component. @return Thisthis component's background color.; Ifif this component does not have a background color the background color of its parent is returned. @see java.awt.Component#setBackground(java.awt.Color) @since JDK1.0
Class Component, Rectangle getBounds()

Gets the bounds of this component in the form of a Rectangle object. The bounds specify this component's width height and location relative to its parent. @return Aa rectangle indicating this component's bounds. @see #setBounds @see #getLocation @see #getSize
Class Component, Rectangle getBounds(Rectangle)

StoreStores the bounds of this component into "return value" rv and return rv. If rv is null a new Rectangle is allocated. This version of getBounds() is useful if the caller wants to avoid allocating a new Rectangle object on the heap. @param rv the return value modified to the components bounds @return rv
Class Component, ColorModel getColorModel()

Gets the instance of ColorModel used to display the component on the output device. @return Thethe color model used by this component. @see java.awt.image.ColorModel @see java.awt.peer.ComponentPeer#getColorModel() @see java.awt.Toolkit#getColorModel() @since JDK1.0
Class Component, Component getComponentAt(Point)

Returns the component or subcomponent that contains the specified point. @param p the point. @see java.awt.Component#contains @since JDK1.1
Class Component, Component getComponentAt(int, int)

Determines if this component or one of its immediate subcomponents contains the (x  y) location and if so returns the containing component. This method only looks one level deep. If the point (x  y) is inside a subcomponent that itself has subcomponents it does not go looking down the subcomponent tree.

The locate method of Component simply returns the component itself if the (x  y) coordinate location is inside its bounding box and null otherwise. @param x the x coordinate. @param y the y coordinate. @return the component or subcomponent that contains the (x  y) location; null if the location is outside this component. @see java.awt.Component#contains(int int) @since JDK1.0

Class Component, ComponentOrientation getComponentOrientation()

RetrieveRetrieves the language-sensitive orientation that is to be used to order the elements or text within this component. LayoutManager and Component subclasses that wish to respect orientation should call this method to get the component's orientation before performing layout or drawing. @see java.awt.ComponentOrientation @author Laura Werner IBM
Class Component, Cursor getCursor()

Gets the cursor set in the component. If the component does not have a cursor set the cursor of its parent is returned. If no Cursorcursor is set in the entire hierarchy Cursor.DEFAULT_CURSOR is returned. @see #setCursor @since JDK1.1
Class Component, DropTarget getDropTarget()

GetGets the DropTarget associated with this Component.
Class Component, Font getFont()

Gets the font of this component. @return Thisthis component's font.; Ifif a font has not been set for this component the font of its parent is returned. @see #setFont @since JDK1.0
Class Component, FontMetrics getFontMetrics(Font)

Gets the font metrics for the specified font. @param font Thethe font for which font metrics is to be obtained. @return Thethe font metrics for font. @param font the font. @return the font metrics for the specified font. @see java.awt.Component#getFont @see java.awt.Component#getPeer() @see java.awt.peer.ComponentPeer#getFontMetrics(java.awt.Font) @see java.awt.Toolkit#getFontMetrics(java.awt.Font) @since JDK1.0
Class Component, Color getForeground()

Gets the foreground color of this component. @return Thisthis component's foreground color.; Ifif this component does not have a foreground color the foreground color of its parent is returned. @see #setForeground @since JDK1.0 @beaninfo bound: true
Class Component, Graphics getGraphics()

Creates a graphics context for this component. This method will return null if this component is currently not displayable. @return Aa graphics context for this component or null if it has none. @see java.awt.Component#paint @since JDK1.0
Class Component, GraphicsConfiguration getGraphicsConfiguration()

GetGets the GraphicsConfiguration associated with this Component. If the Component has not been assigned a specific GraphicsConfiguration the GraphicsConfiguration of the Component object's top-level container is returned. If the Component has been created but not yet added to a Container this method returns null. @return the GraphicsConfiguration used by this Component or null @since 1.3
Class Component, int getHeight()

ReturnReturns the current height of this component. This method is preferable to writing component.getBounds().height or component.getSize().height because it doesn't cause any heap allocations. @return the current height of this component. @since 1.2
Class Component, InputContext getInputContext()

Gets the input context used by this component for handling the communication with input methods when text is entered in this component. By default the input context used for the parent component is returned. Components may override this to return a private input context. @return Thethe input context used by this component.; Nullnull if no context can be determined. @since 1.2
Class Component, InputMethodRequests getInputMethodRequests()

Gets the input method request handler which supports requests from input methods for this component. A component that supports on-the-spot text input must override this method to return an InputMethodRequests instance. At the same time it also has to handle input method events. @return the input method request handler for this component null by default. @see #addInputMethodListener @since 1.2
Class Component, EventListener[] getListeners(Class)

ReturnReturns an array of all the listenersobjects that were addedcurrently registered as toFooListeners the Componentupon this withComponent. addXXXListener()FooListeners where XXX isare registered using the nameaddFooListener method.

ofYou can specify the listenerType argument. For example to get all ofwith a class literal such as theFooListener.class. For MouseListeners for the givenexample you can query a Component c onefor its mouse listeners with the would writefollowing code:

 MouseListener[] mls = (MouseListener[])(c.getListeners(MouseListener.class)) ;
If no such listenerlisteners exist list exists thenthis method returns an empty array is returned. @param listenerType Typethe type of listeners requested. This; this parameter mustshould be aspecify an interface that descends from java.util.EventListener or subclass. @returnsreturn an array of all listenersobjects added toregistered as thisFooListeners Component using addXXXListeneron this component or an empty array if no such listeners have been added to this Component. @throwsexception ClassCastException if the listenerType parameter isdoesn't notspecify a class or interface that implements java.util.EventListener or@see subclass.#getComponentListeners @see #getFocusListeners @see #getHierarchyListeners @see #getHierarchyBoundsListeners @see #getKeyListeners @see #getMouseListeners @see #getMouseMotionListeners @see #getMouseWheelListeners @see #getInputMethodListeners @see #getPropertyChangeListeners @since 1.3
Class Component, Locale getLocale()

Gets the locale of this component. @return Thisthis component's locale.; Ifif this component does not have a locale the locale of its parent is returned. @see #setLocale @exception IllegalComponentStateException Ifif the Component does not have its own locale and has not yet been added to a containment hierarchy such that the locale can be determined from the containing parent. @since JDK1.1
Class Component, Point getLocation()

Gets the location of this component in the form of a point specifying the component's top-left corner. The location will be relative to the parent's coordinate space.

Due to the asynchronous nature of native event handling this method can return outdated values (for instance after several calls of setLocation() in rapid succession). For this reason the recommended method of obtaining a Componentcomponent's position is within java.awt.event.ComponentListener.componentMoved() which is called after the operating system has finished moving the Componentcomponent.

@return Anan instance of Point representing the top-left corner of the component's bounds in the coordinate space of the component's parent. @see #setLocation @see #getLocationOnScreen @since JDK1.1
Class Component, Point getLocation(Point)

StoreStores the x y origin of this component into "return value" rv and return rv. If rv is null a new Point is allocated. This version of getLocation() is useful if the caller wants to avoid allocating a new Point object on the heap. @param rv the return value modified to the components location @return rv
Class Component, Point getLocationOnScreen()

Gets the location of this component in the form of a point specifying the component's top-left corner in the screen's coordinate space. @return Anan instance of Point representing the top-left corner of the component's bounds in the coordinate space of the screen. @throws IllegalComponentStateException if the component is not showing on the screen @see #setLocation @see #getLocation
Class Component, Dimension getMaximumSize()

Gets the maximum size of this component. @return Aa dimension object indicating this component's maximum size. @see #getMinimumSize @see #getPreferredSize @see LayoutManager
Class Component, Dimension getMinimumSize()

Gets the mininimum size of this component. @return Aa dimension object indicating this component's minimum size. @see #getPreferredSize @see java.awtLayoutManagerLayoutManager
Class Component, String getName()

Gets the name of the component. @return Thisthis component's name. @see #setName @since JDK1.1
Class Component, Container getParent()

Gets the parent of this component. @return Thethe parent container of this component. @since JDK1.0
Class Component, ComponentPeer getPeer()

@deprecated As of JDK version 1.1 programs should not directly manipulate peers.; replaced by boolean isDisplayable().
Class Component, Dimension getPreferredSize()

Gets the preferred size of this component. @return Aa dimension object indicating this component's preferred size. @see #getMinimumSize @see java.awt.LayoutManager
Class Component, Dimension getSize()

Returns the size of this component in the form of a Dimension object. The height field of the Dimension object contains this component's height and the width field of the Dimension object contains this component's width. @return Aa Dimension object that indicates the size of this component. @see #setSize @since JDK1.1
Class Component, Dimension getSize(Dimension)

StoreStores the width/height of this component into "return value" rv and return rv. If rv is null a new Dimension object is allocated. This version of getSize() is useful if the caller wants to avoid allocating a new Dimension object on the heap. @param rv the return value modified to the components size @return rv
Class Component, Toolkit getToolkit()

Gets the toolkit of this component. Note that the frame that contains a component controls which toolkit is used by that component. Therefore if the component is moved from one frame to another the toolkit it uses may change. @return Thethe toolkit of this component. @since JDK1.0
Class Component, Object getTreeLock()

Gets the locking object for AWT component-tree and layout Gets this component's locking object (the object that owns the thread sychronization monitor) for AWT component-tree and layout operations. @return Thisthis component's locking object.
Class Component, int getWidth()

ReturnReturns the current width of this component. This method is preferable to writing component.getBounds().width or component.getSize().width because it doesn't cause any heap allocations. @return the current width of this component. @since 1.2
Class Component, int getX()

ReturnReturns the current x coordinate of the components origin. This method is preferable to writing component.getBounds().x or component.getLocation().x because it doesn't cause any heap allocations. @return the current x coordinate of the components origin. @since 1.2
Class Component, int getY()

ReturnReturns the current y coordinate of the components origin. This method is preferable to writing component.getBounds().y or component.getLocation().y because it doesn't cause any heap allocations. @return the current y coordinate of the components origin. @since 1.2
Class Component, boolean hasFocus()

Returns true if this Component hasis the keyboard focus owner. This method is obsolete and has been replaced by isFocusOwner(). @return true if this Component hasis the keyboard focus. owner; false otherwise @since 1.2
Class Component, boolean imageUpdate(Image, int, int, int, int, int)

Repaints the component when the image has changed. This imageUpdate method of an ImageObserver is called when more information about an image which had been previously requested using an asynchronous routine such as the drawImage method of Graphics becomes available. See the definition of imageUpdate for more information on this method and its arguments.

The imageUpdate method of Component incrementally draws an image on the component as more of the bits of the image are available.

If the system property awt.image.incrementalDraw is missing or has the value true the image is incrementally drawn. If the system property has any other value then the image is not drawn until it has been completely loaded.

Also if incremental drawing is in effect the value of the system property awt.image.redrawrate is interpreted as an integer to give the maximum redraw rate in milliseconds. If the system property is missing or cannot be interpreted as an integer the redraw rate is once every 100ms.

The interpretation of the x y width and height arguments depends on the value of the infoflags argument. @param img the image being observed. @param infoflags see imageUpdate for more information. @param x the x coordinate. @param y the y coordinate. @param w the width. @param h the height. @return false if the infoflags indicate that the image is completely loaded; true otherwise. @see java.awt.image.ImageObserver @see java.awt.Graphics#drawImage(java.awt.Image int int java.awt.Color java.awt.image.ImageObserver) @see java.awt.Graphics#drawImage(java.awt.Image int int java.awt.image.ImageObserver) @see java.awt.Graphics#drawImage(java.awt.Image int int int int java.awt.Color java.awt.image.ImageObserver) @see java.awt.Graphics#drawImage(java.awt.Image int int int int java.awt.image.ImageObserver) @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image int int int int int) @since JDK1.0

Class Component, void invalidate()

Invalidates this component. This component and all parents above it are marked as needing to be laid out. This method can be called often so it needs to execute quickly. @see java.awt.Component#validate @see java.awt.Component#doLayout @see java.awt.LayoutManager @since JDK1.0
Class Component, boolean isDisplayable()

Determines whether this component is displayable. A component is displayable when it is connected to a native screen resource.

A component is made displayable either when it is added to a displayable containment hierarchy or when its containment hierarchy is made displayable. A containment hierarchy is made displayable when its ancestor window is either packed or made visible.

A component is made undisplayable either when it is removed from a displayable containment hierarchy or when its containment hierarchy is made undisplayable. A containment hierarchy is made undisplayable when its ancestor window is disposed. @return true if the component is displayable; false otherwise. @see java.awt.Container#add(java.awt.Component) @see java.awt.Window#pack @see java.awt.Window#show @see java.awt.Container#remove(java.awt.Component) @see java.awt.Window#dispose @since 1.2

Class Component, boolean isEnabled()

Determines whether this component is enabled. An enabled component can respond to user input and generate events. Components are enabled initially by default. A component may be enabled or disabled by calling its setEnabled method. @return true if the component is enabled; false otherwise. @see #setEnabled @since JDK1.0
Class Component, boolean isFocusTraversable()

Returns the value of a flag that indicates whether this component can be traversed using Tab or Shift-Tab keyboard focus traversal. If this method returns "false" this component may still request the keyboard focus using requestFocus()Component but it will not automaticallycan be assignedbecome the focus during tab traversalowner. @return true if this componentComponent is focus-traverablefocusable; false otherwise. @see #setFocusable @since JDK1.1 @deprecated As of 1.4 replaced by isFocusable().
Class Component, boolean isLightweight()

A lightweight component doesn't have a native toolkit peer. Subclasses of Component and Container other than the ones defined in this package like Button or Scrollbar are lightweight. All of the Swing components are lightweights.

This method will always return false if this Componentcomponent is not displayable because it is impossible to determine the weight of an undisplayable Componentcomponent. @return true if this component has a lightweight peer; false if it has a native peer or no peer. @see #isDisplayable @since 1.2

Class Component, boolean isOpaque()

Returns true if this component is completely opaque returns false by default.

An opaque component paints every pixel within its rectangular region. A non-opaque component paints only some of its pixels allowing the pixels underneath it to "show through". A component that does not fully paint its pixels therefore provides a degree of transparency. Only lightweight components can be transparent.

Subclasses that guarantee to always completely paint their contents should override this method and return true. All of the "heavyweight" AWT components are opaque. @return true if this component is completely opaque. @see #isLightweight @since 1.2

Class Component, boolean isShowing()

Determines whether this component is showing on screen. This means that the component must be visible and it must be in a container that is visible and showing. @return true if the component is showing; false otherwise. @see #setVisible @since JDK1.0
Class Component, boolean isValid()

Determines whether this component is valid. A component is valid when it is correctly sized and positioned within its parent container and all its children are also valid. Components are invalidated when they are first shown on the screen. @return true if the component is valid; false otherwise. @see #validate @see #invalidate @since JDK1.0
Class Component, boolean isVisible()

Determines whether this component should be visible when its parent is visible. Components are initially visible with the exception of top level components such as Frame objects. @return true if the component is visible; false otherwise. @see #setVisible @since JDK1.0
Class Component, void list(PrintStream)

Prints a listing of this component to the specified output stream. @param out a print stream. @since JDK1.0
Class Component, void list(PrintStream, int)

Prints out a list starting at the specified indentionindentation to the specified print stream. @param out a print stream. @param indent number of spaces to indent. @see java.io.PrintStream#println(java.lang.Object) @since JDK1.0
Class Component, void list(PrintWriter)

Prints a listing to the specified print writer. @param out Thethe print writer to print to. @since JDK1.1
Class Component, void list(PrintWriter, int)

Prints out a list starting at the specified indentionindentation to the specified print writer. @param out Thethe print writer to print to. @param indent Thethe number of spaces to indent. @see java.io.PrintStream#println(java.lang.Object) @since JDK1.1
Class Component, void paint(Graphics)

Paints this component.

This method is called when the contents of the component should be painted in response to the component first being shown or damage needing repair. The clip rectangle in the Graphics parameter will be set to the area which needs to be painted. Subclasses of Component that override this method need not call super.paint(g).

For performance reasons Components with zero width or height aren't considered to need painting when they are first shown and also aren't considered to need repair. @param g Thethe graphics context to use for painting. @see java.awt.Component#update @since JDK1.0

Class Component, void paintAll(Graphics)

Paints this component and all of its subcomponents.

The origin of the graphics context its (0  0) coordinate point is the top-left corner of this component. The clipping region of the graphics context is the bounding rectangle of this component. @param g the graphics context to use for painting. @see java.awt.Component#paint @since JDK1.0

Class Component, String paramString()

Returns a string representing the state of this component. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null. @return a string representation of this component's state. @since JDK1.0
Class Component, boolean prepareImage(Image, ImageObserver)

Prepares an image for rendering on this component. The image data is downloaded asynchronously in another thread and the appropriate screen representation of the image is generated. @param image the Image for which to prepare a screen representation. @param observer the ImageObserver object to be notified as the image is being prepared. @return true if the image has already been fully prepared; false otherwise. @since JDK1.0
Class Component, boolean prepareImage(Image, int, int, ImageObserver)

Prepares an image for rendering on this component at the specified width and height.

The image data is downloaded asynchronously in another thread and an appropriately scaled screen representation of the image is generated. @param image the instance of Image for which to prepare a screen representation. @param width the width of the desired screen representation. @param height the height of the desired screen representation. @param observer the ImageObserver object to be notified as the image is being prepared. @return true if the image has already been fully prepared; false otherwise. @see java.awt.image.ImageObserver @since JDK1.0

Class Component, void print(Graphics)

Prints this component. Applications should override this method for components that must do special processing before being printed or should be printed differently than they are painted.

The default implementation of this method calls the paint method.

The origin of the graphics context its (0  0) coordinate point is the top-left corner of this component. The clipping region of the graphics context is the bounding rectangle of this component. @param g the graphics context to use for printing. @see java.awt.Component#paint(java.awt.Graphics) @since JDK1.0

Class Component, void printAll(Graphics)

Prints this component and all of its subcomponents.

The origin of the graphics context its (0  0) coordinate point is the top-left corner of this component. The clipping region of the graphics context is the bounding rectangle of this component. @param g the graphics context to use for printing. @see java.awt.Component#print(java.awt.Graphics) @since JDK1.0

Class Component, void processComponentEvent(ComponentEvent)

Processes component events occurring on this component by dispatching them to any registered ComponentListener objects.

This method is not called unless component events are enabled for this component. Component events are enabled when one of the following occurs:

Note that if the event parameter is null the behavior is unspecified and may result in an exception. @param e the component event. @see java.awt.event.ComponentEvent @see java.awt.event.ComponentListener @see java.awt.Component#addComponentListener @see java.awt.Component#enableEvents @since JDK1.1

Class Component, void processEvent(AWTEvent)

Processes events occurring on this component. By default this method calls the appropriate process<event type>Event method for the given class of event.

Note that if the event parameter is null the behavior is unspecified and may result in an exception. @param e the event. @see java.awt.Component#processComponentEvent @see java.awt.Component#processFocusEvent @see java.awt.Component#processKeyEvent @see java.awt.Component#processMouseEvent @see java.awt.Component#processMouseMotionEvent @see java.awt.Component#processInputMethodEvent @see java.awt.Component#processHierarchyEvent @see #processMouseWheelEvent @since JDK1.1

Class Component, void processFocusEvent(FocusEvent)

Processes focus events occurring on this component by dispatching them to any registered FocusListener objects.

This method is not called unless focus events are enabled for this component. Focus events are enabled when one of the following occurs:

Note that if the event parameter is null the behavior is unspecified and may result in an exception. @param e the focus event. @see java.awt.event.FocusEvent @see java.awt.event.FocusListener @see java.awt.Component#addFocusListener @see java.awt.Component#enableEvents @since JDK1.1

Class Component, void processHierarchyBoundsEvent(HierarchyEvent)

Processes hierarchy bounds events occurring on this component by dispatching them to any registered HierarchyBoundsListener objects.

This method is not called unless hierarchy bounds events are enabled for this component. Hierarchy bounds events are enabled when one of the following occurs:

Note that if the event parameter is null the behavior is unspecified and may result in an exception. @param e the hierarchy event @see java.awt.event.HierarchyEvent @see java.awt.event.HierarchyBoundsListener @see java.awt.Component#addHierarchyBoundsListener @see java.awt.Component#enableEvents @since 1.3

Class Component, void processHierarchyEvent(HierarchyEvent)

Processes hierarchy events occurring on this component by dispatching them to any registered HierarchyListener objects.

This method is not called unless hierarchy events are enabled for this component. Hierarchy events are enabled when one of the following occurs:

Note that if the event parameter is null the behavior is unspecified and may result in an exception. @param e the hierarchy event @see java.awt.event.HierarchyEvent @see java.awt.event.HierarchyListener @see java.awt.Component#addHierarchyListener @see java.awt.Component#enableEvents @since 1.3

Class Component, void processInputMethodEvent(InputMethodEvent)

Processes input method events occurring on this component by dispatching them to any registered InputMethodListener objects.

This method is not called unless input method events are enabled for this component. Input method events are enabled when one of the following occurs:

Note that if the event parameter is null the behavior is unspecified and may result in an exception. @param e the input method event @see java.awt.event.InputMethodEvent @see java.awt.event.InputMethodListener @see java.awt.Component#addInputMethodListener @see java.awt.Component#enableEvents @since 1.2

Class Component, void processKeyEvent(KeyEvent)

Processes key events occurring on this component by dispatching them to any registered KeyListener objects.

This method is not called unless key events are enabled for this component. Key events are enabled when one of the following occurs:

Note that this method is not called by the event dispatch thread if the component is not the focus owner of if the component is not showing. This method is called when key events are registered via the addKeyListener or enableEvents methods but as of release 1.4 the implementation of the AWT event dispatching thread redirects KeyEvent to the focus owner. Please see the Focus Specification for further information.

If the event parameter is null the behavior is unspecified and may result in an exception. @param e the key event. @see java.awt.event.KeyEvent @see java.awt.event.KeyListener @see java.awt.Component#addKeyListener @see java.awt.Component#enableEvents @see #isShowing @since JDK1.1

Class Component, void processMouseEvent(MouseEvent)

Processes mouse events occurring on this component by dispatching them to any registered MouseListener objects.

This method is not called unless mouse events are enabled for this component. Mouse events are enabled when one of the following occurs:

Note that if the event parameter is null the behavior is unspecified and may result in an exception. @param e the mouse event. @see java.awt.event.MouseEvent @see java.awt.event.MouseListener @see java.awt.Component#addMouseListener @see java.awt.Component#enableEvents @since JDK1.1

Class Component, void processMouseMotionEvent(MouseEvent)

Processes mouse motion events occurring on this component by dispatching them to any registered MouseMotionListener objects.

This method is not called unless mouse motion events are enabled for this component. Mouse motion events are enabled when one of the following occurs:

Note that if the event parameter is null the behavior is unspecified and may result in an exception. @param e the mouse motion event. @see java.awt.event.MouseMotionEvent @see java.awt.event.MouseMotionListener @see java.awt.Component#addMouseMotionListener @see java.awt.Component#enableEvents @since JDK1.1

Class Component, void remove(MenuComponent)

Removes the specified popup menu from the component. @param popup the popup menu to be removed. @see java.awt.Component#add(java.awt.PopupMenu) @since JDK1.1
Class Component, void removeComponentListener(ComponentListener)

Removes the specified component listener so that it no longer receives component events from this component. This method performs no function nor does it throw an exception if the listener specified by the argument was not previously added to this component. If listener l is null no exception is thrown and no action is performed. @param l the component listener. @see java.awt.event.ComponentEvent @see java.awt.event.ComponentListener @see java.awt.Component#addComponentListener @see #getComponentListeners @since JDK1.1
Class Component, void removeFocusListener(FocusListener)

Removes the specified focus listener so that it no longer receives focus events from this component. This method performs no function nor does it throw an exception if the listener specified by the argument was not previously added to this component. If listener l is null no exception is thrown and no action is performed. @param l the focus listener. @see java.awt.event.FocusEvent @see java.awt.event.FocusListener @see java.awt.Component#addFocusListener @see #getFocusListeners @since JDK1.1
Class Component, void removeHierarchyBoundsListener(HierarchyBoundsListener)

Removes the specified hierarchy bounds listener so that it no longer receives hierarchy bounds events from this component. This method performs no function nor does it throw an exception if the listener specified by the argument was not previously added to this component. If listener l is null no exception is thrown and no action is performed. @param l the hierarchy bounds listener. @see java.awt.event.HierarchyEvent @see java.awt.event.HierarchyBoundsListener @see java.awt.Component#addHierarchyBoundsListener @see #getHierarchyBoundsListeners @since 1.3
Class Component, void removeHierarchyListener(HierarchyListener)

Removes the specified hierarchy listener so that it no longer receives hierarchy changed events from this component. This method performs no function nor does it throw an exception if the listener specified by the argument was not previously added to this component. If listener l is null no exception is thrown and no action is performed. @param l the hierarchy listener. @see java.awt.event.HierarchyEvent @see java.awt.event.HierarchyListener @see java.awt.Component#addHierarchyListener @see #getHierarchyListeners @since 1.3
Class Component, void removeInputMethodListener(InputMethodListener)

Removes the specified input method listener so that it no longer receives input method events from this component. This method performs no function nor does it throw an exception if the listener specified by the argument was not previously added to this component. If listener l is null no exception is thrown and no action is performed. @param l the input method listener. @see java.awt.event.InputMethodEvent @see java.awt.event.InputMethodListener @see java.awt.Component#addInputMethodListener @see #getInputMethodListeners @since 1.2
Class Component, void removeKeyListener(KeyListener)

Removes the specified key listener so that it no longer receives key events from this component. This method performs no function nor does it throw an exception if the listener specified by the argument was not previously added to this component. If listener l is null no exception is thrown and no action is performed. @param l the key listener. @see java.awt.event.KeyEvent @see java.awt.event.KeyListener @see java.awt.Component#addKeyListener @see #getKeyListeners @since JDK1.1
Class Component, void removeMouseListener(MouseListener)

Removes the specified mouse listener so that it no longer receives mouse events from this component. This method performs no function nor does it throw an exception if the listener specified by the argument was not previously added to this component. If listener l is null no exception is thrown and no action is performed. @param l the mouse listener. @see java.awt.event.MouseEvent @see java.awt.event.MouseListener @see java.awt.Component#addMouseListener @see #getMouseListeners @since JDK1.1
Class Component, void removeMouseMotionListener(MouseMotionListener)

Removes the specified mouse motion listener so that it no longer receives mouse motion events from this component. This method performs no function nor does it throw an exception if the listener specified by the argument was not previously added to this component. If listener l is null no exception is thrown and no action is performed. @param l the mouse motion listener. @see java.awt.event.MouseMotionEvent @see java.awt.event.MouseMotionListener @see java.awt.Component#addMouseMotionListener @see #getMouseMotionListeners @since JDK1.1
Class Component, void removeNotify()

Makes this Component undisplayable by destroying it native screen resource. This method is called by the toolkit internally and should not be called directly by programs. @see java.awt.Component#isDisplayable @see java.awt.Component#addNotify @since JDK1.0
Class Component, void removePropertyChangeListener(PropertyChangeListener)

RemoveRemoves a PropertyChangeListener from the listener list. This removesmethod ashould PropertyChangeListenerbe used to remove PropertyChangeListeners that waswere registered for all bound properties of this class.

If listener is null no exception is thrown and no action is performed. @param listener Thethe PropertyChangeListener to be removed @see #addPropertyChangeListener @see #getPropertyChangeListeners @see #removePropertyChangeListener(java.lang.String java.beans.PropertyChangeListener)

Class Component, void removePropertyChangeListener(String, PropertyChangeListener)

RemoveRemoves a PropertyChangeListener from the listener list for a specific property. This method should be used to remove PropertyChangeListeners that were registered for a specific bound property.

If listener is null no exception is thrown and no action is performed. @param propertyName The name ofa thevalid property that was listened on.name @param listener Thethe PropertyChangeListener to be removed @see #addPropertyChangeListener(java.lang.String) @see #getPropertyChangeListeners(java.lang.String) @see #removePropertyChangeListener(java.beans.PropertyChangeListener)

Class Component, void repaint()

Repaints this component.

This method causes a call to this component's update method as soon as possible. @see java.awt.Component#update(java.awt.Graphics) @since JDK1.0

Class Component, void repaint(int, int, int, int)

Repaints the specified rectangle of this component.

This method causes a call to this component's update method as soon as possible. @param x the x coordinate. @param y the y coordinate. @param width the width. @param height the height. @see java.awt.Component#update(java.awt.Graphics) @since JDK1.0

Class Component, void repaint(long)

Repaints the component. This will result in a call to update within tm milliseconds. @param tm maximum time in milliseconds before update @see #paint @see java.awt.Component#update(java.awt.Graphics) @since JDK1.0
Class Component, void repaint(long, int, int, int, int)

Repaints the specified rectangle of this component within tm milliseconds.

This method causes a call to this component's update method. @param tm maximum time in milliseconds before update. @param x the x coordinate. @param y the y coordinate. @param width the width. @param height the height. @see java.awt.Component#update(java.awt.Graphics) @since JDK1.0

Class Component, void setBackground(Color)

Sets the background color of this component.

The background color affects each component differently and the parts of the component that are affected by the background color may differ between operating systems. @param c Thethe color to become this component's color.; Ifif this parameter is null then this component will inherit the background color of its parent. background color. @see #getBackground @since JDK1.0 @beaninfo bound: true

Class Component, void setBounds(Rectangle)

Moves and resizes this component to conform to the new bounding rectangle r. This component's new position is specified by r.x and r.y and its new size is specified by r.width and r.height @param r Thethe new bounding rectangle for this component. @see java.awt.Component#getBounds @see java.awt.Component#setLocation(int int) @see java.awt.Component#setLocation(java.awt.Point) @see java.awt.Component#setSize(int int) @see java.awt.Component#setSize(java.awt.Dimension) @since JDK1.1
Class Component, void setBounds(int, int, int, int)

Moves and resizes this component. The new location of the top-left corner is specified by x and y and the new size is specified by width and height. @param x Thethe new x-coordinate of this component. @param y Thethe new y-coordinate of this component. @param width Thethe new width of this component. @param height Thethe new height of this component. @see java.awt.Component#getBounds @see java.awt.Component#setLocation(int int) @see java.awt.Component#setLocation(java.awt.Point) @see java.awt.Component#setSize(int int) @see java.awt.Component#setSize(java.awt.Dimension) @since JDK1.1
Class Component, void setComponentOrientation(ComponentOrientation)

SetSets the language-sensitive orientation that is to be used to order the elements or text within this component. Language-sensitive LayoutManager and Component subclasses will use this property to determine how to lay out and draw components.

At construction time a component's orientation is set to ComponentOrientation.UNKNOWN indicating that it has not been specified explicitly. The UNKNOWN orientation behaves the same as ComponentOrientation.LEFT_TO_RIGHT.

To set the orientation of a single component use this method. To apply aset ResourceBundle'sthe orientation toof an entire component hierarchy use java.awt.Window.applyResourceBundle.applyComponentOrientation @see java.awt.ComponentOrientation @see java.awt.Window#applyResourceBundle(java.util.ResourceBundle) @author Laura Werner IBM @beaninfo bound: true

Class Component, void setCursor(Cursor)

Sets the cursor image to the specified cursor. This cursor image is displayed when the contains method for this component returns true for the current cursor location and this Component is visible displayable and enabled. Setting the cursor of a Container causes that cursor to be displayed within all of the container's subcomponents except for those that have a non-null cursor. @param cursor One of the constants defined by the Cursor class. If; if this parameter is null then this component will inherit the cursor of its parent. @see #isEnabled @see #isShowing @see java.awt.Component#getCursor @see java.awt.Component#contains @see java.awt.Toolkit#createCustomCursor @see java.awt.Cursor @since JDK1.1
Class Component, void setDropTarget(DropTarget)

Associate a DropTarget with this Componentcomponent. The Component will receive drops only if it is enabled. @see #isEnabled @param dt The DropTarget
Class Component, void setEnabled(boolean)

Enables or disables this component depending on the value of the parameter b. An enabled component can respond to user input and generate events. Components are enabled initially by default.

Note: Disabling a lightweight component does not prevent it from receiving MouseEvents. @param b If true this component is enabled; otherwise this component is disabled. @see #isEnabled @see #isLightweight @since JDK1.1

Class Component, void setFont(Font)

Sets the font of this component. @param f Thethe font to become this component's font.; Ifif this parameter is null then this component will inherit the font of its parent. @see #getFont @since JDK1.0 @beaninfo bound: true
Class Component, void setForeground(Color)

Sets the foreground color of this component. @param c Thethe color to become this component's foreground color.; Ifif this parameter is null then this component will inherit the foreground color of its parent. @see #getForeground @since JDK1.0
Class Component, void setLocale(Locale)

Sets the locale of this component. This is a bound property. @param l Thethe locale to become this component's locale. @see #getLocale @since JDK1.1
Class Component, void setLocation(Point)

Moves this component to a new location. The top-left corner of the new location is specified by point p. Point p is given in the parent's coordinate space. @param p Thethe point defining the top-left corner of the new location given in the coordinate space of this component's parent. @see #getLocation @see #setBounds @since JDK1.1
Class Component, void setLocation(int, int)

Moves this component to a new location. The top-left corner of the new location is specified by the x and y parameters in the coordinate space of this component's parent. @param x Thethe x-coordinate of the new location's top-left corner in the parent's coordinate space. @param y Thethe y-coordinate of the new location's top-left corner in the parent's coordinate space. @see #getLocation @see #setBounds @since JDK1.1
Class Component, void setName(String)

Sets the name of the component to the specified string. @param name Thethe string that is to be this component's name. @see #getName @since JDK1.1
Class Component, void setSize(Dimension)

Resizes this component so that it has width d.width and height d.height. @param d Thethe dimension specifying the new size of this component. @see #setSize @see #setBounds @since JDK1.1
Class Component, void setSize(int, int)

Resizes this component so that it has width width and height height. @param width Thethe new width of this component in pixels. @param height Thethe new height of this component in pixels. @see #getSize @see #setBounds @since JDK1.1
Class Component, void setVisible(boolean)

Shows or hides this component depending on the value of parameter b. @param b Ifif true shows this component; otherwise hides this component. @see #isVisible @since JDK1.1
Class Component, String toString()

Returns a string representation of this component and its values. @return a string representation of this component. @since JDK1.0
Class Component, void transferFocus()

Transfers the focus to the next component as though this Component were the focus owner. @see java.awt.Component#requestFocus() @since JDK1.1s1
Class Component, void update(Graphics)

Updates this component.

The AWT calls the update method in response to a call to repaint. The appearance of the component on the screen has not changed since the last call to update or paint. You can assume that the background is not cleared.

The updatemethod of Component doescalls this thecomponent's following:paint method to Clearsredraw this component. byThis method filling it with the backgroundis commonly overridden by subclasses color.which Setsneed the color of the graphics contextto do additional work in response to bea thecall to foregroundrepaint. colorSubclasses of thisComponent component.that Callsoverride this component'smethod paintshould method toeither call completelysuper.update(g) redraw thisor call component.paint directly.

The origin of the graphics context its (0  0) coordinate point is the top-left corner of this component. The clipping region of the graphics context is the bounding rectangle of this component. @param g the specified context to use for updating. @see java.awt.Component#paint @see java.awt.Component#repaint() @since JDK1.0

Class Component, void validate()

Ensures that this component has a valid layout. This method is primarily intended to operate on instances of Container. @see java.awt.Component#invalidate @see java.awt.Component#doLayout() @see java.awt.LayoutManager @see java.awt.Container#validate @since JDK1.0

Class ComponentOrientation, ComponentOrientation getOrientation(Locale)

ReturnReturns the orientation that is appropriate for the given locale. @param locale used as a key to look up the orientation in an internalspecified resource bundle.locale
Class ComponentOrientation, ComponentOrientation getOrientation(ResourceBundle)

ReturnReturns the orientation appropriate for the given ResourceBundle's localization. Three approaches are tried innin the following order:
  1. Retrieve a ComponentOrientation object from the ResourceBundle using the string "Orientation" as the key.
  2. Use the ResourceBundle.getLocale to determine the bundle's locale then return the orientation for that locale.
  3. Return the default locale's orientation.
@deprecated As of J2SE 1.4 use #getOrientation(java.util.Locale)

Class Container

A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT components.

Components added to a container are tracked in a list. The order of the list will define the components' front-to-back stacking order within the container. If no index is specified when adding a component to a container it will be added to the end of the list (and hence to the bottom of the stacking order). @version 1.181 04222 12/0603/0001 @author Arthur van Hoff @author Sami Shaio @see java.awt.Container#add(java.awt.Component int) @see java.awt.Container#getComponent(int) @see java.awt.LayoutManager @since JDK1.0


Class Container.AccessibleAWTContainer.AccessibleContainerHandler

Fire PropertyChange listener if one is registered when children are added/ or removed.

Class Container.AccessibleAWTContainer, Accessible getAccessibleAt(Point)

Returns the Accessible child if one exists contained at the local coordinate Point. @param p Thethe point defining the top-left corner of the Accessible given in the coordinate space of the object's parent. @return the Accessible if it exists at the specified location; else null
Class Container.AccessibleAWTContainer, Accessible getAccessibleChild(int)

ReturnReturns the nth Accessible child of the object. @param i zero-based index of child @return the nth Accessible child of the object
Class Container.AccessibleAWTContainer, int getAccessibleChildrenCount()

Returns the number of accessible children in the object. If all of the children of this object implement Accessible thanthen this method should return the number of children of this object. @return the number of accessible children in the object.

Class Container, Component add(Component)

AddsAppends the specified component to the end of this container. This is a convenience method for #addImpl @param comp the component to be added. @see #addImpl @return the component argument.
Class Container, void add(Component, Object)

Adds the specified component to the end of this container. Also notifies the layout manager to add the component to this container's layout using the specified constraints object. This is a convenience method for #addImpl @param comp the component to be added @param constraints an object expressing layout contraints for this component @see java.awt.#addImpl @see LayoutManager @since JDK1.1
Class Container, void add(Component, Object, int)

Adds the specified component to this container with the specified constraints at the specified index. Also notifies the layout manager to add the component to the this container's layout using the specified constraints object. This is a convenience method for #addImpl @param comp the component to be added @param constraints an object expressing layout contraints for this @param index the position in the container's list at which to insert the component. -1 means insert at the end. component @see #addImpl @see #remove @see LayoutManager
Class Container, Component add(Component, int)

Adds the specified component to this container at the given position. This is a convenience method for #addImpl @param comp the component to be added. @param index the position at which to insert the component or -1 to insertappend the component atto the end. @return the component comp @see #addImpl @see #remove
Class Container, Component add(String, Component)

Adds the specified component to this container. ItThis is stronglya advised to useconvenience method for the#addImpl

This method is obsolete as of 1.1. Please use the method add(Component Object) in place of this methodinstead.

Class Container, void addContainerListener(ContainerListener)

Adds the specified container listener to receive container events from this container. If l is null no exception is thrown and no action is performed. @param l the container listener @see #removeContainerListener @see #getContainerListeners
Class Container, void addImpl(Component, Object, int)

Adds the specified component to this container at the specified index. This method also notifies the layout manager to add the component to this container's layout using the specified constraints object via the addLayoutComponent method. The constraints are defined by the particular layout manager being used. For example the BorderLayout class defines five constraints: BorderLayout.NORTH BorderLayout.SOUTH BorderLayout.EAST BorderLayout.WEST and BorderLayout.CENTER.

Note that if the component already exists in this container or a child of this container it is removed from that container before being added to this container.

This is the method to override if a program needs to track every add request to a container as all other add methods defer to this one. An overriding method should usually include a call to the superclass's version of the method:

super.addImpl(comp constraints index)

@param comp the component to be added. @param constraints an object expressing layout contraintsconstraints for this component. @param index the position in the container's list at which to insert the component where -1 means insert atappend to the end. @exception IllegalArgumentException if index is invalid @exception IllegalArgumentException if adding the container's parent to itself @exception IllegalArgumentException if adding a window to a container @see java.awt.Container#add(java.awt.Component) @see java.awt.Container#add(java.awt.Component int) @see java.awt.Container#add(java.awt.Component java.lang.Object) @see java.awt.LayoutManager @see LayoutManager2 @since JDK1.1

Class Container, void doLayout()

Causes this container to lay out its components. Most programs should not call this method directly but should invoke the validate method instead. @see java.awt.LayoutManager#layoutContainer @see #setLayout @see #validate @since JDK1.1
Class Container, Component findComponentAt(Point)

Locates the visible child component that contains the specified point. The top-most child component is returned in the case where there is overlap in the components. If the containing child component is a Container this method will continue searching for the deepest nested child component. Components which are not visible are ignored during the search.

The findComponentAt method is different from getComponentAt in that getComponentAt only searches the Container's immediate children; if the containing component is a Container findComponentAt will search that child to find a nested component. @param p the point. @return null if the component does not contain the position. If there is no child component at the requested point and the point is within the bounds of the container the container itself is returned. @see Component#contains @see #getComponentAt @since 1.2

Class Container, Component findComponentAt(int, int)

Locates the visible child component that contains the specified position. The top-most child component is returned in the case where there is overlap in the components. If the containing child component is a Container this method will continue searching for the deepest nested child component. Components which are not visible are ignored during the search.

The findComponentAt method is different from getComponentAt in that getComponentAt only searches the Container's immediate children; if the containing component is a Container findComponentAt will search that child to find a nested component. @param x the x coordinate @param y the y coordinate @return null if the component does not contain the position. If there is no child component at the requested point and the point is within the bounds of the container the container itself is returned. @see Component#contains @see #getComponentAt @since 1.2

Class Container, Component getComponentAt(Point)

Gets the component that contains the specified point. @param p the point. @return returns the component that contains the point or null if the component does not contain the point. @see java.awt.Component#contains @since JDK1.1
Class Container, int getComponentCount()

Gets the number of components in this panel. @return the number of components in this panel. @see java.awt.Container#getComponent @since JDK1.1
Class Container, Insets getInsets()

Determines the insets of this container which indicate the size of the container's border.

A Frame object for example has a top inset that corresponds to the height of the frame's title bar. @return the insets of this container. @see java.awt.Insets @see java.awt.LayoutManager @since JDK1.1

Class Container, EventListener[] getListeners(Class)

ReturnReturns an array of all the listenersobjects that were addedcurrently registered as toFooListeners the Containerupon this withContainer. addXXXListener()FooListeners where XXX isare registered using the nameaddFooListener ofmethod.

You can specify the listenerType argument. For example to get all ofwith a class literal such as theFooListener.class. ContainerListener(s)For forexample theyou can givenquery a Container c onefor its container listeners with wouldthe following writecode:

 ContainerListener[] cls = (ContainerListener[])(c.getListeners(ContainerListener.class)) ;
If no such listenerlisteners exist list exists thenthis method returns an empty array is returned. @param listenerType Typethe type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener @return allan array of theall objects registered as FooListeners on this container or an empty array if no such listeners of the specifiedhave been added type@exception supported byClassCastException if thislistenerType
containerdoesn't specify a class or interface that implements java.util.EventListener @see #getContainerListeners @since 1.3
Class Container, Dimension getMinimumSize()

Returns the minimum size of this container. @return an instance of Dimension that represents the minimum size of this container. @see java.awt.Container#getPreferredSize @see java.awt.Container#getLayout @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container) @see java.awt.Component#getMinimumSize @since JDK1.1
Class Container, Dimension getPreferredSize()

Returns the preferred size of this container. @return an instance of Dimension that represents the preferred size of this container. @see java.awt.Container#getMinimumSize @see java.awt.Container#getLayout @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container) @see java.awt.Component#getPreferredSize
Class Container, void list(PrintStream, int)

Prints a listing of this container to the specified output stream. The listing starts at the specified indentation. @param out a print stream. @param indent the number of spaces to indent. @see java.awt.Component#list(java.io.PrintStream int) @since JDKJDK1.0
Class Container, void paint(Graphics)

Paints the container. This forwards the paint to any lightweight components that are children of this container. If this method is reimplemented super.paint(g) should be called so that lightweight components are properly rendered. If a child component is entirely clipped by the current clipping setting in g paint() will not be forwarded to that child. @param g the specified Graphics window @see java.awt.Component#update(java.awt.Graphics)
Class Container, void paintComponents(Graphics)

Paints each of the components in this container. @param g the graphics context. @see java.awt.Component#paint @see java.awt.Component#paintAll
Class Container, String paramString()

Returns the parametera string representing the state of this containerContainer. This stringmethod is usefulintended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null. @return the parameter string of this container.
Class Container, void print(Graphics)

Prints the container. This forwards the print to any lightweight components that are children of this container. If this method is reimplemented super.print(g) should be called so that lightweight components are properly rendered. If a child component is entirely clipped by the current clipping setting in g print() will not be forwarded to that child. @param g the specified Graphics window @see java.awt.Component#update(java.awt.Graphics)
Class Container, void printComponents(Graphics)

Prints each of the components in this container. @param g the graphics context. @see java.awt.Component#print @see java.awt.Component#printAll
Class Container, void processContainerEvent(ContainerEvent)

Processes container events occurring on this container by dispatching them to any registered ContainerListener objects. NOTE: This method will not be called unless container events are enabled for this component; this happens when one of the following occurs: a) Component#enableEvents

Note that if the event parameter is null the behavior is unspecified and may result in an exception. @param e the container event @see Component#enableEvents

Class Container, void processEvent(AWTEvent)

Processes events on this container. If the event is a ContainerEvent it invokes the processContainerEvent method else it invokes its superclass's processEvent.

Note that if the event parameter is null the behavior is unspecified and may result in an exception. @param e the event

Class Container, void removeContainerListener(ContainerListener)

Removes the specified container listener so it no longer receives container events from this container. If l is null no exception is thrown and no action is performed. @param l the container listener @see #addContainerListener @see #getContainerListeners
Class Container, void update(Graphics)

Updates the container. This forwards the update to any lightweight components that are children of this container. If this method is reimplemented super.update(g) should be called so that lightweight components are properly rendered. If a child component is entirely clipped by the current clipping setting in g update() will not be forwarded to that child. @param g the specified Graphics window @see java.awt.Component#update(java.awt.Graphics)

Class Cursor

A class to encapsulate the bitmap representation of the mouse cursor. @see Component#setCursor @version 1.30 0236 12/0203/0001 @author Amy Fowler
Class Cursor, constructor Cursor(int)

Creates a new cursor object with the specified type. @param type the type of cursor @throws IllegalArgumentException if the specified cursor type is invalid
Class Cursor, Cursor getPredefinedCursor(int)

Returns a cursor object with the specified predefined type. @param type the type of predefined cursor @throws IllegalArgumentException if the specified cursor type is invalid
Class Cursor, Cursor getSystemCustomCursor(String)

@return the system specific custom Cursor named Cursor names are for example: "Invalid.16x16" @exception HeadlessException if GraphicsEnvironment.isHeadless returns true

Class Dialog

A Dialog is a top-level window with a title and a border that is typically used to take some form of input from the user. The size of the dialog includes any area designated for the border. The dimensions of the border area can be obtained using the getInsets method however since these dimensions are platform-dependent a valid insets value cannot be obtained until the dialog is made displayable by either calling pack or show. Since the border area is included in the overall size of the dialog the border effectively obscures a portion of the dialog constraining the area available for rendering and/or displaying subcomponents to the rectangle which has an upper-left corner location of (insets.left insets.top) and has a size of width - (insets.left + insets.right) by height - (insets.top + insets.bottom).

The default layout for a dialog is BorderLayout.

A dialog may have its native decorations (i.e. Frame & Titlebar) turned off with setUndecorated. This can only be done while the dialog is not displayable

A dialog must have either a frame or another dialog defined as its owner when it's constructed. When the owner window of a visible dialog is hidden or minimized the dialog will automatically be hidden from the user. When the owner window is subsequently re-opened thenrestored the dialog is made visible to the user again.

In a multi-screen environment you can create a Dialog on a different screen device than its owner. See java.awt.Frame for more information.

A dialog can be either modeless (the default) or modal. A modal dialog is one which blocks input to all other toplevel windows in the appapplication context except for any windows created with the dialog as their owner.

Dialogs are capable of generating the following window eventsWindowEvents: WindowOpened WindowClosing WindowClosed WindowActivated WindowDeactivated WindowGainedFocus WindowLostFocus. @see WindowEvent @see Window#addWindowListener @version 1.69 0483 12/2103/01 @author Sami Shaio @author Arthur van Hoff @since JDK1.0

Class Dialog, constructor Dialog(Dialog)

Constructs an initially invisible non-modal Dialog with an empty title and the specified owner dialog. @param owner the owner of the dialog @exception java.lang.IllegalArgumentException if owner is null. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @since 1.2
Class Dialog, constructor Dialog(Dialog, String)

Constructs an initially invisible non-modal Dialog with the specified owner dialog and title. @param owner the owner of the dialog @param title the title of the dialog. A null value will be accepted without causing a NullPointerException to be thrown. @exception java.lang.IllegalArgumentException if owner is null. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @since 1.2
Class Dialog, constructor Dialog(Dialog, String, boolean)

Constructs an initially invisible Dialog with the specified owner dialog title and modality. @param owner the owner of the dialog @exception IllegalArgumentException if the owner's GraphicsConfiguration is not from a screen device @param title the title of the dialog. A; a null value will be accepted without causing a NullPointerException to be thrown. @param modal if true dialog blocks input to other app windows when shown @exception java.lang.IllegalArgumentException if owner is null; this exception is always thrown when GraphicsEnvironment.isHeadless returns true @see java.awt.GraphicsEnvironment#isHeadless @since 1.2
Class Dialog, constructor Dialog(Frame)

Constructs an initially invisible non-modal Dialog with an empty title and the specified owner frame. @param owner the owner of the dialog @exception IllegalArgumentException if the owner's GraphicsConfiguration is not from a screen device @exception java.lang.IllegalArgumentException if owner is null; this exception is always thrown when GraphicsEnvironment.isHeadless returns true @see java.awt.GraphicsEnvironment#isHeadless @see Component#setSize @see Component#setVisible
Class Dialog, constructor Dialog(Frame, String)

Constructs an initially invisible non-modal Dialog with the specified owner frame and title. @param owner the owner of the dialog @param title the title of the dialog. A; a null value will be accepted without causing a NullPointerException to be thrown. @exception IllegalArgumentException if the owner's GraphicsConfiguration is not from a screen device @exception java.lang.IllegalArgumentException if owner is null; this exception is always thrown when GraphicsEnvironment.isHeadless returns true @see java.awt.GraphicsEnvironment#isHeadless @see Component#setSize @see Component#setVisible
Class Dialog, constructor Dialog(Frame, String, boolean)

Constructs an initially invisible Dialog with the specified owner frame title and modality. @param owner the owner of the dialog @param title the title of the dialog. A; a null value will be accepted without causing a NullPointerException to be thrown. @param modal if true dialog blocks input to other app windows when shown @exception IllegalArgumentException if the owner's GraphicsConfiguration is not from a screen device @exception java.lang.IllegalArgumentException if owner is null. This exception is always thrown when GraphicsEnvironment.isHeadless returns true @see java.awt.GraphicsEnvironment#isHeadless @see Component#setSize @see Component#setVisible
Class Dialog, constructor Dialog(Frame, boolean)

Constructs an initially invisible Dialog with an empty title the specified owner frame and modality. @param owner the owner of the dialog @param modal if true dialog blocks input to other app windows when shown @exception IllegalArgumentException if the owner's GraphicsConfiguration is not from a screen device @exception java.lang.IllegalArgumentException if owner is null; this exception is always thrown when GraphicsEnvironment.isHeadless returns true @see java.awt.GraphicsEnvironment#isHeadless
Class Dialog, boolean isModal()

Indicates whether the dialog is modal. When a modal Dialog is made visible user input will be blocked to the other windows in the appapplication context except for any windows created with this dialog as their owner. @return true if this dialog window is modal; false otherwise. @see java.awt.Dialog#setModal
Class Dialog, String paramString()

Returns the parametera string representing the state of this dialog window. This stringmethod is usefulintended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null. @return the parameter string of this dialog window.
Class Dialog, void setTitle(String)

Sets the title of the Dialog. @param title the title displayed in the dialog's border; a null value results in an empty title @see #getTitle

Class Dimension

The Dimension class encapsulates the width and height of a component (in integer precision) in a single object. The class is associated with certain properties of components. Several methods defined by the Component class and the LayoutManager interface return a Dimension object.

Normally the values of width and height are non-negative integers. The constructors that allow you to create a dimension do not prevent you from setting a negative value for these properties. If the value of width or height is negative the behavior of some methods defined by other objects is undefined. @version 1.26 0230 12/0203/0001 @author Sami Shaio @author Arthur van Hoff @see java.awt.Component @see java.awt.LayoutManager @since JDK1.0

Class Dimension, constructor Dimension(Dimension)

Creates an instance of Dimension whose width and height are the same as for the specified dimension. @param d the specified dimension for the width and height values.
Class Dimension, constructor Dimension(int, int)

Constructs a Dimension and initializes it to the specified width and specified height. @param width the specified width dimension @param height the specified height dimension
Class Dimension, double getHeight()

Returns the height of this dimension in double precision. @return the height of this dimension in double precision
Class Dimension, Dimension getSize()

Gets the size of this Dimension object. This method is included for completeness to parallel the getSize method defined by Component. @return the size of this dimension a new instance of Dimension with the same width and height. @see java.awt.Dimension#setSize @see java.awt.Component#getSize @since JDK1.1
Class Dimension, double getWidth()

Returns the width of this dimension in double precision. @return the width of this dimension in double precision
Class Dimension, int hashCode()

Returns the hash code for this Dimension. @return a hash code for this Dimension.
Class Dimension, void setSize(Dimension)

SetSets the size of this Dimension object to the specified size. This method is included for completeness to parallel the setSize method defined by Component. @param d the new size for this Dimension object. @see java.awt.Dimension#getSize @see java.awt.Component#setSize @since JDK1.1
Class Dimension, void setSize(double, double)

SetSets the size of this Dimension object to the specified width and height in double precision. Note that if width or height are larger than Integer.MAX_VALUE they will be reset to Integer.MAX_VALUE. @param width the new width for the Dimension object @param height the new height for the Dimension object
Class Dimension, void setSize(int, int)

SetSets the size of this Dimension object to the specified width and height. This method is included for completeness to parallel the setSize method defined by Component. @param width the new width for this Dimension object. @param height the new height for this Dimension object. @see java.awt.Dimension#getSize @see java.awt.Component#setSize @since JDK1.1
Class Dimension, String toString()

Returns a string representation of the values of this Dimension object's height and width fields. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null. @return a string representation of this Dimension object.
Class Dimension, int height

The height dimension. Negative; negative values can be used. @serial @see #getSize @see #setSize
Class Dimension, int width

The width dimension. Negative; negative values can be used. @serial @see #getSize @see #setSize

Class Event

NOTE: The Event class is obsolete and is available only for backwards compatilibility. It has been replaced by the AWTEvent class and its subclasses.

Event is a platform-independent class that encapsulates events from the platform's Graphical User Interface in the Java 1.0 event model. In Java 1.1 and later versions the Event class is maintained only for backwards compatibilty. The information in this class description is provided to assist programmers in converting Java 1.0 programs to the new event model.

In the Java 1.0 event model an event contains an Event#id field that indicates what type of event it is and which other Event variables are relevant for the event.

For keyboard events Event#key contains a value indicating which key was activated and Event#modifiers contains the modifiers for that event. For the KEY_PRESS and KEY_RELEASE event ids the value of key is the unicode character code for the key. For KEY_ACTION and KEY_ACTION_RELEASE the value of key is one of the defined action-key identifiers in the Event class (PGUP PGDN F1 F2 etc). @version 1.68 0272 12/0203/0001 @author Sami Shaio @since JDK1.0

Class Event, constructor Event(Object, int, Object)

NOTE: The Event class is obsolete and is available only for backwards compatilibility. It has been replaced by the AWTEvent class and its subclasses.

Creates an instance of Event with the specified target component event type and argument. @param target the target component. @param id the event type. @param arg the specified argument.

Class Event, constructor Event(Object, long, int, int, int, int, int)

NOTE: The Event class is obsolete and is available only for backwards compatilibility. It has been replaced by the AWTEvent class and its subclasses.

Creates an instance of Event with the specified target component time stamp event type x and y coordinates keyboard key state of the modifier keys and an argument set to null. @param target the target component. @param when the time stamp. @param id the event type. @param x the x coordinate. @param y the y coordinate. @param key the key pressed in a keyboard event. @param modifiers the state of the modifier keys.

Class Event, constructor Event(Object, long, int, int, int, int, int, Object)

NOTE: The Event class is obsolete and is available only for backwards compatilibility. It has been replaced by the AWTEvent class and its subclasses.

Creates an instance of Event with the specified target component time stamp event type x and y coordinates keyboard key state of the modifier keys and argument. @param target the target component. @param when the time stamp. @param id the event type. @param x the x coordinate. @param y the y coordinate. @param key the key pressed in a keyboard event. @param modifiers the state of the modifier keys. @param arg the specified argument.

Class Event, boolean controlDown()

NOTE: The Event class is obsolete and is available only for backwards compatilibility. It has been replaced by the AWTEvent class and its subclasses.

Checks if the Control key is down. @return true if the key is down; false otherwise. @see java.awt.Event#modifiers @see java.awt.Event#shiftDown @see java.awt.Event#metaDown

Class Event, boolean metaDown()

NOTE: The Event class is obsolete and is available only for backwards compatilibility. It has been replaced by the AWTEvent class and its subclasses.

Checks if the Meta key is down. @return true if the key is down; false otherwise. @see java.awt.Event#modifiers @see java.awt.Event#shiftDown @see java.awt.Event#controlDown

Class Event, String paramString()

ReturnsNOTE: The Event class is obsolete and is available only for backwards compatilibility. It has been replaced by the parameterAWTEvent class and its subclasses.

Returns a string representing the state of this eventEvent. This stringmethod is usefulintended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null. @return the parameter string of this event.

Class Event, boolean shiftDown()

NOTE: The Event class is obsolete and is available only for backwards compatilibility. It has been replaced by the AWTEvent class and its subclasses.

Checks if the Shift key is down. @return true if the key is down; false otherwise. @see java.awt.Event#modifiers @see java.awt.Event#controlDown @see java.awt.Event#metaDown

Class Event, String toString()

NOTE: The Event class is obsolete and is available only for backwards compatilibility. It has been replaced by the AWTEvent class and its subclasses.

Returns a representation of this event's values as a string. @return a string that represents the event and the values of its member fields. @see java.awt.Event#paramString @since JDK1.1

Class Event, void translate(int, int)

NOTE: The Event class is obsolete and is available only for backwards compatilibility. It has been replaced by the AWTEvent class and its subclasses.

Translates this event so that its x and y coordinates are increased by dx and dy respectively.

This method translates an event relative to the given component. This involves at a minimum translating the coordinates into the local coordinate system of the given component. It may also involve translating a region in the case of an expose event. @param dx the distance to translate the x coordinate. @param dy the distance to translate the y coordinate.

Class Event, Object arg

An arbitrary argument of the event. The value of this field depends on the type of event. arg has been replaced bby event specific property. @serial

Class EventQueue

EventQueue is a platform-independent class that queues events both from the underlying peer classes and from trusted application classes.

It encapsulates asynchronous event dispatch machinery which extracts events from the queue and dispatches them by calling dispatchEvent(AWTEvent) method on this EventQueue with the event to be dispatched as an argument. The particular behavior of this machinery is implementation-dependent. The only requirements are that events which were actually enqueued to this queue (note that events being posted to the EventQueue can be coalesced) are dispatched:

Sequentially.
That is it is not permitted that several events from this queue are dispatched simultaneously.
In the same order as they are enqueued.
That is if AWTEvent A is enqueued to the EventQueue before AWTEvent B then event B will not be dispatched before event A.

Some browsers partition applets in different code bases into separate contexts and establish walls between these contexts. In such a scenario there will be one EventQueue per context. Other browsers place all applets into the same context implying that there will be only a single global EventQueue for all applets. This behavior is implementation-dependent. Consult your browser's documentation for more information. @author Thomas Ball @author Fred Ecks @author David Mendenhall @version 1.71 0282 12/0903/01 @since 1.1

Class EventQueue, void dispatchEvent(AWTEvent)

DispatchDispatches an event. The manner in which the event is dispatched depends upon the type of the event and the type of the event's source object:

Event Type Source Type Dispatched To
ActiveEvent Any event.dispatch()
Other Component source.dispatchEvent(AWTEvent)
Other MenuComponent source.dispatchEvent(AWTEvent)
Other Other No action (ignored)

@param theEvent an instance of java.awt.AWTEvent or a subclass of it.
Class EventQueue, AWTEvent getNextEvent()

RemoveRemoves an event from the EventQueue and returnreturns it. This method will block until an event has been posted by another thread. @return the next AWTEvent @exception InterruptedException if another thread has interrupted this thread.
Class EventQueue, void invokeAndWait(Runnable)

Causes runnable to have its run() method called in the dispatch thread of the EventQueue. This will happen after all pending events are processed. The call blocks until this has happened. This method will throw an Error if called from the event dispatcher thread. @param runnable the Runnable whose run() method should be executed synchronously on the EventQueue @exception InterruptedException if another thread has interrupted this thread @exception InvocationTargetException if an exception is thrown when running runnable @see #invokeLater @since 1.2
Class EventQueue, void invokeLater(Runnable)

Causes runnable to have its run() method called in the dispatch thread of the EventQueue. This will happen after all pending events are processed. @param runnable the Runnable whose run() method should be executed synchronously on the EventQueue @see #invokeAndWait @since 1.2
Class EventQueue, boolean isDispatchThread()

Returns true if the calling thread is the current AWT EventQueue's dispatch thread. Use this call the ensure that a given task is being executed (or not being) on the current AWT EventDispatchThread. @return true if running on the current AWT EventQueue's dispatch thread.
Class EventQueue, AWTEvent peekEvent()

ReturnReturns the first event on the EventQueue without removing it. @return the first event
Class EventQueue, AWTEvent peekEvent(int)

ReturnReturns the first event with the specified id if any. @param id the id of the type of event desired. @return the first event of the specified id or null if there is no such event
Class EventQueue, void pop()

StopStops dispatching events using this EventQueue instance. Any pending events are transferred to the previous EventQueue for processing.

Warning: To avoid deadlock do not bydeclare itthis method synchronized in a subclass. @exception EmptyStackException if no previous push was made on this EventQueue. @see java.awt.EventQueue#push

Class EventQueue, void postEvent(AWTEvent)

PostPosts a 1.1-style event to the EventQueue. If there is an existing event on the queue with the same ID and event source the source Component's coalesceEvents method will be called. @param theEvent an instance of java.awt.AWTEvent or a subclass of it.
Class EventQueue, void push(EventQueue)

ReplaceReplaces the existing EventQueue with the specified one. Any pending events are transferred to the new EventQueue for processing by it. @param newEventQueue an EventQueue (or subclass thereof) instance to be used.use @see java.awt.EventQueue#pop

Class FileDialog

The FileDialog class displays a dialog window from which the user can select a file.

Since it is a modal dialog when the application calls its show method to display the dialog it blocks the rest of the application until the user has chosen a file. @see Window#show @version 1.43 0249 12/0203/0001 @author Sami Shaio @author Arthur van Hoff @since JDK1.0

Class FileDialog, constructor FileDialog(Frame)

Creates a file dialog for loading a file. The title of the file dialog is initially empty. This is a convenience method for FileDialog(parent "" LOAD). @param parent the owner of the dialog @since JDK1.1
Class FileDialog, constructor FileDialog(Frame, String)

Creates a file dialog window with the specified title for loading a file. The files shown are those in the current directory. This is a convenience method for FileDialog(parent title LOAD). @param parent the owner of the dialog. @param title the title of the dialog.
Class FileDialog, constructor FileDialog(Frame, String, int)

Creates a file dialog window with the specified title for loading or saving a file.

If the value of mode is LOAD then the file dialog is finding a file to read and the files shown are those in the current directory. If the value of mode is SAVE the file dialog is finding a place to write a file. @param parent the owner of the dialog. @param title the title of the dialog. @param mode the mode of the dialog; either FileDialog.LOAD or FileDialog.SAVE @exception IllegalArgumentException if an illegal file dialog mode is supplied @see java.awt.FileDialog#LOAD @see java.awt.FileDialog#SAVE

Class FileDialog, String getDirectory()

Gets the directory of this file dialog. @return the (potentially null or invalid) directory of this FileDialog. @see java.awt.FileDialog#setDirectory
Class FileDialog, String getFile()

Gets the selected file of this file dialog. If the user selected CANCEL the returned file is null. @return the currently selected file of this file dialog window or null if none is selected. @see java.awt.FileDialog#setFile
Class FileDialog, FilenameFilter getFilenameFilter()

Determines this file dialog's filename filter. A filename filter allows the user to specify which files appear in the file dialog window. Filename filters do not function in Sun's reference implementation for Windows 95 98 or NT 4.0. @return this file dialog's filename filter. @see java.io.FilenameFilter @see java.awt.FileDialog#setFilenameFilter
Class FileDialog, int getMode()

Indicates whether this file dialog box is for loading from a file or for saving to a file. @return the mode of this file dialog window either FileDialog.LOAD or FileDialog.SAVE. @see java.awt.FileDialog#LOAD @see java.awt.FileDialog#SAVE @see java.awt.FileDialog#setMode
Class FileDialog, String paramString()

Returns the parametera string representing the state of this file dialogFileDialog window. This stringmethod is usefulintended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null. @return the parameter string of this file dialog window.
Class FileDialog, void setDirectory(String)

Sets the directory of this file dialog window to be the specified directory. Specifying a null or an invalid directory implies an implementation-defined default. This default will not be realized however until the user has selected a file. Until this point getDirectory() will return the value passed into this method.

Specifying "" as the directory is exactly equivalent to specifying null as the directory. @param dir the specificspecified directory. @see java.awt.FileDialog#getDirectory

Class FileDialog, void setFile(String)

Sets the selected file for this file dialog window to be the specified file. This file becomes the default file if it is set before the file dialog window is first shown.

Specifying "" as the file is exactly equivalent to specifying null as the file. @param file the file being set. @see java.awt.FileDialog#getFile

Class FileDialog, void setFilenameFilter(FilenameFilter)

Sets the filename filter for this file dialog window to the specified filter. Filename filters do not function in Sun's reference implementation for Windows 95 98 or NT 4.0. @param filter the specified filter. @see java.io.FilenameFilter @see java.awt.FileDialog#getFilenameFilter
Class FileDialog, void setMode(int)

Sets the mode of the file dialog. If mode is not a legal value an exception will be thrown and mode will not be set. @param mode the mode for this file dialog either FileDialog.LOAD or FileDialog.SAVE. @see java.awt.FileDialog#LOAD @see java.awt.FileDialog#SAVE @see java.awt.FileDialog#getMode @exception IllegalArgumentException if an illegal file dialog mode is used.supplied @since JDK1.1

Class FlowLayout

A flow layout arranges components in a left-to-right flow much like lines of text in a paragraph. Flow layouts are typically used to arrange buttons in a panel. It will arrange buttons left to right until no more buttons fit on the same line. Each line is centered.

For example the following picture shows an applet using the flow layout manager (its default layout manager) to position three buttons:

Graphic of Layout for Three Buttons

Here is the code for this applet:


 import java.awt.*; import java.applet.Applet; public class myButtons extends Applet { Button button1 button2 button3; public void init() { button1 = new Button("Ok"); button2 = new Button("Open"); button3 = new Button("Close"); add(button1); add(button2); add(button3); } } 

A flow layout lets each component assume its natural (preferred) size. @version 1.39 0243 12/0203/0001 @author Arthur van Hoff @author Sami Shaio @since JDK1.0

Class FlowLayout, constructor FlowLayout()

Constructs a new FlowFlowLayout Layout with a centered alignment and a default 5-unit horizontal and vertical gap.
Class FlowLayout, constructor FlowLayout(int)

Constructs a new Flow LayoutFlowLayout with the specified alignment and a default 5-unit horizontal and vertical gap. The value of the alignment argument must be one of FlowLayout.LEFT FlowLayout.RIGHT or FlowLayout.CENTER. @param align the alignment value
Class FlowLayout, constructor FlowLayout(int, int, int)

Creates a new flow layout manager with the indicated alignment and the indicated horizontal and vertical gaps.

The value of the alignment argument must be one of FlowLayout.LEFT FlowLayout.RIGHT or FlowLayout.CENTER. @param align the alignment value. @param hgap the horizontal gap between components. @param vgap the vertical gap between components.

Class FlowLayout, int getAlignment()

Gets the alignment for this layout. Possible values are FlowLayout.LEFT FlowLayout.RIGHT FlowLayout.CENTER FlowLayout.LEADING or FlowLayout.CENTERTRAILING. @return the alignment value for this layout. @see java.awt.FlowLayout#setAlignment @since JDK1.1
Class FlowLayout, int getHgap()

Gets the horizontal gap between components. @return the horizontal gap between components. @see java.awt.FlowLayout#setHgap @since JDK1.1
Class FlowLayout, int getVgap()

Gets the vertical gap between components. @return the vertical gap between components. @see java.awt.FlowLayout#setVgap @since JDK1.1
Class FlowLayout, void layoutContainer(Container)

Lays out the container. This method lets each component take its preferred size by reshaping the components in the target container in order to satisfy the constraints of this FlowLayout object. @param target the specified component being laid out. @see Container @see java.awt.Container#doLayout
Class FlowLayout, Dimension minimumLayoutSize(Container)

Returns the minimum dimensions needed to layout the visible components contained in the specified target container. @param target the component which needs to be laid out @return the minimum dimensions to lay out the subcomponents of the specified container. @see #preferredLayoutSize @see java.awt.Container @see java.awt.Container#doLayout
Class FlowLayout, Dimension preferredLayoutSize(Container)

Returns the preferred dimensions for this layout given the visible components in the specified target container. @param target the component which needs to be laid out @return the preferred dimensions to lay out the subcomponents of the specified container. @see Container @see #minimumLayoutSize @see java.awt.Container#getPreferredSize
Class FlowLayout, void setAlignment(int)

Sets the alignment for this layout. Possible values are @param align one of the alignment value.values shown above @see #getAlignment() @since JDK1.1
Class FlowLayout, String toString()

Returns a string representation of this FlowLayout object and its values. @return a string representation of this layout.
Class FlowLayout, int LEADING

This value indicates that each row of components should be justified to the leading edge of the container's orientation e.g.for example to the left in left-to-right orientations. @see java.awt.Component#getComponentOrientation @see java.awt.ComponentOrientation @since 1.2 Package-private pending API change approval
Class FlowLayout, int TRAILING

This value indicates that each row of components should be justified to the leadingtrailing edge of the container's orientation e.g.for example to the right in left-to-right orientations. @see java.awt.Component#getComponentOrientation @see java.awt.ComponentOrientation @since 1.2 Package-private pending API change approval

Class Font

The Font class represents fonts. The capabilities of this class have been extended over thewhich are used to render text in a visible java.awtway.Font class inA JDK(tm)font 1.1provides and earlier releasesthe information needed to provide formap developers thesequences of abilitycharacters to utilize more sophisticated typographicsequences features.of glyphs It is important to present the conceptsand to render sequences of glyphs on behindGraphics usingand theComponent wordsobjects. character

Characters and glyph separately.Glyphs

A character is a symbol that represents items like letters and numbers inan item such as a letter a particulardigit writingor systempunctuation in an abstract way. For example lowercase-'g' LATIN SMALL LETTER G is a character. When

A glyph is a particularshape characterused to hasrender beena character renderedor a shapesequence of characters. In simple writing systems such as Latin nowtypically one glyph represents thisone character. ThisIn shape is called ageneral however characters and glyphglyphs do not have one-to-one correspondence. For example Chararcterthe character encoding'á' isLATIN SMALL LETTER A WITH ACUTE can be represented by two glyphs: one for 'a' conversion table thatand one for maps'´'. On the other hand the two-character codesstring to"fi" can be represented by a single glyph codesan in"fi" ligature. In complex writing systems such as Arabic or the South and South-East Asian writing systems the relationship between characters and glyphs can be more complicated and involve context-dependent selection of glyphs as well as glyph reordering. A font encapsulates the collection of glyphs needed to render a selected set of characters as well as the tables needed to map sequences of characters to corresponding sequences of glyphs.

Physical and Logical Fonts

The Java 2 platform distinguishes between two kinds of fonts: physical fonts and logical fonts.

Physical fonts are the actual font libraries containing glyph data and tables to map from character encoding usedsequences to inglyph sequences using a font technology such as TrueType or PostScript Type 1. All implementations of the Java 2D(tm)2 APIplatform must support TrueType fonts; support for other font technologies is Unicodeimplementation dependent. For more information on Unicode you can visit the sitePhysical fonts may use names such as Helvetica Palatino HonMincho http://wwwor any number of other font names.unicode Typically each physical font supports only a limited set of writing systems for example only Latin characters or only Japanese and Basic Latin.org The set of available physical fonts varies between configurations. Applications Charactersthat require specific fonts can bundle them and glyphs do not haveinstantiate them using the one-to-onecreateFont correspondencemethod. For

exampleLogical lowercase-afonts acuteare canthe five font families defined by the Java platform which must be representedsupported by twoany glyphsJava runtime environment: lowercase-aSerif SansSerif Monospaced Dialog and acuteDialogInput. Another example is ligatures such asThese logical fonts are not actual ligaturefont -filibraries. whichInstead the logical font names are mapped to physical fonts by the Java runtime environment. The mapping is a single glyph representing twoimplementation and usually locale dependent charactersso the flook and ithe metrics provided by them vary. Typically each logical font name maps to several physical fonts in order to cover a large range of characters.

APeered FontAWT iscomponents such as Label and TextField can only use logical fonts.

For a collectiondiscussion of glyphsthe relative advantages and disadvantages of using physical or logical fonts see the Internationalization FAQ document.

Font Faces and Names

A Font can have many faces such as heavy medium oblique gothic and regular. All of these faces have similar typographic design.

There are three different names that you can get from a Font object. The logical font name is the same assimply the name that used by java.awt.Font inwas JDKused 1.1to and earlier releasesconstruct the font. The font face name or just font name for short is the name of a particular font face like Helvetica Bold. The family name is the name of the font family that determines the typographic design across several faces like Helvetica. The font face name is the one that should be used to specify fonts. This name signifies actual fonts in the host system and does not identify font names with the shape of font characters as the logical font name does.

The Font class represents an instance of a font face from a collection of font faces that are present in the system resources of the host system. As examples Arial Bold and Courier Bold Italic are font faces. There can be several Font objects associated with a font face each differing in size style transform and font features. The getAllFonts method of the GraphicsEnvironment class returns an array of all font faces available in the system. These font faces are returned as Font objects with a size of 1 identity transform and default font features. These base fonts can then be used to derive new Font objects with varying sizes styles transforms and font features via the deriveFont methods in this class. @see GraphicsEnvironment#getAllFonts @version 1.143 02171 12/1303/01

Class Font, constructor Font(String, int, int)

Creates a new Font from the specified name style and point size. @param name the font name. This can be a logical font name or a font face name. A logical name must be either: Dialog DialogInput Monospaced Serif SansSerif or SymbolSansSerif. If name is null the name of the new Font is set to the name "Default". @param style the style constant for the Font The style argument is an integer bitmask that may be PLAIN or a bitwise union of BOLD and/or ITALIC (for example ITALIC or BOLD|ITALIC). Any other bits set in the style parameter are ignored. If the style argument does not conform to one of the expected integer bitmasks then the style is set to PLAIN. @param size the point size of the Font @see GraphicsEnvironment#getAllFonts @see GraphicsEnvironment#getAvailableFontFamilyNames @since JDK1.0
Class Font, int canDisplayUpTo(CharacterIterator, int, int)

Indicates whether or not this Font can display the specified String. For strings with Unicode encoding it is important to know if a particular font can display the string. This method returns an offset into the String str which is the first character this Font cannot display without using the missing glyph code . If this Font can display all characters -1 is returned. @param textiter a CharacterIterator object @param start the specified starting offset into the specified array of characters @param limit the specified ending offset into the specified array of characters @return an offset into the String object that can be displayed by this Font. @since 1.2
Class Font, int canDisplayUpTo(char[], int, int)

Indicates whether or not this Font can display the characters in the specified text starting at start and ending at limit. This method is a convenience overload. @param text the specified array of characters @param start the specified starting offset into the specified array of characters @param limit the specified ending offset into the specified array of characters @return an offset into text that points to the first character in text that this Font cannot display; or -1 if this Font can display all characters in text. @since 1.2
Class Font, Font createFont(int, InputStream)

Returns a new Font with the specified font type and input data. The new Font is created with a point size of 1 and style PLAIN This base font can then be used with the deriveFont methods in this class to derive new Font objects with varying sizes styles transforms and font features. This method does not close the InputStream @param fontTypefontFormat the type of the Font which is TRUETYPE_FONT if a TrueType is desired. Other types might be provided in the future. @param fontStream an InputStream object representing the input data for the font. @return a new Font created with the specified font type. @throws IllegalArgumentException if fontType is not TRUETYPE_FONT @throws FontFormatException if the fontStream data does not contain the required Truetype font tables. @throws IOException if the fontStream cannot be completely read. @since 1.3
Class Font, GlyphVector createGlyphVector(FontRenderContext, CharacterIterator)

ReturnsCreates a new GlyphVector object by created withmapping the specified CharacterIteratorcharacters andto glyphs one-to-one based on the specifiedUnicode cmap in this FontRenderContextFont. This method does no other processing besides the mapping of glyphs to characters. This means that this method is not useful for some scripts such as Arabic Hebrew Thai and Indic that require reordering shaping or ligature substitution. @param frc the specified FontRenderContext @param ci the specified CharacterIterator @return a new GlyphVector created with the specified CharacterIterator and the specified FontRenderContext.
Class Font, GlyphVector createGlyphVector(FontRenderContext, String)

ReturnsCreates a new GlyphVector object createdby mapping withcharacters to glyphs one-to-one based on the specifiedUnicode cmap in this StringFont. andThis method does no other processing besides the specifiedmapping FontRenderContextof glyphs to characters. This means that this method is not useful for some scripts such as Arabic Hebrew Thai and Indic that require reordering shaping or ligature substitution. @param frc the specified FontRenderContext @param str the specified String @return a new GlyphVector created with the specified String and the specified FontRenderContext.
Class Font, GlyphVector createGlyphVector(FontRenderContext, char[])

ReturnsCreates a newGlyphVector by mapping characters to glyphs one-to-one based on the Unicode cmap in this GlyphVectorFont. object created with the specifiedThis method does no other arrayprocessing besides the mapping of glyphs to characters. This means that this method is not useful for some scripts such as Arabic Hebrew Thai and the specifiedIndic that FontRenderContextrequire reordering shaping or ligature substitution. @param frc the specified FontRenderContext @param chars the specified array of characters @return a new GlyphVector created with the specified array of characters and the specified FontRenderContext.
Class Font, GlyphVector createGlyphVector(FontRenderContext, int[])

ReturnsCreates a newGlyphVector by mapping characters to glyphs one-to-one based on the Unicode cmap in this GlyphVectorFont. object createdThis method withdoes no other processing besides the specified integermapping of arrayglyphs to characters. This means that this method is not useful for some scripts such as Arabic Hebrew Thai and the specifiedIndic that FontRenderContextrequire reordering shaping or ligature substitution. @param frc the specified FontRenderContext @param glyphcodesglyphCodes the specified integer array @return a new GlyphVector created with the specified integer array and the specified FontRenderContext.
Class Font, Font decode(String)

Returns the Font that the str argument describes. To ensure that this method returns the desired Font format the str parameter in one of two ways:

"fontfamilyname-style-pointsize" or
"fontfamilyname style pointsize"

in which style is one of the three case-insensitive strings: "BOLD" "BOLDITALIC" or "ITALIC" and pointsize is a decimal representation of the point size. For example if you want a font that is Arial bold and a point size of 18 you would call this method with: "Arial-BOLD-18".

The default size is 12 and the default style is PLAIN. If you don't specify a valid size the returned Font has a size of 12. If you don't specify a valid style the returned Font has a style of PLAIN. If you do not provide a valid font family name in the str argument this method still returns a valid font with a family name of "dialog". To determine what font family names are available on your system use the GraphicsEnvironment#getAvailableFontFamilyNames() method. If str is null a new Font is returned with the family name "dialog" a size of 12 and a PLAIN style. If str is null a new Font is returned with the name "dialog" a size of 12 and a PLAIN style. @param str the name of the font or null @return the Font object that str describes or a new default Font if str is null. @see #getFamily @since JDK1.1

Class Font, String getFamily()

Returns the family name of this Font. For

The examplefamily Helveticaname of coulda befont is font specific. Two returnedfonts such as aHelvetica Italic and Helvetica Bold have the same family name forHelvetica whereas thetheir font face namenames ofare Helvetica Bold and Helvetica Italic. The list of available family names may be obtained by using the GraphicsEnvironment#getAvailableFontFamilyNames() method.

Use getName to get the logical name of the font. Use getFontName to get the font face name of the font. @return a String that is the family name of this Font. @see #getName @see #getFontName @since JDK1.1

Class Font, String getFamily(Locale)

Returns the family name of this Font localized for the specified locale. For

The examplefamily Helveticaname of coulda befont is font specific. Two fonts returnedsuch as aHelvetica Italic and Helvetica Bold have the same family name forHelvetica thewhereas their font face name ofnames are Helvetica Bold and Helvetica Italic. The list of available family names may be obtained by using the GraphicsEnvironment#getAvailableFontFamilyNames() method.

Use getFontName to get the font face name of the font. @param l locale for which to get the family name @return a String representing the family name of the font localized for the specified locale. @see #getFontName @see java.util.Locale @since 1.2

Class Font, Font getFont(Map)

Returns a Font appropriate to this attribute set. @param attributes the attributes to assign to the new Font @return a new Font created with the specified attributes. @since 1.2 @see java.awt.font.TextAttribute
Class Font, Rectangle2D getStringBounds(CharacterIterator, int, int, FontRenderContext)

Returns the logical bounds of the characters indexed in the specified CharacterIterator in the specified FontRenderContext. The logical bounds iscontains the origin ascent advance and height which includes the leading. The logical bounds does not always enclose all the text. For example in some languages and in some fonts accent marks can be positioned above the ascent or below the descent. used toTo obtain layouta visual bounding box which encloses all the text use the getBounds method of StringTextLayout. @param ci the specified CharacterIterator @param beginIndex the initial offset in ci @param limit the end offset in ci @param frc the specified FontRenderContext @return a Rectangle2D that is the bounding box of the characters indexed in the specified CharacterIterator in the specified FontRenderContext. @see FontRenderContext @see Font#createGlyphVector @since 1.2 @throws IndexOutOfBoundsException if beginIndex is less than the start index of ci or limit is greater than the end index of ci or beginIndex is greater than limit
Class Font, Rectangle2D getStringBounds(String, FontRenderContext)

Returns the logical bounds of the specified String in the specified FontRenderContext. The logical bounds iscontains the origin ascent advance and height which includes the leading. The logical bounds does not always enclose all the text. For example in some languages and in some fonts accent marks can be positioned above the ascent or below the descent. To usedobtain toa visual bounding box which encloses all layoutthe text use the getBounds method of StringTextLayout. @param str the specified String @param frc the specified FontRenderContext @return a Rectangle2D that is the bounding box of the specified String in the specified FontRenderContext. @see FontRenderContext @see Font#createGlyphVector @since 1.2
Class Font, Rectangle2D getStringBounds(String, int, int, FontRenderContext)

Returns the logical bounds of the specified String in the specified FontRenderContext. The logical bounds iscontains the origin ascent advance and height which includes the leading. The logical bounds does not always enclose all the text. For example in some languages and in some fonts accent marks can be positioned above the ascent or below the descent. used toTo obtain layouta visual bounding box which encloses all the text use the getBounds method of StringTextLayout. @param str the specified String @param beginIndex the initial offset of str @param limit the end offset of str @param frc the specified FontRenderContext @return a Rectangle2D that is the bounding box of the specified String in the specified FontRenderContext. @throws IndexOutOfBoundsException if beginIndex is less than zero or limit is greater than the length of str or beginIndex is greater than limit. @see FontRenderContext @see Font#createGlyphVector @since 1.2
Class Font, Rectangle2D getStringBounds(char[], int, int, FontRenderContext)

Returns the logical bounds of the specified array of characters in the specified FontRenderContext. The logical bounds iscontains the origin ascent advance and used to layoutheight which includes the Stringleading. The logical bounds does created withnot always enclose all the specifiedtext. array of charactersFor example in beginIndexsome languages and in some fonts accent marks can be positioned above the ascent or below the descent. To obtain a visual bounding box which encloses all the text use the getBounds method of limitTextLayout. @param chars an array of characters @param beginIndex the initial offset in the array of characters @param limit the end offset in the array of characters @param frc the specified FontRenderContext @return a Rectangle2D that is the bounding box of the specified array of characters in the specified FontRenderContext. @throws IndexOutOfBoundsException if beginIndex is less than zero or limit is greater than the length of chars or beginIndex is greater than limit. @see FontRenderContext @see Font#createGlyphVector @since 1.2
Class Font, AffineTransform getTransform()

Returns a copy of the transform associated with this Font. @paramreturn an AffineTransform object representing the transform attribute of this Font object.
Class Font, int CENTER_BASELINE

The baseline used in ideographic scripts like Chinese Japanese and Korean when laying out text.
Class Font, int HANGING_BASELINE

The baseline used in Devanigiri and similar scripts when laying out text.
Class Font, int ROMAN_BASELINE

The baseline used in most Roman scripts when laying out text.

Class FontFormatException

Thrown by method createFont in the Font class to indicate that the specified font is bad. @author Parry Kejriwal @version 1.4 026 12/0203/0001 @see java.awt.Font @since 1.3
Class FontFormatException, constructor FontFormatException(String)

Report a FontFormatException for the reason specified. @param reason a String message indicating why the font is not accepted.

Class FontMetrics

The FontMetrics class defines a font metrics object which encapsulates information about the rendering of a particular font on a particular screen.

Note to subclassers: Since many of these methods form closed mutually recursive loops you must take care that you implement at least one of the methods in each such loop to prevent infinite recursion when your subclass is used. In particular the following is the minimal suggested set of methods to override in order to ensure correctness and prevent infinite recursion (though other subsets are equally feasible):

Note that the implementations of these methods are inefficient so they are usually overridden with more efficient toolkit-specific implementations.

When an application asks AWT to place a character at the position (x  y) the character is placed so that its reference point (shown as the dot in the accompanying image) is put at that position. The reference point specifies a horizontal line called the baseline of the character. In normal printing the baselines of characters should align.

In addition every character in a font has an ascent a descent and an advance width. The ascent is the amount by which the character ascends above the baseline. The descent is the amount by which the character descends below the baseline. The advance width indicates the position at which AWT should place the next character.

An array of characters or a string can also have an ascent a descent and an advance width. The ascent of the array is the maximum ascent of any character in the array. The descent is the maximum descent of any character in the array. The advance width is the sum of the advance widths of each of the characters in the character array. The advance of a String is the distance along the baseline of the String. This distance is the width that should be used for centering or right-aligning the String. Note that the advance of a String is not necessarily the sum of the advances of its characters measured in isolation because the width of a character can vary depending on its context. For example in Arabic text the shape of a character can change in order to connect to other characters. Also in some scripts certain character sequences can be represented by a single shape called a ligature. Measuring characters individually does not account for these transformations. @version 1.21 0347 12/1803/9801 @author Jim Graham @see java.awt.Font @since JDK1.0

Class FontMetrics, int charWidth(char)

Returns the advance width of the specified character in this Font. The advance is the distance from the leftmost point to the rightmost point on the character's baseline. Note that the advance of a String is not necessarily the sum of the advances of its characters. @param ch the character to be measured @return the advance width of the specified char in the Font described by this FontMetrics object. @see #charsWidth(char[] int int) @see #stringWidth(String)
Class FontMetrics, int getHeight()

Gets the standard height of a line of text in this font. This is the distance between the baseline of adjacent lines of text. It is the sum of the leading + ascent + descent. Due to rounding this may not be the same as getAscent() + getDescent() + getLeading(). There is no guarantee that lines of text spaced at this distance are disjoint; such lines may overlap if some characters overshoot either the standard ascent or the standard descent metric. @return the standard height of the font. @see #getLeading() @see #getAscent() @see #getDescent()
Class FontMetrics, int getMaxDecent()

For backward compatibility only. @return the maximum descent of any character in the Font. @see #getMaxDescent() @deprecated As of JDK version 1.1.1 replaced by getMaxDescent().

Class Frame

A Frame is a top-level window with a title and a border.

The size of the frame includes any area designated for the border. The dimensions of the border area canmay be obtained using the getInsets method however since these dimensions are platform-dependent a valid insets value cannot be obtained until the frame is made displayable by either calling pack or show. Since the border area is included in the overall size of the frame the border effectively obscures a portion of the frame constraining the area available for rendering and/or displaying subcomponents to the rectangle which has an upper-left corner location of (insets.left insets.top) and has a size of width - (insets.left + insets.right) by height - (insets.top + insets.bottom).

The default layout for a frame is BorderLayout.

A frame may have its native decorations (i.e. Frame and Titlebar) turned off with setUndecorated. This can only be done while the frame is not displayable

In a multi-screen environment you can create a Frame on a different screen device by constructing the Frame with #Frame(GraphicsConfiguration) or titl GraphicsConfiguration)}. The GraphicsConfiguration object is one of the GraphicsConfiguration objects of the target screen device.

In a virtual device multi-screen environment in which the desktop area could span multiple physical screen devices the bounds of all configurations are relative to the virtual-coordinate system. The origin of the virtual-coordinate system is at the upper left-hand corner of the primary physical screen. Depending on the location of the primary screen in the virtual device negative coordinates are possible as shown in the following figure.

ALIGN=center HSPACE=10 VSPACE=7

In such an environment when calling setLocation you must pass a virtual coordinate to this method. Similarly calling getLocationOnScreen on a Frame returns virtual device coordinates. Call the getBounds method of a GraphicsConfiguration to find its origin in the virtual coordinate system.

The following code sets the location of the Frame at (10 10) relative to the origin of the physical screen of the corresponding GraphicsConfiguration. If the bounds of the GraphicsConfiguration is not taken into account the Frame location would be set at (10 10) relative to the virtual-coordinate system and would appear on the primary physical screen which might be different from the physical screen of the specified GraphicsConfiguration.

 Frame f = new Frame(GraphicsConfiguration gc); Rectangle bounds = gc.getBounds(); f.setLocation(10 + bounds.x 10 + bounds.y); 

Frames are capable of generating the following types of window eventsWindowEvents: WindowOpened

@version 1.108 04131 12/0603/0001 @author Sami Shaio @see WindowEvent @see Window#addWindowListener @since JDK1.0
Class Frame, constructor Frame()

Constructs a new instance of Frame that is initially invisible. The title of the Frame is empty. @exception HeadlessException when GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless() @see Component#setSize @see Component#setVisible(boolean)
Class Frame, constructor Frame(GraphicsConfiguration)

Create a Frame with the specified GraphicsConfiguration of a screen device. @param gc the GraphicsConfiguration of the target screen device. If gc is null the system default GraphicsConfiguration is assumed. @exception IllegalArgumentException if gc is not from a screen device. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless() @since 1.3
Class Frame, constructor Frame(String)

Constructs a new initially invisible Frame object with the specified title. @param title the title to be displayed in the frame's border. A null value is treated as an empty string "". @exception IllegalArgumentException ifHeadlessException when gc is notGraphicsEnvironment.isHeadless() from areturns true screen@see devicejava.awt.GraphicsEnvironment#isHeadless() @see java.awt.Component#setSize @see java.awt.Component#setVisible(boolean) @see java.awt.GraphicsConfiguration#getBounds
Class Frame, constructor Frame(String, GraphicsConfiguration)

Constructs a new initially invisible Frame object with the specified title and a GraphicsConfiguration. @param title the title to be displayed in the frame's border. A null value is treated as an empty string "". @param gc the GraphicsConfiguration of the target screen device. If gc is null the system default GraphicsConfiguration is assumed. @exception IllegalArgumentException if gc is not from a screen device. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless() @see java.awt.Component#setSize @see java.awt.Component#setVisible(boolean) @see java.awt.GraphicsConfiguration#getBounds
Class Frame, Image getIconImage()

Gets the image to be displayed in the minimized icon for this frame. @return the icon image for this frame or null if this frame doesn't have an icon image. @see java.awt.Frame#setIconImage(Icon)
Class Frame, MenuBar getMenuBar()

Gets the menu bar for this frame. @return the menu bar for this frame or null if this frame doesn't have a menu bar. @see java.awt.Frame#setMenuBar(MenuBar)
Class Frame, int getState()

Gets the state of this frame (obsolete). @return

Frame.In older versions of JDK a frame state could only be NORMAL or ICONIFIED. Since JDK 1.4 set of ifsupported frame instates iconicis expanded and frame state; is represented as a bitwise mask.

For compatibility with old programs this method still returns Frame.NORMAL ifand Frame.ICONIFIED but it only reports the iconic state of the frame isother aspects in normalof frame state are not reported by this method. @seereturn java.awtFrame.NORMAL or Frame.ICONIFIED. @see #setState(int) @see #getExtendedState

Class Frame, String getTitle()

Gets the title of the frame. The title is displayed in the frame's border. @return the title of this frame or an empty string ("") if this frame doesn't have a title. @see java.awt.Frame#setTitle(String)
Class Frame, boolean isResizable()

Indicates whether this frame is resizable by the user. By default all frames are initially resizable. @return true if the user can resize this frame; false otherwise. @see java.awt.Frame#setResizable(boolean)
Class Frame, String paramString()

Returns thea parameterstring representing the Stringstate of this Frame. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null. @return the parameter string of this frame
Class Frame, void remove(MenuComponent)

Removes the specified menu bar from this frame. @param m the menu component to remove. If this parameterm is null then a NullPointerException is thrown and no action is taken.
Class Frame, void setIconImage(Image)

Sets the image to be displayed in the minimized icon for this frame. Not all platforms support the concept of minimizing a window. @param image the icon image to be displayed. If this parameter is null then the icon image is set to the default image which may vary with platform. @see java.awt.Frame#getIconImage
Class Frame, void setMenuBar(MenuBar)

Sets the menu bar for this frame to the specified menu bar. @param mb the menu bar being set. If this parameter is null then any existing menu bar on this frame is removed. @see java.awt.Frame#getMenuBar
Class Frame, void setState(int)

Sets the state of this frame (obsolete). @param

In older versions of JDK a frame state Frame.could only be NORMAL or ICONIFIED if. Since thisJDK 1.4 set of supported frame states is in iconicexpanded and frame state; is represented as a bitwise mask.

For compatibility with old programs this method still accepts Frame.NORMAL ifand thisFrame.ICONIFIED but it only changes the iconic state of the frame isother aspects in normalof frame state are not affected by this method. @seeparam java.awtstate either Frame.NORMAL or Frame.ICONIFIED. @see #getState @see #setExtendedState(int)

Class Frame, void setTitle(String)

Sets the title for this frame to the specified string. @param title the title to be displayed in the frame's border @param title the title to be displayed in the frame's border. A null value is treated as an empty string "". @see java.awt.Frame#getTitle

Class GradientPaint, constructor GradientPaint(Point2D, Color, Point2D, Color)

Constructs a simple acyclic GradientPaint object. @param pt1 the first specified Point in user space @param color1 Color at the first specified Point @param pt2 the second specified Point in user space @param color2 Color at the second specified Point @throws NullPointerException if either one of colors or points is null
Class GradientPaint, constructor GradientPaint(Point2D, Color, Point2D, Color, boolean)

Constructs either a cyclic or acyclic GradientPaint object depending on the boolean parameter. @param pt1 the first specified Point in user space @param color1 Color at the first specified Point @param pt2 the second specified Point in user space @param color2 Color at the second specified Point @param cyclic true if the gradient pattern should cycle repeatedly between the two colors; false otherwise @throws NullPointerException if either one of colors or points is null
Class GradientPaint, constructor GradientPaint(float, float, Color, float, float, Color)

Constructs a simple acyclic GradientPaint object. @param x1  y1 coordinates of the first specified Point in user space @param color1 Color at the first specified Point @param x2  y2 coordinates of the second specified Point in user space @param color2 Color at the second specified Point @throws NullPointerException if either one of colors is null

Class Graphics

The Graphics class is the abstract base class for all graphics contexts that allow an application to draw onto components that are realized on various devices as well as onto off-screen images.

A Graphics object encapsulates state information needed for the basic rendering operations that Java supports. This state information includes the following properties:

Class Graphics, boolean drawImage(Image, int, int, Color, ImageObserver)

Draws as much of the specified image as is currently available. The image is drawn with its top-left corner at (x  y) in this graphics context's coordinate space. Transparent pixels are drawn in the specified background color.

This operation is equivalent to filling a rectangle of the width and height of the specified image with the given color and then drawing the image on top of it but possibly more efficient.

This method returns immediately in all cases even if the complete image has not yet been loaded and it has not been dithered and converted for the current output device.

If the image has not yet been completely loaded then drawImage returns false. As more of the image becomes available the process that draws the image notifies the specified image observer. @param img the specified image to be drawn. @param x the x coordinate. @param y the y coordinate. @param bgcolor the background color to paint under the non-opaque portions of the image. @param observer object to be notified as more of the image is converted. @return true if the image is completely loaded; false otherwise. @see java.awt.Image @see java.awt.image.ImageObserver @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image int int int int int)

Class Graphics, boolean drawImage(Image, int, int, ImageObserver)

Draws as much of the specified image as is currently available. The image is drawn with its top-left corner at (x  y) in this graphics context's coordinate space. Transparent pixels in the image do not affect whatever pixels are already there.

This method returns immediately in all cases even if the complete image has not yet been loaded and it has not been dithered and converted for the current output device.

If the image has not yet been completely loaded then drawImage returns false. As more of the image becomes available the process that draws the image notifies the specified image observer. @param img the specified image to be drawn. @param x the x coordinate. @param y the y coordinate. @param observer object to be notified as more of the image is converted. @return true if the image is completely loaded; false otherwise. @see java.awt.Image @see java.awt.image.ImageObserver @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image int int int int int)

Class Graphics, boolean drawImage(Image, int, int, int, int, Color, ImageObserver)

Draws as much of the specified image as has already been scaled to fit inside the specified rectangle.

The image is drawn inside the specified rectangle of this graphics context's coordinate space and is scaled if necessary. Transparent pixels are drawn in the specified background color. This operation is equivalent to filling a rectangle of the width and height of the specified image with the given color and then drawing the image on top of it but possibly more efficient.

This method returns immediately in all cases even if the entire image has not yet been scaled dithered and converted for the current output device. If the current output representation is not yet complete then drawImage returns false. As more of the image becomes available the process that draws the image notifies the specified image observer.

A scaled version of an image will not necessarily be available immediately just because an unscaled version of the image has been constructed for this output device. Each size of the image may be cached separately and generated from the original data in a separate image production sequence. @param img the specified image to be drawn. @param x the x coordinate. @param y the y coordinate. @param width the width of the rectangle. @param height the height of the rectangle. @param bgcolor the background color to paint under the non-opaque portions of the image. @param observer object to be notified as more of the image is converted. @return true if the current output representation is complete; false otherwise. @see java.awt.Image @see java.awt.image.ImageObserver @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image int int int int int)

Class Graphics, boolean drawImage(Image, int, int, int, int, ImageObserver)

Draws as much of the specified image as has already been scaled to fit inside the specified rectangle.

The image is drawn inside the specified rectangle of this graphics context's coordinate space and is scaled if necessary. Transparent pixels do not affect whatever pixels are already there.

This method returns immediately in all cases even if the entire image has not yet been scaled dithered and converted for the current output device. If the current output representation is not yet complete then drawImage returns false. As more of the image becomes available the process that draws the image notifies the image observer by calling its imageUpdate method.

A scaled version of an image will not necessarily be available immediately just because an unscaled version of the image has been constructed for this output device. Each size of the image may be cached separately and generated from the original data in a separate image production sequence. @param img the specified image to be drawn. @param x the x coordinate. @param y the y coordinate. @param width the width of the rectangle. @param height the height of the rectangle. @param observer object to be notified as more of the image is converted. @return true if the current output representation is complete; false otherwise. @see java.awt.Image @see java.awt.image.ImageObserver @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image int int int int int)

Class Graphics, boolean drawImage(Image, int, int, int, int, int, int, int, int, Color, ImageObserver)

Draws as much of the specified area of the specified image as is currently available scaling it on the fly to fit inside the specified area of the destination drawable surface.

Transparent pixels are drawn in the specified background color. This operation is equivalent to filling a rectangle of the width and height of the specified image with the given color and then drawing the image on top of it but possibly more efficient.

This method returns immediately in all cases even if the image area to be drawn has not yet been scaled dithered and converted for the current output device. If the current output representation is not yet complete then drawImage returns false. As more of the image becomes available the process that draws the image notifies the specified image observer.

This method always uses the unscaled version of the image to render the scaled rectangle and performs the required scaling on the fly. It does not use a cached scaled version of the image for this operation. Scaling of the image from source to destination is performed such that the first coordinate of the source rectangle is mapped to the first coordinate of the destination rectangle and the second source coordinate is mapped to the second destination coordinate. The subimage is scaled and flipped as needed to preserve those mappings. @param img the specified image to be drawn @param dx1 the x coordinate of the first corner of the destination rectangle. @param dy1 the y coordinate of the first corner of the destination rectangle. @param dx2 the x coordinate of the second corner of the destination rectangle. @param dy2 the y coordinate of the second corner of the destination rectangle. @param sx1 the x coordinate of the first corner of the source rectangle. @param sy1 the y coordinate of the first corner of the source rectangle. @param sx2 the x coordinate of the second corner of the source rectangle. @param sy2 the y coordinate of the second corner of the source rectangle. @param bgcolor the background color to paint under the non-opaque portions of the image. @param observer object to be notified as more of the image is scaled and converted. @return true if the current output representation is complete; false otherwise. @see java.awt.Image @see java.awt.image.ImageObserver @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image int int int int int) @since JDK1.1

Class Graphics, boolean drawImage(Image, int, int, int, int, int, int, int, int, ImageObserver)

Draws as much of the specified area of the specified image as is currently available scaling it on the fly to fit inside the specified area of the destination drawable surface. Transparent pixels do not affect whatever pixels are already there.

This method returns immediately in all cases even if the image area to be drawn has not yet been scaled dithered and converted for the current output device. If the current output representation is not yet complete then drawImage returns false. As more of the image becomes available the process that draws the image notifies the specified image observer.

This method always uses the unscaled version of the image to render the scaled rectangle and performs the required scaling on the fly. It does not use a cached scaled version of the image for this operation. Scaling of the image from source to destination is performed such that the first coordinate of the source rectangle is mapped to the first coordinate of the destination rectangle and the second source coordinate is mapped to the second destination coordinate. The subimage is scaled and flipped as needed to preserve those mappings. @param img the specified image to be drawn @param dx1 the x coordinate of the first corner of the destination rectangle. @param dy1 the y coordinate of the first corner of the destination rectangle. @param dx2 the x coordinate of the second corner of the destination rectangle. @param dy2 the y coordinate of the second corner of the destination rectangle. @param sx1 the x coordinate of the first corner of the source rectangle. @param sy1 the y coordinate of the first corner of the source rectangle. @param sx2 the x coordinate of the second corner of the source rectangle. @param sy2 the y coordinate of the second corner of the source rectangle. @param observer object to be notified as more of the image is scaled and converted. @return true if the current output representation is complete; false otherwise. @see java.awt.Image @see java.awt.image.ImageObserver @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image int int int int int) @since JDK1.1

Class Graphics, Rectangle getClipRect()

Returns the bounding rectangle of the current clipping area. @return the bounding rectangle of the current clipping area or null if no clip is set. @deprecated As of JDK version 1.1 replaced by getClipBounds().
Class Graphics, Color getColor()

Gets this graphics context's current color. @return this graphics context's current color. @see java.awt.Color @see java.awt.Graphics#setColor(Color)
Class Graphics, Font getFont()

Gets the current font. @return this graphics context's current font. @see java.awt.Font @see java.awt.Graphics#setFont(Font)
Class Graphics, boolean hitClip(int, int, int, int)

Returns true if the specified rectangular area intersects the boundingmight rectangle ofintersect the current clipping area. The coordinates of the specified rectangular area are in the rectangleuser coordinate space and are relative to the coordinate system origin of this graphics context. This method may use an algorithm that calculates a result quickly but which sometimes might return true even if the specified rectangular area does not intersect the clipping area. The specific algorithm employed may thus trade off accuracy for speed but it will never return false unless it can guarantee that the specified rectangular area does not intersect the current clipping area. The clipping area used by this method can represent the intersection of the user clip as specified through the clip methods of this graphics context as well as the clipping associated with the device or image bounds and window visibility. @param x the x coordinate of the rectangle to test against the clip @param y the y coordinate of the rectangle to test against the clip @param width the width of the rectangle to test against the clip @param height the height of the rectangle to test against the clip @return true if the specified rectangle intersects the bounds of the current clip; false otherwise.
Class Graphics, void setClip(int, int, int, int)

Sets the current clip to the rectangle specified by the given coordinates. This method sets the user clip which is independent of the clipping associated with device bounds and window visibility. Rendering operations have no effect outside of the clipping area. @param x the x coordinate of the new clip rectangle. @param y the y coordinate of the new clip rectangle. @param width the width of the new clip rectangle. @param height the height of the new clip rectangle. @see java.awt.Graphics#clipRect @see java.awt.Graphics#setClip(Shape) @see java.awt.Graphics#getClip @since JDK1.1

Class Graphics2D

This Graphics2D class extends the Graphics class to provide more sophisticated control over geometry coordinate transformations color management and text layout. This is the fundamental class for rendering 2-dimensional shapes text and images on the Java(tm) platform.

Coordinate Spaces

All coordinates passed to a Graphics2D object are specified in a device-independent coordinate system called User Space which is used by applications. The Graphics2D object contains an AffineTransform object as part of its rendering state that defines how to convert coordinates from user space to device-dependent coordinates in Device Space.

Coordinates in device space usually refer to individual device pixels and are aligned on the infinitely thin gaps between these pixels. Some Graphics2D objects can be used to capture rendering operations for storage into a graphics metafile for playback on a concrete device of unknown physical resolution at a later time. Since the resolution might not be known when the rendering operations are captured the Graphics2D Transform is set up to transform user coordinates to a virtual device space that approximates the expected resolution of the target device. Further transformations might need to be applied at playback time if the estimate is incorrect.

Some of the operations performed by the rendering attribute objects occur in the device space but all Graphics2D methods take user space coordinates.

Every Graphics2D object is associated with a target that defines where rendering takes place. A GraphicsConfiguration object defines the characteristics of the rendering target such as pixel format and resolution. The same rendering target is used throughout the life of a Graphics2D object.

When creating a Graphics2D object the GraphicsConfiguration specifies the default transform for the target of the Graphics2D (a Component or Thi default transform maps the user space coordinate system to screen and printer device coordinates such that the origin maps to the upper left hand corner of the target region of the device with increasing X coordinates extending to the right and increasing Y coordinates extending downward. The scaling of the default transform is set to identity for those devices that are close to 72 dpi such as screen devices. The scaling of the default transform is set to approximately 72 user space coordinates per square inch for high resolution devices such as printers. For image buffers the default transform is the Identity transform.

Rendering Process

The Rendering Process can be broken down into four phases that are controlled by the Graphics2D rendering attributes. The renderer can optimize many of these steps either by caching the results for future calls by collapsing multiple virtual steps into a single operation or by recognizing various attributes as common simple cases that can be eliminated by modifying other parts of the operation.

The steps in the rendering process are:

  1. Determine what to render.
  2. Constrain the rendering operation to the current Clip. The Clip is specified by a Shape in user space and is controlled by the program using the various clip manipulation methods of Graphics and Graphics2D. This user clip is transformed into device space by the current Transform and combined with the device clip which is defined by the visibility of windows and device extents. The combination of the user clip and device clip defines the composite clip which determines the final clipping region. The user clip is not modified by the rendering system to reflect the resulting composite clip.
  3. Determine what colors to render.
  4. Apply the colors to the destination drawing surface using the current Composite attribute in the Graphics2D context.

The three types of rendering operations along with details of each of their particular rendering processes are:
  1. Shape operations
    1. If the operation is a draw(Shape) operation then the createStrokedShape method on the current Stroke attribute in the Graphics2D context is used to construct a new Shape object that contains the outline of the specified Shape.
    2. The Shape is transformed from user space to device space using the current Transform in the Graphics2D context.
    3. The outline of the Shape is extracted using the getPathIterator method of Shape which returns a PathIterator object that iterates along the boundary of the Shape.
    4. If the Graphics2D object cannot handle the curved segments that the PathIterator object returns then it can call the alternate double getPathIterator} method of Shape which flattens the Shape.
    5. The current Paint in the Graphics2D context is queried for a PaintContext which specifies the colors to render in device space.
  2. Text operations
    1. The following steps are used to determine the set of glyphs required to render the indicated String:
      1. If the argument is a String then the current Font in the Graphics2D context is asked to convert the Unicode characters in the String into a set of glyphs for presentation with whatever basic layout and shaping algorithms the font implements.
      2. If the argument is an AttributedCharacterIterator the iterator is asked to convert itself to a TextLayout using its embedded font attributes. The TextLayout implements more sophisticated glyph layout algorithms that perform Unicode bi-directional layout adjustments automatically for multiple fonts of differing writing directions.
      3. If the argument is a GlyphVector then the GlyphVector object already contains the appropriate font-specific glyph codes with explicit coordinates for the position of each glyph.
    2. The current Font is queried to obtain outlines for the indicated glyphs. These outlines are treated as shapes in user space relative to the position of each glyph that was determined in step 1.
    3. The character outlines are filled as indicated above under Shape operations.
    4. The current Paint is queried for a PaintContext which specifies the colors to render in device space.
  3. Image Operations
    1. The region of interest is defined by the bounding box of the source Image. This bounding box is specified in Image Space which is the Image object's local coordinate system.
    2. If an AffineTransform is passed to java.awt.geom.AffineTransfor java.awt.image.ImageObserver) drawImage(Image AffineTransform ImageObserver)} the AffineTransform is used to transform the bounding box from image space to user space. If no AffineTransform is supplied the bounding box is treated as if it is already in user space.
    3. The bounding box of the source Image is transformed from user space into device space using the current Transform. Note that the result of transforming the bounding box does not necessarily result in a rectangular region in device space.
    4. The Image object determines what colors to render sampled according to the source to destination coordinate mapping specified by the current Transform and the optional image transform.

Default Rendering Attributes

The default values for the Graphics2D rendering attributes are:
Paint
The color of the Component.
Font
The Font of the Component.
Stroke
A square pen with a linewidth of 1 no dashing miter segment joins and square end caps.
Transform
The getDefaultTransform for the GraphicsConfiguration of the Component.
Composite
The AlphaComposite#SRC_OVER rule.
Clip
No rendering Clip the output is clipped to the Component.

Rendering Compatibility Issues

The JDK(tm) 1.1 rendering model is based on a pixelization model that specifies that coordinates are infinitely thin lying between the pixels. Drawing operations are performed using a one-pixel wide pen that fills the pixel below and to the right of the anchor point on the path. The JDK 1.1 rendering model is consistent with the capabilities of most of the existing class of platform renderers that need to resolve integer coordinates to a discrete pen that must fall completely on a specified number of pixels.

The Java 2D(tm) (Java(tm) 2 platform) API supports antialiasing renderers. A pen with a width of one pixel does not need to fall completely on pixel N as opposed to pixel N+1. The pen can fall partially on both pixels. It is not necessary to choose a bias direction for a wide pen since the blending that occurs along the pen traversal edges makes the sub-pixel position of the pen visible to the user. On the other hand when antialiasing is turned off by setting the KEY_ANTIALIASING hint key to the VALUE_ANTIALIAS_OFF hint value the renderer might need to apply a bias to determine which pixel to modify when the pen is straddling a pixel boundary such as when it is drawn along an integer coordinate in device space. While the capabilities of an antialiasing renderer make it no longer necessary for the rendering model to specify a bias for the pen it is desirable for the antialiasing and non-antialiasing renderers to perform similarly for the common cases of drawing one-pixel wide horizontal and vertical lines on the screen. To ensure that turning on antialiasing by setting the KEY_ANTIALIASING hint key to VALUE_ANTIALIAS_ON does not cause such lines to suddenly become twice as wide and half as opaque it is desirable to have the model specify a path for such lines so that they completely cover a particular set of pixels to help increase their crispness.

Java 2D API maintains compatibility with JDK 1.1 rendering behavior such that legacy operations and existing renderer behavior is unchanged under Java 2D API. Legacy methods that map onto general draw and fill methods are defined which clearly indicates how Graphics2D extends Graphics based on settings of Stroke and Transform attributes and rendering hints. The definition performs identically under default attribute settings. For example the default Stroke is a BasicStroke with a width of 1 and no dashing and the default Transform for screen drawing is an Identity transform.

The following two rules provide predictable rendering behavior whether aliasing or antialiasing is being used.

The following definitions of general legacy methods perform identically to previously specified behavior under default attribute settings:

The Graphics class defines only the setColor method to control the color to be painted. Since the Java 2D API extends the Color object to implement the new Paint interface the existing setColor method is now a convenience method for setting the current Paint attribute to a Color object. setColor(c) is equivalent to setPaint(c).

The Graphics class defines two methods for controlling how colors are applied to the destination.

  1. The setPaintMode method is implemented as a convenience method to set the default Composite equivalent to setComposite(new AlphaComposite.SrcOver).
  2. The setXORMode(Color xorcolor) method is implemented as a convenience method to set a special Composite object that ignores the Alpha components of source colors and sets the destination color to the value:
     dstpixel = (PixelOf(srccolor) ^ PixelOf(xorcolor) ^ dstpixel); 
@version 1.70 0276 12/0203/0001 @author Jim Graham @see java.awt.RenderingHints
Class Graphics2D, void drawGlyphVector(GlyphVector, float, float)

Renders the text of the specified GlyphVector using the Graphics2D context's rendering attributes. The rendering attributes applied include the Clip Transform Paint and Composite attributes. The GlyphVector specifies individual glyphs from a Font The GlyphVector can also contain the glyph positions. This is the fastest way to render a set of characters to the screen. @param g the GlyphVector to be rendered @param x  y the position in User Space where the glyphs should be rendered @see java.awt.fontFont#createGlyphVector @see java.awt.font.GlyphVector @see #setPaint @see java.awt.Graphics#setColor @see #setTransform @see #setComposite @see #setClip
Class Graphics2D, void drawString(String, float, float)

Renders the text specified by the specified String using the current Font andtext Paintattribute attributesstate in the Graphics2D context. The baseline of the first character is at position (x  y) in the User Space. The rendering attributes applied include the Clip Transform Paint Font and Composite attributes. For characters in script systems such as Hebrew and Arabic the glyphs can be rendered from right to left in which case the coordinate supplied is the location of the leftmost character on the baseline. @param s the String to be rendered @param x  y the coordinates where the String should be rendered @throws NullPointerException if str is null @see #setPaint @see java.awt.Graphics#setColor @see java.awt.Graphics#setFont @see #setTransform @see #setComposite @see #setClip
Class Graphics2D, void drawString(String, int, int)

Renders the text of the specified String using the current Font andtext Paintattribute attributesstate in the Graphics2D context. The baseline of the first character is at position (x  y) in the User Space. The rendering attributes applied include the Clip Transform Paint Font and Composite attributes. For characters in script systems such as Hebrew and Arabic the glyphs can be rendered from right to left in which case the coordinate supplied is the location of the leftmost character on the baseline. @param str the string to be rendered @param x  y the coordinates where the String should be rendered @throws NullPointerException if str is null @see java.awt.Graphics#drawBytes @see java.awt.Graphics#drawChars @since JDK1.0
Class Graphics2D, GraphicsConfiguration getDeviceConfiguration()

Returns the device configuration associated with this Graphics2D. @return the device configuration of this Graphics2D.
Class Graphics2D, Object getRenderingHint(Key)

Returns the value of a single preference for the rendering algorithms. Hint categories include controls for rendering quality and overall time/quality trade-off in the rendering process. Refer to the RenderingHints class for definitions of some common keys and values. @param hintKey the key corresponding to the hint to get. @return an object representing the value for the specified hint key. Some of the keys and their associated values are defined in the RenderingHints class. @see RenderingHints @see #setRenderingHint(RenderingHints.Key Object)
Class Graphics2D, RenderingHints getRenderingHints()

Gets the preferences for the rendering algorithms. Hint categories include controls for rendering quality and overall time/quality trade-off in the rendering process. Returns all of the hint key/value pairs that were ever specified in one operation. Refer to the RenderingHints class for definitions of some common keys and values. @return a reference to an instance of RenderingHints that contains the current preferences. @see RenderingHints @see #setRenderingHints(Map)
Class Graphics2D, void setComposite(Composite)

Sets the Composite for the Graphics2D context. The Composite is used in all drawing methods such as drawImage drawString draw and fill. It specifies how new pixels are to be combined with the existing pixels on the graphics device during the rendering process.

If this Graphics2D context is drawing to a Component on the display screen and the Composite is a custom object rather than an instance of the AlphaComposite class and if there is a security manager its checkPermission method is called with an AWTPermission("readDisplayPixels") permission. @throws SecurityException if a custom Composite object is being used to render to the screen and a security manager is set and its checkPermission method does not allow the operation. @param comp the Composite object to be used for rendering @see java.awt.Graphics#setXORMode @see java.awt.Graphics#setPaintMode @see #getComposite @see AlphaComposite @see SecurityManager#checkPermission @see java.awt.AWTPermission

Class Graphics2D, void setPaint(Paint)

Sets the Paint attribute for the Graphics2D context. Calling this method with a null Paint object does not have any effect on the current Paint attribute of this Graphics2D. @param paint the Paint object to be used to generate color during the rendering process or null @see java.awt.Graphics#setColor @see #getPaint @see GradientPaint @see TexturePaint
Class Graphics2D, void setRenderingHint(Key, Object)

Sets the value of a single preference for the rendering algorithms. Hint categories include controls for rendering quality and overall time/quality trade-off in the rendering process. Refer to the RenderingHints class for definitions of some common keys and values. @param hintKey the key of the hint to be set. @param hintValue the value indicating preferences for the specified hint category. @see #getRenderingHint(RenderingHints.Key) @see RenderingHints
Class Graphics2D, void setRenderingHints(Map)

Replaces the values of all preferences for the rendering algorithms with the specified hints. The existing values for all rendering hints are discarded and the new set of known hints and values are initialized from the specified Map object. Hint categories include controls for rendering quality and overall time/quality trade-off in the rendering process. Refer to the RenderingHints class for definitions of some common keys and values. @param hints the rendering hints to be set @see #getRenderingHints @see RenderingHints
Class Graphics2D, void setStroke(Stroke)

Sets the Stroke for the Graphics2D context. @param s the Stroke object to be used to stroke a Shape during the rendering process @see BasicStroke @see #getStroke
Class Graphics2D, void setTransform(AffineTransform)

SetsOverwrites the Transform in the Graphics2D context. WARNING: This method should never be used to apply a new coordinate transform on top of an existing transform because the Graphics2D might already have a transform that is needed for other purposes such as rendering Swing components or applying a scaling transformation to adjust for the resolution of a printer.

To add a coordinate transform use the transform rotate scale or shear methods. The setTransform method is intended only for restoring the original Graphics2D transform after rendering as shown in this example:

// Get the current transform AffineTransform saveAT = g2.getTransform(); // Perform transformation g2d.transform(...); // Render g2d.draw(...); // Restore original transform g2d.setTransform(saveAT);
@param Tx the AffineTransform object tothat be used inwas retrieved from the renderinggetTransform processmethod @see #transform @see #getTransform @see AffineTransform

Class GraphicsConfigTemplate

The GraphicsConfigTemplate class is used to obtain a valid GraphicsConfiguration A user instantiates one of these objects and then sets all non-default attributes as desired. The GraphicsDevice#getBestConfiguration method found in the GraphicsDevice class is then called with this GraphicsConfigTemplate. A valid GraphicsConfiguration is returned that meets or exceeds what was requested in the GraphicsConfigTemplate. @see GraphicsDevice @see GraphicsConfiguration @version 1.13 0214 12/0203/0001 @since 1.2

Class GraphicsDevice

The GraphicsDevice class describes the graphics devices that might be available in a particular graphics environment. These include screen and printer devices. Note that there can be many screens and many printers in an instance of GraphicsEnvironment Each graphics device has one or more GraphicsConfiguration objects associated with it. These objects specify the different configurations in which the GraphicsDevice can be used.

In a multi-screen environment the GraphicsConfiguration objects can be used to render components on multiple screens. The following code sample demonstrates how to create a JFrame object for each GraphicsConfiguration on each screen device in the GraphicsEnvironment:

 GraphicsEnvironment ge = GraphicsEnvironment. getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); for (int j = 0; j  @see GraphicsEnvironment @see GraphicsConfiguration @version 1.21 0225 12/0903/01

Class GraphicsEnvironment

The GraphicsEnvironment class describes the collection of GraphicsDevice objects and java.awt.Font objects available to a Java(tm) application on a particular platform. The resources in this GraphicsEnvironment might be local or on a remote machine. GraphicsDevice objects can be screens printers or image buffers and are the destination of Graphics2D drawing methods. Each GraphicsDevice has a number of GraphicsConfiguration objects associated with it. These objects specify the different configurations in which the GraphicsDevice can be used. @see GraphicsDevice @see GraphicsConfiguration @version 1.42 0251 12/0203/0001
Class GraphicsEnvironment, String[] getAvailableFontFamilyNames()

Returns an array containing the names of all font families available in this GraphicsEnvironment. Typical usage would be to allow a user to select a particular family name and allow the application to choose related variants of the same family when the user specifies style attributes such as Bold or Italic.

This method provides for the application some control over which Font instance is used to render text but allows the Font object more flexibility in choosing its own best match among multiple fonts in the same font family. @return an array of String containing names of font families. @see #getAllFonts @see java.awt.Font @see java.awt.Font#getFamily @since 1.2

Class GraphicsEnvironment, String[] getAvailableFontFamilyNames(Locale)

Returns an array containing the localized names of all font families available in this GraphicsEnvironment. Typical usage would be to allow a user to select a particular family name and allow the application to choose related variants of the same family when the user specifies style attributes such as Bold or Italic.

This method provides for the application some control over which Font instance used to render text but allows the Font object more flexibility in choosing its own best match among multiple fonts in the same font family. If l is null this method returns an array containing all font family names available in this GraphicsEnvironment. @param l a Locale object that represents a particular geographical political or cultural region @return an array of String objects containing names of font families specific to the specified Locale. @see #getAllFonts @see java.awt.Font @see java.awt.Font#getFamily @since 1.2

Class GraphicsEnvironment, GraphicsDevice getDefaultScreenDevice()

Returns the default screen GraphicsDevice. @return the GraphicsDevice that represents the default screen device. @exception HeadlessException if isHeadless() returns true @see isHeadless
Class GraphicsEnvironment, GraphicsDevice[] getScreenDevices()

Returns an array of all of the screen GraphicsDevice objects. @return an array containing all the GraphicsDevice objects that represent screen devices. @exception HeadlessException if isHeadless() returns true @see isHeadless

Class GridBagConstraints

The GridBagConstraints class specifies constraints for components that are laid out using the GridBagLayout class. @version 1.26 0229 12/0203/0001 @author Doug Stein @see java.awt.GridBagLayout @since JDK1.0
Class GridBagConstraints, int RELATIVE

SpecifySpecifies that this component is the next-to-last component in its column or row (gridwidth gridheight) or that this component be placed next to the previously added component (gridx gridy). @see java.awt.GridBagConstraints#gridwidth @see java.awt.GridBagConstraints#gridheight @see java.awt.GridBagConstraints#gridx @see java.awt.GridBagConstraints#gridy
Class GridBagConstraints, int REMAINDER

SpecifySpecifies that this component is the last component in its column or row.
Class GridBagConstraints, int anchor

This field is used when the component is smaller than its display area. It determines where within the display area to place the component. Possible

There are two kinds of possible values: relative and absolute. Relative values are interpreted relative to the container's component orientation property while absolute values are not. The absolute values are: CENTER NORTH NORTHEAST EAST SOUTHEAST SOUTH SOUTHWEST WEST and NORTHWEST. The relative values are: PAGE_START PAGE_END LINE_START LINE_END FIRST_LINE_START FIRST_LINE_END LAST_LINE_START and LAST_LINE_END. The default value is CENTER. @serial @see #clone() @see java.awt.ComponentOrientation

Class GridBagConstraints, int gridheight

Specifies the number of cells in a column for the component's display area.

Use REMAINDER to specify that the component be the last one in its column. Use RELATIVE to specify that the component be the next-to-last one in its column.

gridheight should be a non-negative value and the default value is 1. @serial @see #clone() @see java.awt.GridBagConstraints#gridwidth

Class GridBagConstraints, int gridwidth

Specifies the number of cells in a row for the component's display area.

Use REMAINDER to specify that the component be the last one in its row. Use RELATIVE to specify that the component be the next-to-last one in its row.

gridwidth should be non-negative and the default value is 1. @serial @see #clone() @see java.awt.GridBagConstraints#gridheight

Class GridBagConstraints, int gridx

Specifies the cell atcontaining the leftleading edge of the component's display area where the leftmostfirst cell in a row has gridx=0. The leading edge of a component's display area is its left edge for a horizontal left-to-right container and its right edge for a horizontal right-to-left container. The value RELATIVE specifies that the component be placed just to the rightimmediately offollowing the component that was added to the container just before this component was added.

The default value is RELATIVE. gridx should be a non-negative value. @serial @see #clone() @see java.awt.GridBagConstraints#gridy @see java.awt.ComponentOrientation

Class GridBagConstraints, int gridy

Specifies the cell at the top of the component's display area where the topmost cell has gridy=0. The value RELATIVE specifies that the component be placed just below the component that was added to the container just before this component was added.

The default value is RELATIVE. gridy should be a non-negative value. @serial @see #clone() @see java.awt.GridBagConstraints#gridx

Class GridBagConstraints, double weightx

Specifies how to distribute extra horizontal space.

The grid bag layout manager calculates the weight of a column to be the maximum weightx of all the components in a column. If the resulting layout is smaller horizontally than the area it needs to fill the extra space is distributed to each column in proportion to its weight. A column that has a weight of zero receives no extra space.

If all the weights are zero all the extra space appears between the grids of the cell and the left and right edges.

The default value of this field is 0. weightx should be a non-negative value. @serial @see #clone() @see java.awt.GridBagConstraints#weighty

Class GridBagConstraints, double weighty

Specifies how to distribute extra vertical space.

The grid bag layout manager calculates the weight of a row to be the maximum weighty of all the components in a row. If the resulting layout is smaller vertically than the area it needs to fill the extra space is distributed to each row in proportion to its weight. A row that has a weight of zero receives no extra space.

If all the weights are zero all the extra space appears between the grids of the cell and the top and bottom edges.

The default value of this field is 0. weighty should be a non-negative value. @serial @see #clone() @see java.awt.GridBagConstraints#weightx


Class GridBagLayout

The GridBagLayout class is a flexible layout manager that aligns components vertically and horizontally without requiring that the components be of the same size. Each GridBagLayout object maintains a dynamic rectangular grid of cells with each component occupying one or more cells called its display area.

Each component managed by a grid bag layoutGridBagLayout is associated with an instance of GridBagConstraints thatThe constraints object specifies where a component's display area should be located on the grid and how the component is laid outshould be positioned within its display area. In Howaddition ato its constraints object the GridBagLayout objectalso considers each component's minimum and preferred sizes in order to placesdetermine a setcomponent's size.

The overall orientation of componentsthe grid depends on the GridBagConstraintscontainer's objectComponentOrientation associatedproperty. with eachFor horizontal componentleft-to-right and onorientations grid coordinate (0 0) is in the minimum sizeupper left corner of the container with x increasing to the right and y increasing downward. For horizontal right-to-left orientations grid coordinate (0 0) is in the preferredupper sizeright corner of the components'container with x increasing to the left and containersy increasing downward.

To use a grid bag layout effectively you must customize one or more of the GridBagConstraints objects that are associated with its components. You customize a GridBagConstraints object by setting one or more of its instance variables:

{@link GridBagConstraints#gridx} GridBagConstraints#gridy
Specifies the cell atcontaining the upperleading leftcorner of the component's display area where the upper-left-most cell at the origin of the grid has address gridx = 0 gridy = 0. For horizontal left-to-right layout a component's leading corner is its upper left. For horizontal right-to-left layout a component's leading corner is its upper right. Use GridBagConstraints.RELATIVE (the default value) to specify that the component be just placed justimmediately tofollowing (along the right ofx axis (for gridx) or just belowthe y (axis for gridy) the component that was added to the container just before this component was added.
{@link GridBagConstraints#gridwidth} GridBagConstraints#gridheight
Specifies the number of cells in a row (for gridwidth) or column (for gridheight) in the component's display area. The default value is 1. Use GridBagConstraints.REMAINDER to specify that the component be the last one in its row (for gridwidth) or column (for gridheight). Use GridBagConstraints.RELATIVE to specify that the component be the next to last one in its row (for gridwidth) or column (for gridheight).
{@link GridBagConstraints#fill}
Used when the component's display area is larger than the component's requested size to determine whether (and how) to resize the component. Possible values are GridBagConstraints.NONE (the default) GridBagConstraints.HORIZONTAL (make the component wide enough to fill its display area horizontally but don't change its height) GridBagConstraints.VERTICAL (make the component tall enough to fill its display area vertically but don't change its width) and GridBagConstraints.BOTH (make the component fill its display area entirely).
{@link GridBagConstraints#ipadx} GridBagConstraints#ipady
Specifies the component's internal padding within the layout how much to add to the minimum size of the component. The width of the component will be at least its minimum width plus (ipadx * 2) pixels (since the padding applies to both sides of the component). Similarly the height of the component will be at least the minimum height plus (ipady * 2) pixels.
{@link GridBagConstraints#insets}
Specifies the component's external padding the minimum amount of space between the component and the edges of its display area.
{@link GridBagConstraints#anchor}
Used when the component is smaller than its display area to determine where (within the display area) to place the component. There are two kinds of possible values: relative and absolute. Relative values are interpreted relative to the container's ComponentOrientation property while absolute values are not. Valid values are:

Absolute Values Relative Values
  • GridBagConstraints.NORTH
  • GridBagConstraints.SOUTH
  • GridBagConstraints.WEST
  • GridBagConstraints.EAST
  • GridBagConstraints.NORTHWEST
  • GridBagConstraints.NORTHEAST
  • GridBagConstraints.SOUTHWEST
  • GridBagConstraints.SOUTHEAST
  • GridBagConstraints.CENTER (the default)
  • GridBagConstraints.NORTHPAGE_START
  • GridBagConstraints.NORTHEASTPAGE_END
  • GridBagConstraints.EASTLINE_START
  • GridBagConstraints.SOUTHEASTLINE_END
  • GridBagConstraints.SOUTHFIRST_LINE_START
  • GridBagConstraints.SOUTHWESTFIRST_LINE_END
  • GridBagConstraints.WESTLAST_LINE_START
  • and
  • GridBagConstraints.NORTHWESTLAST_LINE_END.
  • {@link GridBagConstraints#weightx} GridBagConstraints#weighty
    Used to determine how to distribute space which is important for specifying resizing behavior. Unless you specify a weight for at least one component in a row (weightx) and column (weighty) all the components clump together in the center of their container. This is because when the weight is zero (the default) the GridBagLayout object puts any extra space between its grid of cells and the edges of the container.

    The following figure showsfigures show ten components (all buttons) managed by a grid bag layout:. Figure 1 shows the layout for a horizontal left-to-right container and Figure 2 shows the layout for a horizontal right-to-left container.

    Figure 1: Horizontal Left-to-Right Figure 2: Horizontal Right-to-Left

    Each of the ten components has the fill field of its associated GridBagConstraints object set to GridBagConstraints.BOTH. In addition the components have the following non-default constraints:

    Here is the code that implements the example shown above:


     import java.awt.*; import java.util.*; import java.applet.Applet; public class GridBagEx1 extends Applet { protected void makebutton(String name GridBagLayout gridbag GridBagConstraints c) { Button button = new Button(name); gridbag.setConstraints(button c); add(button); } public void init() { GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setFont(new Font("Helvetica" Font.PLAIN 14)); setLayout(gridbag); c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; makebutton("Button1" gridbag c); makebutton("Button2" gridbag c); makebutton("Button3" gridbag c); c.gridwidth = GridBagConstraints.REMAINDER; //end row makebutton("Button4" gridbag c); c.weightx = 0.0; //reset to the default makebutton("Button5" gridbag c); //another row c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last in row makebutton("Button6" gridbag c); c.gridwidth = GridBagConstraints.REMAINDER; //end row makebutton("Button7" gridbag c); c.gridwidth = 1; //reset to the default c.gridheight = 2; c.weighty = 1.0; makebutton("Button8" gridbag c); c.weighty = 0.0; //reset to the default c.gridwidth = GridBagConstraints.REMAINDER; //end row c.gridheight = 1; //reset to the default makebutton("Button9" gridbag c); makebutton("Button10" gridbag c); setSize(300 100); } public static void main(String args[]) { Frame f = new Frame("GridBag Layout Example"); GridBagEx1 ex1 = new GridBagEx1(); ex1.init(); f.add("Center" ex1); f.pack(); f.setSize(f.getPreferredSize()); f.show(); } } 

    @version 1.5 16 Nov 1995 @author Doug Stein @see java.awt.GridBagConstraints @see java.awt.ComponentOrientation @since JDK1.0

    Class GridBagLayout, GridBagLayoutInfo GetLayoutInfo(Container, int)

    Print the layoutThis method is constraints. Usefulsupplied for debuggingbackwards compatability only; new code should call getLayoutInfo() instead. @see getLayoutInfo
    Class GridBagLayout, void addLayoutComponent(Component, Object)

    Adds the specified component to the layout using the specified constraintconstraints object. Note that constraints are mutable and are therefore cloned when cached. @param comp the component to be added. @param constraints an object that determines how the component is added to the layout. @exception IllegalArgumentException if constraints is not a GridBagConstraint
    Class GridBagLayout, void addLayoutComponent(String, Component)

    Adds the specified component with the specified name to the layout. @param name the name of the component. @param comp the component to be added.
    Class GridBagLayout, GridBagConstraints getConstraints(Component)

    Gets the constraints for the specified component. A copy of the actual GridBagConstraints object is returned. @param comp the component to be queried. @return the constraint for the specified component in this grid bag layout; a copy of the actual constraint object is returned.
    Class GridBagLayout, int[][] getLayoutDimensions()

    Determines column widths and row heights for the layout grid.

    Most applications do not call this method directly. @return an array of two arrays containing the widths of the layout columns and the heights of the layout rows. @since JDK1.1

    Class GridBagLayout, Point getLayoutOrigin()

    Determines the origin of the layout area in the graphics coordinate space of the target container. This value represents the pixel coordinates of the top-left corner of the layout area regardless of the ComponentOrientation value of the container. This is distinct from the grid origin given by the cell coordinates (0 0). Most applications do not call this method directly. @return the graphics origin of the cell in the top-left corner of the layout grid @see java.awt.ComponentOrientation @since JDK1.1
    Class GridBagLayout, double[][] getLayoutWeights()

    Determines the weights of the layout grid's columns and rows. Weights are used to calculate how much a given column or row stretches beyond its preferred size if the layout has extra room to fill.

    Most applications do not call this method directly. @return an array of two arrays representing the horizontal weights of the layout columns and the vertical weights of the layout rows. @since JDK1.1

    Class GridBagLayout, Point location(int, int)

    Determines which cell in the layout grid contains the point specified by (x  y). Each cell is identified by its column index (ranging from 0 to the number of columns minus 1) and its row index (ranging from 0 to the number of rows minus 1).

    If the (x  y) point lies outside the grid the following rules are used. The column index is returned as zero if x lies to the left of the layout andfor a left-to-right container or to the right of the layout for a right-to-left container. The column index is returned as the number of columns if x lies to the right of the layout in a left-to-right container or to the left in a right-to-left container. The row index is returned as zero if y lies above the layout and as the number of rows if y lies below the layout. The orientation of a container is determined by its ComponentOrientation property. @param x the x coordinate of a point. @param y the y coordinate of a point. @return an ordered pair of indexes that indicate which cell in the layout grid contains the point (x  y). @see java.awt.ComponentOrientation @since JDK1.1

    Class GridBagLayout, GridBagConstraints lookupConstraints(Component)

    Retrieves the constraints for the specified component. The return value is not a copy but is the actual GridBagConstraints object used by the layout mechanism. @param comp the component to be queried @return the contraints for the specified componentcomponen.
    Class GridBagLayout, void setConstraints(Component, GridBagConstraints)

    Sets the constraints for the specified component in this layout. @param comp the component to be modified. @param constraints the constraints to be applied.
    Class GridBagLayout, double[] columnWeights

    This field holds the overrides to the column weights. If this field is non-null the values are applied to the gridbag after all of the columns weights have been calculated. If columnWeights[i] > weight for column i then column i is assigned the weight in columnWeights[i]. If columnWeights has more elements than the number of columns the excess elements are ignored - they do not cause more columns to be created. @serial
    Class GridBagLayout, int[] columnWidths

    This field holds the overrides to the column minimum width. If this field is non-null the values are applied to the gridbag after all of the minimum columns widths have been calculated. If columnWidths has more elements than the number of columns columns are added to the gridbag to match the number of elements in columnWidth. @serial @see #getLayoutDimensions()
    Class GridBagLayout, Hashtable comptable

    This hashtable maintains the association between a component and its gridbag constraints. The Keys in comptable are the components and the values are the instances of GridBagConstraints. @serial @see java.awt.GridBagConstraints
    Class GridBagLayout, GridBagLayoutInfo layoutInfo

    This field holds thathe layout information for the gridbag. The information in this field is based on the most recent validation of the gridbag. If layoutInfo is null this indicates that there are no components in the gridbag or if there are components they have not yet been validated. @serial @see #GetLayoutInfogetLayoutInfo(Container int)
    Class GridBagLayout, int[] rowHeights

    This field holds the overrides to the row minimum heights. If this field is non-null the values are applied to the gridbag after all of the minimum row heights have been calculated. If rowHeights has more elements than the number of rows rowa are added to the gridbag to match the number of elements in rowHeights. @serial @see #getLayoutDimensions()
    Class GridBagLay