|
Generated by JDiff |
||||||||
PREV PACKAGE NEXT PACKAGE FRAMES NO FRAMES |
This file contains all the changes in documentation in the packagejava.awt
as colored differences. Deletions are shownlike 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.
Thrown when a serious Abstract Window Toolkit error has occurred. @version 1.12 0213 12/0203/0001 @author Arthur van Hoff
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.Class AWTEvent, String paramString()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
Returns a string representing the state of thiseventEvent
. 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 benull
. @return a string representation of this event.
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:@author John Rose @author Amy Fowler @version 1.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()); } }
25 0231 12/0203/0001 @since 1.1
Signals that an Absract Window Toolkit exception has occurred. @version 1.13 0214 12/0203/0001 @author Arthur van Hoff
This class is for AWT permissions. AnClass AWTPermission, constructor AWTPermission(String)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.
@see java.security.BasicPermission @see java.security.Permission @see java.security.Permissions @see java.security.PermissionCollection @see java.lang.SecurityManager @version 1.
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. 18 0221 12/0203/0001 @author Marianne Mueller @author Roland Schemers
Creates a newClass AWTPermission, constructor AWTPermission(String, String)AWTPermission
with the specified name. The name is the symbolic name of theAWTPermission
such as "topLevelWindow" "systemClipboard" etc. An asterisk may be used to indicate all AWT permissions. @param name the name of the AWTPermission.
Creates a newAWTPermission
object with the specified name. The name is the symbolic name of theAWTPermission
and the actionsStringstring is currently unused and should benull
. This constructor exists for use by thePolicy
object to instantiate newPermissionpermission objects. @param name the name of theAWTPermission
@param actions should be.null
.
An interface for events that know how dispatch themselves. By implementing this interface an event can be placed upon the event queue and itsdispatch()
method will be called when the event is dispatched using theEventDispatchThread
.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
The interface for objects which have an adjustable numeric value contained within a bounded range of values. @version 1.Class Adjustable, void addAdjustmentListener(AdjustmentListener)10 0214 12/0203/0001 @author Amy Fowler @author Tim Prinzing
Class Adjustable, int getBlockIncrement()AddAdds a listener torecievereceive adjustment events when the value of the adjustable object changes. @param l the listener torecievereceive events @see AdjustmentEvent
Gets the block value increment for the adjustable object. @return the block value increment for the adjustable objectClass Adjustable, int getMaximum()
Gets the maximum value of the adjustable object. @return the maximum value of the adjustable objectClass Adjustable, int getMinimum()
Gets the minimum value of the adjustable object. @return the minimum value of the adjustable objectClass Adjustable, int getOrientation()
Gets the orientation of the adjustable object. @return the orientation of the adjustable object; eitherClass Adjustable, int getUnitIncrement()HORIZONTAL
VERTICAL
orNO_ORIENTATION
Gets the unit value increment for the adjustable object. @return the unit value increment for the adjustable objectClass Adjustable, int getValue()
Gets the current value of the adjustable object. @return the current value of the adjustable objectClass Adjustable, int getVisibleAmount()
Gets the length of theClass Adjustable, void setVisibleAmount(int)propertionalproportional indicator. @return the length of the proportional indicator
Sets the length of theClass Adjustable, int HORIZONTALproportionlproportional indicator of the adjustable object. @param v the length of the indicator
Class Adjustable, int VERTICALTheIndicates that theAdjustable
has horizontal orientation.
TheIndicates that theAdjustable
has vertical orientation.
ThisClass AlphaComposite, AlphaComposite getInstance(int)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 area subsetthe set ofthePorter-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:
- Cs = one of the color components of the source pixel.
- Cd = one of the color components of the destination pixel.
- As = alpha component of the source pixel.
- Ad = alpha component of the destination pixel.
- Fs = fraction of the source pixel that contributes to the output.
- Fd = fraction of the input destination pixel that contributes to the output.
The color and alpha components produced by the compositing operation are calculated as follows:
Cd = Cs*Fs + Cd*Fd Ad = As*Fs + Ad*Fdwhere 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
Creates anAlphaComposite
object with the specified rule. @param rule the compositing rule @throws IllegalArgumentException ifrule
is not one of the following: #CLEAR #SRC #DST #SRC_OVER #DST_OVER #SRC_IN #DST_IN #SRC_OUTor#DST_OUT #SRC_ATOP #DST_ATOP or #XOR
TheBasicStroke
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 thisBasicStroke
. The rendering attributes defined byBasicStroke
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 theShape
. These rendering attributes include: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
- 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.
Shape
argument. When aGraphics2D
object uses aStroke
object to redefine a path during the execution of one of itsdraw
methods the geometry is supplied in its original form before theGraphics2D
transform attribute is applied. Therefore attributes such as the pen width are interpreted in the user space coordinate system of theGraphics2D
object and are subject to the scaling and shearing effects of the user-space-to-device-space transform in that particularGraphics2D
. For example the width of a rendered shape's outline is determined not only by the width attribute of thisBasicStroke
but also by the transform attribute of theGraphics2D
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 theGraphics2D
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 aGraphics2D
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.370212/0903/01 @author Jim Graham
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:Class BorderLayout, String AFTER_LAST_LINENORTH
SOUTH
EAST
WEST
andCENTER
. 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 convenienceBorderLayout
interprets the absence of a string specification the same as the constantCENTER
:Panel p2 = new Panel(); p2.setLayout(new BorderLayout()); p2.add(new TextArea()); // Same as p.add(new TextArea() BorderLayout.CENTER);In addition
BorderLayout
supportsfourthe relative positioning constants
BEFORE_FIRSTPAGE_LINESTART
AFTERPAGE_LAST_LINEENDand
BEFORE_LINE_BEGINSSTART. In a container whose
AFTER_LINE_ENDSENDComponentOrientation
is set toComponentOrientation.LEFT_TO_RIGHT
these constants map toNORTH
SOUTH
WEST
andEAST
respectively.
MixingFor compatibility with previous releasesBorderLayout
also includes thetwo typesrelative positioningofconstantsBEFORE_FIRST_LINE
AFTER_LAST_LINE
BEFORE_LINE_BEGINS
andAFTER_LINE_ENDS
. These are equivalent toPAGE_START
PAGE_END
LINE_START
andLINE_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 theNORTH
andconstants in a container whose orientation is
BEFORE_FIRSTPAGE_LINESTARTLEFT_TO_RIGHT
only thewill be layed out.
BEFORE_FIRSTPAGE_LINESTARTNOTE: Currently (in the Java 2 platform v1.2)
BorderLayout
does not support vertical orientations. TheisVertical
setting on the container'sComponentOrientation
is not respected.The components are laid out according to their preferred sizes and the constraints of the container's size. The
NORTH
andSOUTH
components may be stretched horizontally; theEAST
andWEST
components may be stretched vertically; theCENTER
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_LINE_ENDSThe componentSynonym forcomes after thePAGE_END.last line of theExists for compatibility withlayout'spreviouscontentversions.For Western top-to-bottom left-to-rightPAGE_ENDorientations thisisequivalent to SOUTHpreferred. @seejava.awt.Component#getComponentOrientationPAGE_END @since 1.2
Class BorderLayout, String BEFORE_FIRST_LINETheSynonymcomponent goes at the end of the line directionforthe layoutLINE_END.For WesternExiststop-to-bottomforleft-to-rightcompatibilityorientations thiswith previousisversions.equivalentLINE_ENDto EASTis preferred. @seejava.awt.Component#getComponentOrientationLINE_END @since 1.2
Class BorderLayout, String BEFORE_LINE_BEGINSThe componentSynonym forcomes before thePAGE_START.first line of theExists for compatibility withlayout'spreviouscontentversions.For Western top-to-bottom left-to-rightPAGE_STARTorientations thisisequivalent to NORTHpreferred. @seejava.awt.Component#getComponentOrientationPAGE_START @since 1.2
TheSynonymcomponent goes at the beginning of the line directionforthe layoutLINE_START.For WesternExiststop-to-bottomforleft-to-rightcompatibilityorientations thiswith previousisversions.equivalentLINE_STARTto WESTis preferred. @seejava.awt.Component#getComponentOrientationLINE_START @since 1.2
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 "Class Button, constructor Button()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 specializeprocessMouseEvent
or it can register itself as a listener for mouse events by callingaddMouseListener
. Both of these methods are defined byComponent
the abstract superclass of all components.When a button is pressed and released AWT sends an instance of
ActionEvent
to the button by callingprocessEvent
on the button. The button'sprocessEvent
method receives all events for the button; it passes an action event along by calling its ownprocessActionEvent
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'saddActionListener
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
Constructs a Button with no label. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadlessClass 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#isHeadlessClass 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 @seeClass Button, AccessibleContext getAccessibleContext()java.awt.event.ActionListener#removeActionListener @see #getActionListeners @see java.awt.Button#removeActionListenerevent.ActionListener @since JDK1.1
Gets theClass Button, EventListener[] getListeners(Class)AccessibleContext
associated with thisButton
. For buttons theAccessibleContext
takes the form of anAccessibleAWTButton
. A newAccessibleAWTButton
instance is created if necessary. @return anAccessibleAWTButton
that serves as theAccessibleContext
of thisButton
@beaninfo expert: true description: The AccessibleContext associated with this Button.
Class Button, String paramString()ReturnReturns an array of all thelistenersobjectsthat were addedcurrently registered astoFooListener
sthe Buttonupon thiswithButton
.addXXXListener()FooListener
swhere XXX isare registered using thenameaddFooListener
ofmethod. You can specify thelistenerType
argument.For example to get all ofwith a class literal such astheFooListener.class
.ActionListener(s)Forforexampletheyou can querygivenaButton
b
onefor itswouldactionwritelisteners with the following code:If no suchActionListener[] als = (ActionListener[])(b.getListeners(ActionListener.class));listenerlisteners existlist exists thenthis method returns an empty arrayis returned. @param listenerTypeTypethe type of listeners requested; this parameter should specify an interface that descends fromjava.util.EventListener
@returnallan array oftheall objects registered asFooListener
s on this button or an empty array if no such listenersof the specifiedhave been addedtype@exceptionsupported byClassCastException ifthislistenerType
buttondoesn't specify a class or interface that implementsjava.util.EventListener
@see #getActionListeners @since 1.3
ReturnsClass Button, void processActionEvent(ActionEvent)the parametera string representing the state of thisbuttonButton
. Thisstringmethod isusefulintended 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 benull
. @return the parameter string of this button.
Processes action events occurring on this button by dispatching them to any registeredClass Button, void processEvent(AWTEvent)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:
- An
ActionListener
object is registered viaaddActionListener
.- Action events are enabled via
enableEvents
.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
Processes events on this button. If an event is an instance ofClass Button, void removeActionListener(ActionListener)ActionEvent
this method invokes theprocessActionEvent
method. Otherwise it invokesprocessEvent
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
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 @seejava.awt.event.ActionListener#addActionListener @see #getActionListeners @see java.awt.Button#addActionListenerevent.ActionListener @since JDK1.1
AClass Canvas, void paint(Graphics)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. Thepaint
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 update(Graphics)ThisPaintsmethod is called to repaintthis canvas.Most applications that subclass
Canvas
should override this method in order to perform some useful operation. The paint method provided by Canvas redrawsthis(typicallycanvas'scustomrectangle inpainting of thebackground colorcanvas).Thegraphics context's origin (0default0)operation isthe top-leftsimplycorner of thisto clear the canvas.ItsApplicationsclipping region is the area of the contextthat override this method need not call super.paint(g). @param g thegraphicsspecified Graphics context.@seejava.awt.#update(Graphics) @see Component#paint(Graphics)
Updates thiscomponentcanvas.
The AWT callsThisthemethodupdateismethodcalled in response to a call torepaint
.update or paintYou can assume that theThebackgroundcanvas isnotfirst cleared. The updatemethod ofComponent does the following: Clears this componentby filling it with the background color. Sets the color of the graphics context to bethe foregroundandcolor of thisthen completely redrawncomponent.byCallscalling thiscomponentcanvas'spaint
methodto 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 regionorofincorporate thegraphicsfunctionalitycontext is thedescribedbounding rectangle of this componentabove into their own code. @param g the specifiedcontext to use forGraphicsupdating.context @seejava.awt.Component#paint(Graphics) @seejava.awt.Component#repaintupdate(Graphics)@since JDK1.0
AClass CardLayout, void removeLayoutComponent(Component)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 aCardLayout
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. TheCardLayouCardLayout#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
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()
A check box is a graphical component that can be in either an "on" (Class Checkbox, constructor Checkbox()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 theGridLayout
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
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#isHeadlessClass 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 orClass Checkbox, constructor Checkbox(String, CheckboxGroup, boolean)null
for no label. @exception HeadlessException ifGraphicsEnvironment.isHeadless
returnstrue
@see java.awt.GraphicsEnvironment#isHeadless
Class Checkbox, constructor Checkbox(String, boolean)ConstructsCreates aCheckboxcheck box with the specified labelset toin the specifiedstatecheck box group andinset to the specifiedcheck box groupstate. @param label a string label for this check box ornull
for no label. @param group a check box group for this check box ornull
for no group. @param state the initial state of this check box. @exception HeadlessException ifGraphicsEnvironment.isHeadless
returnstrue
@see java.awt.GraphicsEnvironment#isHeadless @since JDK1.1
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 orClass Checkbox, constructor Checkbox(String, boolean, CheckboxGroup)null
for no label.@param state the initial state of this check box @exception HeadlessException ifGraphicsEnvironment.isHeadless
returnstrue
@see java.awt.GraphicsEnvironment#isHeadless
Class Checkbox, void addItemListener(ItemListener)CreatesConstructs acheck boxCheckbox with the specified labelinset to the specifiedcheck box groupstate andset toin the specifiedstatecheck box group. @param label a string label for this check box ornull
for no label. @param state the initial state of this check box. @param group a check box group for this check box ornull
for no group. @exception HeadlessException ifGraphicsEnvironment.isHeadless
returnstrue
@see java.awt.GraphicsEnvironment#isHeadless @since JDK1.1
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 @seeClass Checkbox, CheckboxGroup getCheckboxGroup()java.awt.event.ItemEvent#removeItemListener @see #getItemListeners @see #setState @see java.awt.event.ItemListenerItemEvent @see java.awt.Checkbox#removeItemListenerevent.ItemListener @since JDK1.1
Determines this check box's group. @return this check box's group orClass Checkbox, String getLabel()null
if the check box is not part of a check box group. @seejava.awt.Checkbox#setCheckboxGroup
Gets the label of this check box. @return the label of this check box orClass Checkbox, EventListener[] getListeners(Class)null
if this check box has no label. @seejava.awt.Checkbox#setLabel
Class Checkbox, boolean getState()ReturnReturns an array of all thelistenersobjectsthat were addedcurrently registered astoFooListener
sthe Checkboxupon thiswithCheckbox
.addXXXListener()FooListener
swhere XXX isare registered using thenameaddFooListener
ofmethod. You can specify thelistenerType
argument.For example to get all ofwith a class literal such astheFooListener.class
.ItemListener(s)Forforexampletheyou can querygivenaCheckbox
c
onefor itswoulditemwritelisteners with the following code:If no suchItemListener[] ils = (ItemListener[])(c.getListeners(ItemListener.class));listenerlisteners existlist exists thenthis method returns an empty arrayis returned. @param listenerTypeTypethe type of listeners requested; this parameter should specify an interface that descends fromjava.util.EventListener
@returnallan array oftheall objects registered asFooListener
s on this checkbox or an empty array if no such listenersof the specifiedhave been addedtype@exceptionsupported byClassCastException ifthislistenerType
checkboxdoesn't specify a class or interface that implementsjava.util.EventListener
@see #getItemListeners @since 1.3
Determines whether this check box is in the "on" or "off" state. The boolean valueClass Checkbox, String paramString()true
indicates the "on" state andfalse
indicates the "off" state. @return the state of this check box as a boolean value.@seejava.awt.Checkbox#setState
ReturnsClass Checkbox, void processEvent(AWTEvent)the parametera string representing the state of thischeck boxCheckbox
. Thisstringmethod isusefulintended 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 benull
. @return the parameter string of this check box.
Processes events on this check box. If the event is an instance ofClass Checkbox, void processItemEvent(ItemEvent)ItemEvent
this method invokes theprocessItemEvent
method. Otherwise it calls its superclass'sprocessEvent
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 @seejava.awt.Checkbox#processItemEvent @since JDK1.1
Processes item events occurring on this check box by dispatching them to any registeredClass Checkbox, void removeItemListener(ItemListener)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:
- An
ItemListener
object is registered viaaddItemListener
.- Item events are enabled via
enableEvents
.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 @seejava.awt.Checkbox#addItemListener @see java.awt.Component#enableEvents @since JDK1.1
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 @seeClass Checkbox, void setCheckboxGroup(CheckboxGroup)java.awt.event.ItemEvent#addItemListener @see #getItemListeners @see java.awt.event.ItemListenerItemEvent @see java.awt.Checkbox#addItemListenerevent.ItemListener @since JDK1.1
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 orClass Checkbox, void setLabel(String)null
to remove this check box from any check box group. @seejava.awt.Checkbox#getCheckboxGroup
Sets this check box's label to be the string argument. @param label a string to set as the new label orClass Checkbox, void setState(boolean)null
for no label. @seejava.awt.Checkbox#getLabel
Sets the state of this check box to the specified state. The boolean valuetrue
indicates the "on" state andfalse
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 anItemEvent
is by user interaction. @param state the boolean state of the check box.@seejava.awt.Checkbox#getState
TheCheckboxGroup
class is used to group together a set ofCheckbox
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
This class represents a check box that can be included in a menu.Class CheckboxMenuItem, constructor CheckboxMenuItem()ClickingSelectingonthe 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
theprocessEvent
method examines the event and passes it along toprocessItemEvent
. The latter method redirects the event to anyItemListener
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
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.1Class 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 orClass CheckboxMenuItem, void addItemListener(ItemListener)null
for an unlabeled menu item. @param state the initial state of the menu item wheretrue
indicates "on" andfalse
indicates "off." @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @since JDK1.1
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 @seeClass CheckboxMenuItem, EventListener[] getListeners(Class)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, boolean getState()ReturnReturns an array of all thelistenersobjectsthat were addedcurrently registered astoFooListener
sthe CheckboxMenuItemupon thiswithCheckboxMenuItem
.addXXXListener()FooListener
swhere XXX isare registered using thenameaddFooListener
ofmethod. You can specify thelistenerType
argument.For example to get all ofwith a class literal such astheFooListener.class
.ItemListener(s)Forforexampletheyou cangivenquery aCheckboxMenuItem
c
onefor its item listeners withwouldthe followingwritecode:If no suchItemListener[] ils = (ItemListener[])(c.getListeners(ItemListener.class));listenerlisteners existlist exists thenthis method returns an empty arrayis returned. @param listenerTypeTypethe type of listeners requested; this parameter should specify an interface that descends fromjava.util.EventListener
@returnallan array oftheall objects registered asFooListener
s on this checkbox menuitem or an empty array if no such listenersof the specifiedhave been addedtype@exceptionsupported byClassCastException ifthislistenerType
checkboxdoesn'tmenuspecifyitema class or interface that implementsjava.util.EventListener
@see #getItemListeners @since 1.3
Determines whether the state of this check box menu item is "on" or "off." @return the state of this check box menu item whereClass CheckboxMenuItem, String paramString()true
indicates "on" andfalse
indicates "off." @seejava.awt.CheckboxMenuItem#setState
ReturnsClass CheckboxMenuItem, void processEvent(AWTEvent)the parametera string representing the state of thischeck box menu itemCheckBoxMenuItem
. Thisstringmethod isusefulintended 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 benull
. @return the parameter string of this check box menu item.
Processes events on this check box menu item. If the event is an instance ofClass CheckboxMenuItem, void processItemEvent(ItemEvent)ItemEvent
this method invokes theprocessItemEvent
method. If the event is not an item event it invokesprocessEvent
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 @seejava.awt.CheckboxMenuItem#processItemEvent @since JDK1.1
Processes item events occurring on this check box menu item by dispatching them to any registeredClass CheckboxMenuItem, void removeItemListener(ItemListener)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:
- An
ItemListener
object is registered viaaddItemListener
.- Item events are enabled via
enableEvents
.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 @seejava.awt.CheckboxMenuItem#addItemListener @see java.awt.MenuItem#enableEvents @since JDK1.1
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 @seeClass CheckboxMenuItem, void setState(boolean)java.awt.event.ItemEvent#addItemListener @see #getItemListeners @see java.awt.event.ItemListenerItemEvent @see java.awt.Choice#addItemListenerevent.ItemListener @since JDK1.1
Sets this check box menu item to the specifed state. The boolean valuetrue
indicates "on" whilefalse
indicates "off."@paramNote
bthat this method should be primarily used to initialize thebooleanstate of the check box menu item. Programmatically setting the state ofthisthe check box menu item will not trigger anItemEvent
. The only way to trigger anItemEvent
is by user interaction. @param btrue
if the check box menu item is on otherwisefalse
@seejava.awt.CheckboxMenuItem#getState
TheClass Choice, constructor Choice()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 ofsetSize()/getSize()
is bound by such limitations. Native GUIChoice
components' size are often bound by such attributes as font size and length of items contained within theChoice
.@version 1.
64 0378 12/1403/0001 @author Sami Shaio @author Arthur van Hoff @since JDK1.0
Creates a new choice menu. The menu initially has no items in it.Class Choice, void add(String)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) @seejava.awt.Choice#select(java.lang.String)
Adds an item to thisClass Choice, void addItem(String)Choice
menu. @param item the item to be added @exception NullPointerException if the item's value isnull
.@since JDK1.1
Obsolete as of Java 2 platform v1.1. Please use theClass Choice, void addItemListener(ItemListener)add
method instead.Adds an item to this
Choice
menu. @param item the item to be added @exception NullPointerExceptionIfif the item's value is equal tonull
.
Adds the specified item listener to receive item events from thisClass Choice, void addNotify()Choice
menu. Item events are sent in response to user input but not in response to calls toselect
. If l isnull
no exception is thrown and no action is performed. @param l the item listener.@seejava.awt.event.ItemEvent#removeItemListener @see #getItemListeners @see #select @see java.awt.event.ItemListenerItemEvent @see java.awt.Choice#removeItemListenerevent.ItemListener @since JDK1.1
Creates theClass Choice, AccessibleContext getAccessibleContext()Choice
's peer. This peer allows us to change the look of theChoice
without changing its functionality. @see java.awt.Toolkit#createChoice(java.awt.Choice) @see java.awt.Component#getToolkit()
Gets theClass Choice, String getItem(int)AccessibleContext
associated with thisChoice
. ForChoice
components theAccessibleContext
takes the form of anAccessibleAWTChoice
. A newAccessibleAWTChoice
instance is created if necessary. @return anAccessibleAWTChoice
that serves as theAccessibleContext
of thisChoice
Gets the string at the specified index in thisClass Choice, int getItemCount()Choice
menu. @param index the index at which to begin.@seejava.awt.Choice#getItemCount
Returns the number of items in thisClass Choice, EventListener[] getListeners(Class)Choice
menu. @seereturnjava.awt.the number of items in thisChoice menu @see #getItem @since JDK1.1
Class Choice, String getSelectedItem()ReturnReturns an array of all thelistenersobjectsthat were addedcurrently registered astoFooListener
sthe Choiceupon thiswithChoice
.addXXXListener()FooListener
swhere XXX isare registered using thenameaddFooListener
ofmethod. You can specify thelistenerType
argument.For example to get all ofwith a class literal such astheFooListener.class
.ItemListener(s)Forforexampletheyou can querygivenaChoice
c
onefor itswoulditemwritelisteners with the following code:If no suchItemListener[] ils = (ItemListener[])(c.getListeners(ItemListener.class));listenerlisteners existlist exists thenthis method returns an empty arrayis returned. @param listenerTypeTypethe type of listeners requested; this parameter should specify an interface that descends fromjava.util.EventListener
@returnallan array oftheall objects registered asFooListener
s on this choice or an empty array if no such listenersof the specifiedhave been addedtype@exceptionsupported byClassCastException ifthislistenerType
choicedoesn't specify a class or interface that implementsjava.util.EventListener
@see #getItemListeners @since 1.3
Gets a representation of the current choice as a string. @return a string representation of the currently selected item in this choice menuClass Choice, Object[] getSelectedObjects().@seejava.awt.Choice#getSelectedIndex
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 toClass Choice, String paramString()index
are shifted up by one to accommodate the new item. Ifindex
is greater than or equal to the number of items in this choiceitem
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.
ReturnsClass Choice, void processEvent(AWTEvent)the parametera string representing the state of thischoiceChoice
menu. Thisstringmethod isusefulintended 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 benull
. @return the parameter string of thisChoice
menu.
Processes events on this choice. If the event is an instance ofClass Choice, void processItemEvent(ItemEvent)ItemEvent
it invokes theprocessItemEvent
method. Otherwise it calls its superclass'sprocessEvent
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 @seejava.awt.Choice#processItemEvent @since JDK1.1
Processes item events occurring on thisClass Choice, void remove(String)Choice
menu by dispatching them to any registeredItemListener
objects.This method is not called unless item events are enabled for this component. Item events are enabled when one of the following occurs:
- An
ItemListener
object is registered viaaddItemListener
.- Item events are enabled via
enableEvents
.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 @seejava.awt.Choice#addItemListener @see java.awt.Component#enableEvents @since JDK1.1
Class Choice, void remove(int)RemoveRemoves the first occurrence ofitem
from theChoice
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 thisChoice
menu.@exception IllegalArgumentException if the item doesn't exist in the choice menu.@since JDK1.1
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 itemClass Choice, void removeAll().@throws IndexOutOfBoundsException if the specified position is out of bounds @since JDK1.1
Removes all items from the choice menu. @seeClass Choice, void removeItemListener(ItemListener)java.awt.Choice#remove @since JDK1.1
Removes the specified item listener so that it no longer receives item events from thisClass Choice, void select(String)Choice
menu. If l isnull
no exception is thrown and no action is performed. @param l the item listener.@seejava.awt.event.ItemEvent#addItemListener @see #getItemListeners @see java.awt.event.ItemListenerItemEvent @see java.awt.Choice#addItemListenerevent.ItemListener @since JDK1.1
Sets the selected item in thisClass Choice, void select(int)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 anItemEvent
is by user interaction. @param str the specified string @seejava.awt.Choice#getSelectedItem @seejava.awt.Choice#getSelectedIndex
Sets the selected item in thisChoice
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 anItemEvent
is by user interaction. @param pos the positon of the selected item.@exception IllegalArgumentException if the specified position isinvalid.greater than the number of items or less than zero @seejava.awt.Choice#getSelectedItem @seejava.awt.Choice#getSelectedIndex
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. ClassComponent
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 theSerializable
protocol will be saved when the object is stored. If an AWT object has listeners that aren't marked serializable they will be dropped atwriteObject
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 serializingaButton
by itself will causeMyApp
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 aboutMyApp
and theActionListener
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
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 theClass Component.AccessibleAWTComponent, Accessible getAccessibleAt(Point)Point
relative to the coordinate system of the object @return true if object containsPoint
; otherwise false
Returns theClass Component.AccessibleAWTComponent, Accessible getAccessibleChild(int)Accessible
child if one exists contained at the local coordinatePoint
. Otherwise returnsnull
. @param pThethe point defining the top-left corner of theAccessible
given in the coordinate space of the object's parent.@return theAccessible
if it exists at the specified location; elsenull
Class Component.AccessibleAWTComponent, int getAccessibleChildrenCount()ReturnReturns the nthAccessible
child of the object. @param i zero-based index of child @return the nthAccessible
child of the object
Returns the number of accessible children in the object. If all of the children of this object implementClass Component.AccessibleAWTComponent, AccessibleComponent getAccessibleComponent()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, String getAccessibleDescription()GetGets theAccessibleComponent
associated with this object if one exists. Otherwise returnnull
. @return the component
Class Component.AccessibleAWTComponent, int getAccessibleIndexInParent()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 benull
if this object does not have a description @see javax.accessibility.AccessibleContext#setAccessibleDescription
Class Component.AccessibleAWTComponent, String getAccessibleName()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, Accessible getAccessibleParent()GetGets the accessible name of this object. This should almost never returnjava.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 benull
if this object does not have a name @see javax.accessibility.AccessibleContext#setAccessibleName
Class Component.AccessibleAWTComponent, AccessibleRole getAccessibleRole()GetGets theAccessible
parent of this object. If the parent of this object implementsAccessible
this method should simply returngetParent
. @return the()Accessible
parent of this object -- can benull
if this object does not have anAccessible
parent
Class Component.AccessibleAWTComponent, AccessibleStateSet getAccessibleStateSet()GetGets the role of this object. @return an instance ofAccessibleRole
describing the role of the object @see javax.accessibility.AccessibleRole
Class Component.AccessibleAWTComponent, Color getBackground()GetGets the state of this object. @return an instance ofAccessibleStateSet
containing the current state set of the object @see javax.accessibility.AccessibleState
Class Component.AccessibleAWTComponent, Rectangle getBounds()GetGets the background color of this object. @return the background color if supported of the object; otherwisenull
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. @returnClass Component.AccessibleAWTComponent, Cursor getCursor()Aa rectangle indicating this component's bounds;null
if this object is not on the screen.
Class Component.AccessibleAWTComponent, Font getFont()GetGets theCursor
of this object. @return theCursor
if supported of the object; otherwisenull
Class Component.AccessibleAWTComponent, FontMetrics getFontMetrics(Font)GetGets theFont
of this object. @return theFont
if supported for the object; otherwisenull
Class Component.AccessibleAWTComponent, Color getForeground()GetGets theFontMetrics
of this object. @param f theFont
@return theFontMetrics
if supported the object; otherwisenull
@see #getFont
Class Component.AccessibleAWTComponent, Locale getLocale()GetGets the foreground color of this object. @return the foreground color if supported of the object; otherwisenull
Class Component.AccessibleAWTComponent, Point getLocation()ReturnReturns the locale of this object. @return the locale of this object
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. @returnClass Component.AccessibleAWTComponent, Point getLocationOnScreen()Anan instance of Point representing the top-left corner of theobjectsobject's bounds in the coordinate space of the screen;null
if this object or its parent are not on the screen
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 aClass Component.AccessibleAWTComponent, boolean isEnabled()Dimension
object. The height field of theDimension
object contains this objects's height and the width field of theDimension
object contains this object's width. @returnAaDimension
object that indicates the size of this component;null
if this object is not on the screen
Class Component.AccessibleAWTComponent, boolean isShowing()DetermineDetermines if the object is enabled. @return true if object is enabled; otherwise false
Class Component.AccessibleAWTComponent, boolean isVisible()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, void setBackground(Color)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 useisShowing
. @return true if object is visible; otherwise false()
Class Component.AccessibleAWTComponent, void setBounds(Rectangle)SetSets the background color of this object. (For transparency seeisOpaque
.) @param c the newColor
for the background @see Component#isOpaque
Sets the bounds of this object in the form of aClass Component.AccessibleAWTComponent, void setCursor(Cursor)Rectangle
object. The bounds specify this object's width height and location relative to its parent. @paramAa rectangle indicating this component's bounds
Class Component.AccessibleAWTComponent, void setEnabled(boolean)SetSets theCursor
of this object. @param c the newCursor
for the object
Class Component.AccessibleAWTComponent, void setFont(Font)SetSets the enabled state of the object. @param b if true enables this object; otherwise disables it
Class Component.AccessibleAWTComponent, void setForeground(Color)SetSets theFont
of this object. @param f the newFont
for the object
Class Component.AccessibleAWTComponent, void setLocation(Point)SetSets the foreground color of this object. @param c the newColor
for the foreground
Sets the location of the object relative to the parent. @param p the coordinates of the objectClass Component.AccessibleAWTComponent, void setSize(Dimension)
Resizes this object so that it has width width and height. @param d -Class Component.AccessibleAWTComponent, void setVisible(boolean)Thethe dimension specifying the new size of the object.
SetSets the visible state of the object. @param b if true shows this object; otherwise hides it
Adds the specified popup menu to the component. @param popup the popup menu to be added to the component. @seeClass Component, void addComponentListener(ComponentListener)java.awt.Component#remove(java.awt.MenuComponent) @since JDK1.1
Adds the specified component listener to receive component events from this component. If listenerClass Component, void addFocusListener(FocusListener)l is
null
no exception is thrown and no action is performed. @param l the componentlistenerlistene. @see java.awt.event.ComponentEvent @see java.awt.event.ComponentListener @seejava.awt.Component#removeComponentListener @see #getComponentListeners @since JDK1.1
Adds the specified focus listener to receive focus events from this component when this component gains input focus. If listenerClass Component, void addHierarchyBoundsListener(HierarchyBoundsListener)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 @seejava.awt.Component#removeFocusListener @see #getFocusListeners @since JDK1.1
Adds the specified hierarchy bounds listener to receive hierarchy bounds events from this component when the hierarchy to which this container belongs changes. If listenerClass Component, void addHierarchyListener(HierarchyListener)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 @seejava.awt.Component#removeHierarchyBoundsListener @see #getHierarchyBoundsListeners @since 1.3
Adds the specified hierarchy listener to receive hierarchy changed events from this component when the hierarchy to which this container belongs changes. If listenerClass Component, void addInputMethodListener(InputMethodListener)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 @seejava.awt.Component#removeHierarchyListener @see #getHierarchyListeners @since 1.3
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 overridesClass Component, void addKeyListener(KeyListener)getInputMethodRequests
to return anInputMethodRequests
instance. If listenerl 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 @seejava.awt.Component#removeInputMethodListener @seejava.awt.Component#getInputMethodListeners @see #getInputMethodRequests @since 1.2
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 @seeClass Component, void addMouseListener(MouseListener)java.awt.Component#removeKeyListener @see #getKeyListeners @since JDK1.1
Adds the specified mouse listener to receive mouse events from this component. If listenerClass Component, void addMouseMotionListener(MouseMotionListener)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 @seejava.awt.Component#removeMouseListener @see #getMouseListeners @since JDK1.1
Adds the specified mouse motion listener to receive mouse motion events from this component. If listenerClass Component, void addNotify()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 @seejava.awt.Component#removeMouseMotionListener @see #getMouseMotionListeners @since JDK1.1
Makes thisClass Component, void addPropertyChangeListener(PropertyChangeListener)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. @seejava.awt.Component#isDisplayable @seejava.awt.Component#removeNotify @since JDK1.0
Class Component, void addPropertyChangeListener(String, PropertyChangeListener)AddAdds a PropertyChangeListener to the listener list. The listener is registered for all bound properties.A PropertyChangeEvent will getof this class including thefiredfollowing:inNote that if this Component is inheriting a bound property then no event will be fired in response to a change in the inherited property.
response- this
toComponent'sanfontexplicit("font")- this Component's
setFont setBackgroundbackground coloror("background")- this Component's
SetForeground onforeground colorthe("foreground")current- this
component.Component'sNotefocusabilitythat("focusable")if- this
theComponent'scurrent component is inheriting itsfocus traversal keys enabled stateforeground("focusTraversalKeysEnabled")background- this
orComponent'sfontSet of FORWARD_TRAVERSAL_KEYS ("forwardFocusTraversalKeys")- this Component's Set of BACKWARD_TRAVERSAL_KEYS ("backwardFocusTraversalKeys")
- this Component's Set
fromofitsUP_CYCLE_TRAVERSAL_KEYScontainer("upCycleFocusTraversalKeys")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, int checkImage(Image, ImageObserver)AddAdds a PropertyChangeListener to the listener list for a specific property. Thelistenerspecifiedwillproperty may beinvokeduser-definedonly whenor oneaof thecallfollowing:onNote that
firePropertyChange- this
namesComponent's font ("font")- this Component's background color ("background")
- this Component's foreground color ("foreground")
- this Component's focusability ("focusable")
- this Component's focus traversal keys enabled state ("focusTraversalKeysEnabled")
- this Component's Set of FORWARD_TRAVERSAL_KEYS ("forwardFocusTraversalKeys")
- this Component's Set of BACKWARD_TRAVERSAL_KEYS ("backwardFocusTraversalKeys")
- this Component's Set of UP_CYCLE_TRAVERSAL_KEYS ("upCycleFocusTraversalKeys")
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 propertyto listennames listedon.above @param listenerThethe PropertyChangeListener to be added @see #removePropertyChangeListener(java.lang.String) @see #getPropertyChangeListeners(java.lang.String) @see #addPropertyChangeListener(java.beans.PropertyChangeListener)
Returns the status of the construction of a screen representation of the specified image.Class Component, int checkImage(Image, int, int, ImageObserver)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 theImage
object whose status is being checked.@param observer theImageObserver
object to be notified as the image is being prepared.@return the bitwise inclusive OR ofImageObserver
flags indicating what information about the image is currently available.@seejava.awt.Component#prepareImage(java.awt.Image int int java.awt.image.ImageObserver) @seejava.awt.Toolkit#checkImage(java.awt.Image int int java.awt.image.ImageObserver) @see java.awt.image.ImageObserver @since JDK1.0
Returns the status of the construction of a screen representation of the specified image.Class Component, AWTEvent coalesceEvents(AWTEvent, AWTEvent)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 ofComponent
calls its peer'scheckImage
method to calculate the flags. If this component does not yet have a peer the component's toolkit'scheckImage
method is called instead.Information on the flags returned by this method can be found with the discussion of the
ImageObserver
interface. @param image theImage
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 theImageObserver
object to be notified as the image is being prepared.@return the bitwise inclusive OR ofImageObserver
flags indicating what information about the image is currently available.@seejava.awt.Component#prepareImage(java.awt.Image int int java.awt.image.ImageObserver) @seejava.awt.Toolkit#checkImage(java.awt.Image int int java.awt.image.ImageObserver) @see java.awt.image.ImageObserver @since JDK1.0
Potentially coalesce an event being posted with an existing event. This method is called byClass Component, boolean contains(Point)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) ornull
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 unlessnull
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 complexRepaintArea
in the peer. The newEventAWTEvent
is always returned. @param existingEvent the event already on theEventQueue
@param newEvent the event being posted to the.EventQueue
@return a coalesced event or.null
indicating that no coalescing was done.
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 pointClass Component, boolean contains(int, int).@seejava.awt.Component#getComponentAt(java.awt.Point) @since JDK1.1
Checks whether this component "contains" the specified point whereClass Component, Image createImage(ImageProducer)x
andy
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.@seejava.awt.Component#getComponentAt(int int) @since JDK1.1
Creates an image from the specified image producer. @param producer the image producer @return the image producedClass Component, Image createImage(int, int).@since JDK1.0
Creates an off-screen drawable image to be used for double buffering. @param width the specified widthClass Component, void disableEvents(long).@param height the specified height.@return an off-screen drawable image which can be used for double buffering. The return value may benull
if the component is not displayable. This will always happen ifGraphicsEnvironment.isHeadless()
returnstrue
. @see #isDisplayable @see GraphicsEnvironment#isHeadless @since JDK1.0
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 @seeClass Component, void dispatchEvent(AWTEvent)java.awt.Component#enableEvents @since JDK1.1
Dispatches an event to this component or one of its sub components. CallsClass Component, void enableEvents(long)processEvent
before returning for 1.1-style events which have been enabled for the()Component
. @param e the event
Enables the events defined by the specified event mask parameter to be delivered to this component.Class Component, void enableInputMethods(boolean)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 toprocessEvent
regardless of whether or not a listener is registered. @param eventsToEnable the event mask defining the event types.@seejava.awt.Component#processEvent @seejava.awt.Component#disableEvents @see AWTEvent @since JDK1.1
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 disableClass Component, AccessibleContext getAccessibleContext().@seejava.awt.Component#processKeyEvent @since 1.2
Class Component, Color getBackground()GetGets theAccessibleContext
associated with thisComponent
. The method implemented by this base class returns null. Classes that extendComponent
should implement this method to return theAccessibleContext
associated with the subclass. @return theAccessibleContext
of thisComponent
Gets the background color of this component. @returnClass Component, Rectangle getBounds()Thisthis component's background color.;Ifif this component does not have a background color the background color of its parent is returned.@seejava.awt.Component#setBackground(java.awt.Color)@since JDK1.0
Gets the bounds of this component in the form of aClass Component, Rectangle getBounds(Rectangle)Rectangle
object. The bounds specify this component's width height and location relative to its parent. @returnAa rectangle indicating this component's bounds.@see #setBounds @see #getLocation @see #getSize
Class Component, ColorModel getColorModel()StoreStores the bounds of this component into "return value" rv and return rv. If rv isnull
a newRectangle
is allocated. This version ofgetBounds
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
Gets the instance ofClass Component, Component getComponentAt(Point)ColorModel
used to display the component on the output device. @returnThethe color model used by this component.@see java.awt.image.ColorModel @see java.awt.peer.ComponentPeer#getColorModel() @seejava.awt.Toolkit#getColorModel() @since JDK1.0
Returns the component or subcomponent that contains the specified point. @param p the pointClass Component, Component getComponentAt(int, int).@see java.awt.Component#contains @since JDK1.1
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.Class Component, ComponentOrientation getComponentOrientation()The
locate
method ofComponent
simply returns the component itself if the (x y) coordinate location is inside its bounding box andnull
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.@seejava.awt.Component#contains(int int) @since JDK1.0
Class Component, Cursor getCursor()RetrieveRetrieves the language-sensitive orientation that is to be used to order the elements or text within this component.LayoutManager
andComponent
subclasses that wish to respect orientation should call this method to get the component's orientation before performing layout or drawing. @seejava.awt.ComponentOrientation @author Laura Werner IBM
Gets the cursor set in the component. If the component does not have a cursor set the cursor of its parent is returned. If noClass Component, DropTarget getDropTarget()Cursorcursor is set in the entire hierarchyCursor.DEFAULT_CURSOR
is returned. @see #setCursor @since JDK1.1
Class Component, Font getFont()GetGets theDropTarget
associated with thisComponent
.
Gets the font of this component. @returnClass Component, FontMetrics getFontMetrics(Font)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
Gets the font metrics for the specified font. @param fontClass Component, Color getForeground()Thethe font for which font metrics is to be obtained.@returnThethe font metrics forfont
.@param font the font.@return the font metrics for the specified font.@seejava.awt.Component#getFont @seejava.awt.Component#getPeer()@see java.awt.peer.ComponentPeer#getFontMetrics(java.awt.Font) @seejava.awt.Toolkit#getFontMetrics(java.awt.Font) @since JDK1.0
Gets the foreground color of this component. @returnClass Component, Graphics getGraphics()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
Creates a graphics context for this component. This method will returnClass Component, GraphicsConfiguration getGraphicsConfiguration()null
if this component is currently not displayable. @returnAa graphics context for this component ornull
if it has none.@seejava.awt.Component#paint @since JDK1.0
Class Component, int getHeight()GetGets theGraphicsConfiguration
associated with thisComponent
. If theComponent
has not been assigned a specificGraphicsConfiguration
theGraphicsConfiguration
of theComponent
object's top-level container is returned. If theComponent
has been created but not yet added to aContainer
this method returnsnull
. @return theGraphicsConfiguration
used by thisComponent
ornull
@since 1.3
Class Component, InputContext getInputContext()ReturnReturns the current height of this component. This method is preferable to writingcomponent.getBounds().height
because it doesn't cause any heap allocations. @return the current height of this componentorcomponent.getSize().height.@since 1.2
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. @returnClass Component, InputMethodRequests getInputMethodRequests()Thethe input context used by this component.;Nullnull
if no context can be determined.@since 1.2
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 anClass Component, EventListener[] getListeners(Class)InputMethodRequests
instance. At the same time it also has to handle input method events. @return the input method request handler for this componentnull
by default.@see #addInputMethodListener @since 1.2
Class Component, Locale getLocale()ReturnReturns an array of all thelistenersobjectsthat were addedcurrently registered astoFooListener
sthe Componentupon thiswithComponent
.addXXXListener()FooListener
swhere XXX isare registered using thenameaddFooListener
method.
ofYou can specify thelistenerType
argument.For example to get all ofwith a class literal such astheFooListener.class
. ForMouseListeners for the givenexample you can query aComponent
c
onefor its mouse listeners with thewould writefollowing code:If no suchMouseListener[] mls = (MouseListener[])(c.getListeners(MouseListener.class));listenerlisteners existlist exists thenthis method returns an empty arrayis returned. @param listenerTypeTypethe type of listeners requested. This; this parametermustshouldbe aspecify an interface that descends fromjava.util.EventListener
or subclass.@returnsreturn an array of alllistenersobjectsadded toregistered asthisFooListener
sComponent using addXXXListeneron this component or an empty array if no such listeners have been addedto this Component.@throwsexception ClassCastException ifthelistenerType
parameterisdoesn'tnotspecify a class or interface that implementsjava.util.EventListener
or@seesubclass.#getComponentListeners @see #getFocusListeners @see #getHierarchyListeners @see #getHierarchyBoundsListeners @see #getKeyListeners @see #getMouseListeners @see #getMouseMotionListeners @see #getMouseWheelListeners @see #getInputMethodListeners @see #getPropertyChangeListeners @since 1.3
Gets the locale of this component. @returnClass Component, Point getLocation()Thisthis component's locale.;Ifif this component does not have a locale the locale of its parent is returned.@see #setLocale @exception IllegalComponentStateExceptionIfif theComponent
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
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.Class Component, Point getLocation(Point)Due to the asynchronous nature of native event handling this method can return outdated values (for instance after several calls of
@returnsetLocation()
in rapid succession). For this reason the recommended method of obtaining aComponentcomponent's position is withinjava.awt.event.ComponentListener.componentMoved()
which is called after the operating system has finished moving theComponentcomponent.Anan instance ofPoint
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 getLocationOnScreen()StoreStores the x y origin of this component into "return value" rv and return rv. If rv isnull
a newPoint
is allocated. This version ofgetLocation
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
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. @returnClass Component, Dimension getMaximumSize()Anan instance ofPoint
representing the top-left corner of the component's bounds in the coordinate space of the screen.@throwsIllegalComponentStateException
if the component is not showing on the screen @see #setLocation @see #getLocation
Gets the maximum size of this component. @returnClass Component, Dimension getMinimumSize()Aa dimension object indicating this component's maximum size.@see #getMinimumSize @see #getPreferredSize @see LayoutManager
Gets the mininimum size of this component. @returnClass Component, String getName()Aa dimension object indicating this component's minimum size.@see #getPreferredSize @seejava.awtLayoutManagerLayoutManager
Gets the name of the component. @returnClass Component, Container getParent()Thisthis component's name.@see #setName @since JDK1.1
Gets the parent of this component. @returnClass Component, ComponentPeer getPeer()Thethe parent container of this component.@since JDK1.0
@deprecated As of JDK version 1.1 programs should not directly manipulate peersClass Component, Dimension getPreferredSize().; replaced byboolean isDisplayable()
.
Gets the preferred size of this component. @returnClass Component, Dimension getSize()Aa dimension object indicating this component's preferred size.@see #getMinimumSize @seejava.awt.LayoutManager
Returns the size of this component in the form of aClass Component, Dimension getSize(Dimension)Dimension
object. Theheight
field of theDimension
object contains this component's height and thewidth
field of theDimension
object contains this component's width. @returnAaDimension
object that indicates the size of this component.@see #setSize @since JDK1.1
Class Component, Toolkit getToolkit()StoreStores the width/height of this component into "return value" rv and return rv. If rv isnull
a newDimension
object is allocated. This version ofgetSize
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
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. @returnClass Component, Object getTreeLock()Thethe toolkit of this component.@since JDK1.0
GetsClass Component, int getWidth()the locking object for AWT component-tree and layout Getsthis component's locking object (the object that owns the thread sychronization monitor) for AWT component-tree and layout operations. @returnThisthis component's locking object.
Class Component, int getX()ReturnReturns the current width of this component. This method is preferable to writingcomponent.getBounds().width
orcomponent.getSize().width
because it doesn't cause any heap allocations. @return the current width of this component.@since 1.2
Class Component, int getY()ReturnReturns the current x coordinate of the components origin. This method is preferable to writingcomponent.getBounds().x
orcomponent.getLocation().x
because it doesn't cause any heap allocations. @return the current x coordinate of the components origin.@since 1.2
Class Component, boolean hasFocus()ReturnReturns the current y coordinate of the components origin. This method is preferable to writingcomponent.getBounds().y
orcomponent.getLocation().y
because it doesn't cause any heap allocations. @return the current y coordinate of the components origin.@since 1.2
ReturnsClass Component, boolean imageUpdate(Image, int, int, int, int, int)true
if thisComponent
hasis thekeyboardfocus owner. This method is obsolete and has been replaced byisFocusOwner()
. @returntrue
if thisComponent
hasis thekeyboardfocus.owner;false
otherwise @since 1.2
Repaints the component when the image has changed. ThisClass Component, void invalidate()imageUpdate
method of anImageObserver
is called when more information about an image which had been previously requested using an asynchronous routine such as thedrawImage
method ofGraphics
becomes available. See the definition ofimageUpdate
for more information on this method and its arguments.The
imageUpdate
method ofComponent
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 valuetrue
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
andheight
arguments depends on the value of theinfoflags
argument. @param img the image being observed.@param infoflags seeimageUpdate
for more information.@param x the x coordinate.@param y the y coordinate.@param w the width.@param h the height.@returnfalse
if the infoflags indicate that the image is completely loaded;true
otherwise. @see java.awt.image.ImageObserver @seejava.awt.Graphics#drawImage(java.awt.Image int intjava.awt.Color java.awt.image.ImageObserver) @seejava.awt.Graphics#drawImage(java.awt.Image int int java.awt.image.ImageObserver) @seejava.awt.Graphics#drawImage(java.awt.Image int int int intjava.awt.Color java.awt.image.ImageObserver) @seejava.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
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. @seeClass Component, boolean isDisplayable()java.awt.Component#validate @seejava.awt.Component#doLayout @seejava.awt.LayoutManager @since JDK1.0
Determines whether this component is displayable. A component is displayable when it is connected to a native screen resource.Class Component, boolean isEnabled()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.@seejava.awt.Container#add(java.awt.Component) @seejava.awt.Window#pack @seejava.awt.Window#show @seejava.awt.Container#remove(java.awt.Component) @seejava.awt.Window#dispose @since 1.2
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 itsClass Component, boolean isFocusTraversable()setEnabled
method. @returntrue
if the component is enabled;false
otherwise.@see #setEnabled @since JDK1.0
ReturnsClass Component, boolean isLightweight()the value of a flag that indicateswhether thiscomponent 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()Componentbut it will not automaticallycanbe assignedbecome the focusduring tab traversalowner. @returntrue
if thiscomponentComponent
isfocus-traverablefocusable;false
otherwise.@see #setFocusable @since JDK1.1 @deprecated As of 1.4 replaced byisFocusable()
.
A lightweight component doesn't have a native toolkit peer. Subclasses ofClass Component, boolean isOpaque()Component
andContainer
other than the ones defined in this package likeButton
orScrollbar
are lightweight. All of the Swing components are lightweights.This method will always return
false
if thisComponentcomponent is not displayable because it is impossible to determine the weight of an undisplayableComponentcomponent. @return true if this component has a lightweight peer; false if it has a native peer or no peer.@see #isDisplayable @since 1.2
Returns true if this component is completely opaque returns false by default.Class Component, boolean isShowing()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
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. @returnClass Component, boolean isValid()true
if the component is showing;false
otherwise.@see #setVisible @since JDK1.0
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. @returnClass Component, boolean isVisible()true
if the component is valid;false
otherwise.@see #validate @see #invalidate @since JDK1.0
Determines whether this component should be visible when its parent is visible. Components are initially visible with the exception of top level components such asClass Component, void list(PrintStream)Frame
objects. @returntrue
if the component is visible;false
otherwise.@see #setVisible @since JDK1.0
Prints a listing of this component to the specified output stream. @param out a print streamClass Component, void list(PrintStream, int).@since JDK1.0
Prints out a list starting at the specifiedClass Component, void list(PrintWriter)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
Prints a listing to the specified print writer. @param outClass Component, void list(PrintWriter, int)Thethe print writer to print to.@since JDK1.1
Prints out a list starting at the specifiedClass Component, void paint(Graphics)indentionindentation to the specified print writer. @param outThethe print writer to print to.@param indentThethe number of spaces to indent.@see java.io.PrintStream#println(java.lang.Object) @since JDK1.1
Paints this component.Class Component, void paintAll(Graphics)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.@seejava.awt.Component#update @since JDK1.0
Paints this component and all of its subcomponents.Class Component, String paramString()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.@seejava.awt.Component#paint @since JDK1.0
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 beClass Component, boolean prepareImage(Image, ImageObserver)null
. @return a string representation of this component's state.@since JDK1.0
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 theClass Component, boolean prepareImage(Image, int, int, ImageObserver)Image
for which to prepare a screen representation.@param observer theImageObserver
object to be notified as the image is being prepared.@returntrue
if the image has already been fully prepared;false
otherwise.@since JDK1.0
Prepares an image for rendering on this component at the specified width and height.Class Component, void print(Graphics)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 theImageObserver
object to be notified as the image is being prepared.@returntrue
if the image has already been fully prepared;false
otherwise.@see java.awt.image.ImageObserver @since JDK1.0
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.Class Component, void printAll(Graphics)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.@seejava.awt.Component#paint(java.awt.Graphics) @since JDK1.0
Prints this component and all of its subcomponents.Class Component, void processComponentEvent(ComponentEvent)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.@seejava.awt.Component#print(java.awt.Graphics) @since JDK1.0
Processes component events occurring on this component by dispatching them to any registeredClass Component, void processEvent(AWTEvent)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:
- A
ComponentListener
object is registered viaaddComponentListener
.- Component events are enabled via
enableEvents
.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 @seejava.awt.Component#addComponentListener @seejava.awt.Component#enableEvents @since JDK1.1
Processes events occurring on this component. By default this method calls the appropriateClass Component, void processFocusEvent(FocusEvent)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.@seejava.awt.Component#processComponentEvent @seejava.awt.Component#processFocusEvent @seejava.awt.Component#processKeyEvent @seejava.awt.Component#processMouseEvent @seejava.awt.Component#processMouseMotionEvent @seejava.awt.Component#processInputMethodEvent @seejava.awt.Component#processHierarchyEvent @see #processMouseWheelEvent @since JDK1.1
Processes focus events occurring on this component by dispatching them to any registeredClass Component, void processHierarchyBoundsEvent(HierarchyEvent)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:
- A
FocusListener
object is registered viaaddFocusListener
.- Focus events are enabled via
enableEvents
.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 @seejava.awt.Component#addFocusListener @seejava.awt.Component#enableEvents @since JDK1.1
Processes hierarchy bounds events occurring on this component by dispatching them to any registeredClass Component, void processHierarchyEvent(HierarchyEvent)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:
- An
HierarchyBoundsListener
object is registered viaaddHierarchyBoundsListener
.- Hierarchy bounds events are enabled via
enableEvents
.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 @seejava.awt.Component#addHierarchyBoundsListener @seejava.awt.Component#enableEvents @since 1.3
Processes hierarchy events occurring on this component by dispatching them to any registeredClass Component, void processInputMethodEvent(InputMethodEvent)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:
- An
HierarchyListener
object is registered viaaddHierarchyListener
.- Hierarchy events are enabled via
enableEvents
.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 @seejava.awt.Component#addHierarchyListener @seejava.awt.Component#enableEvents @since 1.3
Processes input method events occurring on this component by dispatching them to any registeredClass Component, void processKeyEvent(KeyEvent)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:
- An
InputMethodListener
object is registered viaaddInputMethodListener
.- Input method events are enabled via
enableEvents
.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 @seejava.awt.Component#addInputMethodListener @seejava.awt.Component#enableEvents @since 1.2
Processes key events occurring on this component by dispatching them to any registeredClass Component, void processMouseEvent(MouseEvent)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:
- A
KeyListener
object is registered viaaddKeyListener
.- Key events are enabled via
enableEvents
.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
orenableEvents
methods but as of release 1.4 the implementation of the AWT event dispatching thread redirectsKeyEvent
to the focus owner. Please see the Focus Specification for further information.If the event parameter is
@param e the key eventnull
the behavior is unspecified and may result in an exception..@see java.awt.event.KeyEvent @see java.awt.event.KeyListener @seejava.awt.Component#addKeyListener @seejava.awt.Component#enableEvents @see #isShowing @since JDK1.1
Processes mouse events occurring on this component by dispatching them to any registeredClass Component, void processMouseMotionEvent(MouseEvent)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:
- A
MouseListener
object is registered viaaddMouseListener
.- Mouse events are enabled via
enableEvents
.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 @seejava.awt.Component#addMouseListener @seejava.awt.Component#enableEvents @since JDK1.1
Processes mouse motion events occurring on this component by dispatching them to any registeredClass Component, void remove(MenuComponent)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:
- A
MouseMotionListener
object is registered viaaddMouseMotionListener
.- Mouse motion events are enabled via
enableEvents
.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 @seejava.awt.Component#addMouseMotionListener @seejava.awt.Component#enableEvents @since JDK1.1
Removes the specified popup menu from the component. @param popup the popup menu to be removedClass Component, void removeComponentListener(ComponentListener).@seejava.awt.Component#add(java.awt.PopupMenu) @since JDK1.1
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 listenerClass Component, void removeFocusListener(FocusListener)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 @seejava.awt.Component#addComponentListener @see #getComponentListeners @since JDK1.1
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 listenerClass Component, void removeHierarchyBoundsListener(HierarchyBoundsListener)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 @seejava.awt.Component#addFocusListener @see #getFocusListeners @since JDK1.1
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 listenerClass Component, void removeHierarchyListener(HierarchyListener)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 @seejava.awt.Component#addHierarchyBoundsListener @see #getHierarchyBoundsListeners @since 1.3
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 listenerClass Component, void removeInputMethodListener(InputMethodListener)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 @seejava.awt.Component#addHierarchyListener @see #getHierarchyListeners @since 1.3
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 listenerClass Component, void removeKeyListener(KeyListener)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 @seejava.awt.Component#addInputMethodListener @see #getInputMethodListeners @since 1.2
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 listenerClass Component, void removeMouseListener(MouseListener)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 @seejava.awt.Component#addKeyListener @see #getKeyListeners @since JDK1.1
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 listenerClass Component, void removeMouseMotionListener(MouseMotionListener)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 @seejava.awt.Component#addMouseListener @see #getMouseListeners @since JDK1.1
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 listenerClass Component, void removeNotify()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 @seejava.awt.Component#addMouseMotionListener @see #getMouseMotionListeners @since JDK1.1
Makes thisClass Component, void removePropertyChangeListener(PropertyChangeListener)Component
undisplayable by destroying it native screen resource. This method is called by the toolkit internally and should not be called directly by programs. @seejava.awt.Component#isDisplayable @seejava.awt.Component#addNotify @since JDK1.0
Class Component, void removePropertyChangeListener(String, PropertyChangeListener)RemoveRemoves a PropertyChangeListener from the listener list. ThisremovesmethodashouldPropertyChangeListenerbe used to remove PropertyChangeListeners thatwaswere 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 repaint()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 ofathevalid propertythat was listened on.name @param listenerThethe PropertyChangeListener to be removed @see #addPropertyChangeListener(java.lang.String) @see #getPropertyChangeListeners(java.lang.String) @see #removePropertyChangeListener(java.beans.PropertyChangeListener)
Repaints this component.Class Component, void repaint(int, int, int, int)This method causes a call to this component's
update
method as soon as possible. @seejava.awt.Component#update(java.awt.Graphics) @since JDK1.0
Repaints the specified rectangle of this component.Class Component, void repaint(long)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.@seejava.awt.Component#update(java.awt.Graphics) @since JDK1.0
Repaints the component. This will result in a call toClass Component, void repaint(long, int, int, int, int)update
within tm milliseconds. @param tm maximum time in milliseconds before update @see #paint @seejava.awt.Component#update(java.awt.Graphics) @since JDK1.0
Repaints the specified rectangle of this component withinClass Component, void setBackground(Color)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.@seejava.awt.Component#update(java.awt.Graphics) @since JDK1.0
Sets the background color of this component.Class Component, void setBounds(Rectangle)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 isnull
then this component will inherit the background color of its parent. background color.@see #getBackground @since JDK1.0 @beaninfo bound: true
Moves and resizes this component to conform to the new bounding rectangleClass Component, void setBounds(int, int, int, int)r
. This component's new position is specified byr.x
andr.y
and its new size is specified byr.width
andr.height
@param rThethe new bounding rectangle for this component.@seejava.awt.Component#getBounds @seejava.awt.Component#setLocation(int int) @seejava.awt.Component#setLocation(java.awt.Point) @seejava.awt.Component#setSize(int int) @seejava.awt.Component#setSize(java.awt.Dimension) @since JDK1.1
Moves and resizes this component. The new location of the top-left corner is specified byClass Component, void setComponentOrientation(ComponentOrientation)x
andy
and the new size is specified bywidth
andheight
. @param xThethe new x-coordinate of this component.@param yThethe new y-coordinate of this component.@param widthThethe newwidth
of this component.@param heightThethe newheight
of this component.@seejava.awt.Component#getBounds @seejava.awt.Component#setLocation(int int) @seejava.awt.Component#setLocation(java.awt.Point) @seejava.awt.Component#setSize(int int) @seejava.awt.Component#setSize(java.awt.Dimension) @since JDK1.1
Class Component, void setCursor(Cursor)SetSets the language-sensitive orientation that is to be used to order the elements or text within this component. Language-sensitiveLayoutManager
andComponent
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 asComponentOrientation.LEFT_TO_RIGHT
.To set the orientation of a single component use this method. To
apply asetResourceBundle'sthe orientationtoof an entire component hierarchy usejava.awt.Window.applyResourceBundle.applyComponentOrientation @seejava.awt.ComponentOrientation @see java.awt.Window#applyResourceBundle(java.util.ResourceBundle) @author Laura Werner IBM @beaninfo bound: true
Sets the cursor image to the specified cursor. This cursor image is displayed when theClass Component, void setDropTarget(DropTarget)contains
method for this component returns true for the current cursor location and this Component is visible displayable and enabled. Setting the cursor of aContainer
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 theCursor
class. If; if this parameter isnull
then this component will inherit the cursor of its parent.@see #isEnabled @see #isShowing @seejava.awt.Component#getCursor @seejava.awt.Component#contains @seejava.awt.Toolkit#createCustomCursor @seejava.awt.Cursor @since JDK1.1
Associate aClass Component, void setEnabled(boolean)DropTarget
with thisComponentcomponent. TheComponent
will receive drops only if it is enabled. @see #isEnabled @param dt The DropTarget
Enables or disables this component depending on the value of the parameterClass Component, void setFont(Font)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
Sets the font of this component. @param fClass Component, void setForeground(Color)Thethe font to become this component's font.;Ifif this parameter isnull
then this component will inherit the font of its parent.@see #getFont @since JDK1.0 @beaninfo bound: true
Sets the foreground color of this component. @param cClass Component, void setLocale(Locale)Thethe color to become this component's foreground color.;Ifif this parameter isnull
then this component will inherit the foreground color of its parent.@see #getForeground @since JDK1.0
Sets the locale of this component. This is a bound property. @param lClass Component, void setLocation(Point)Thethe locale to become this component's locale.@see #getLocale @since JDK1.1
Moves this component to a new location. The top-left corner of the new location is specified by pointClass Component, void setLocation(int, int)p
. Pointp
is given in the parent's coordinate space. @param pThethe 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
Moves this component to a new location. The top-left corner of the new location is specified by theClass Component, void setName(String)x
andy
parameters in the coordinate space of this component's parent. @param xThethe x-coordinate of the new location's top-left corner in the parent's coordinate space.@param yThethe y-coordinate of the new location's top-left corner in the parent's coordinate space.@see #getLocation @see #setBounds @since JDK1.1
Sets the name of the component to the specified string. @param nameClass Component, void setSize(Dimension)Thethe string that is to be this component's name.@see #getName @since JDK1.1
Resizes this component so that it has widthClass Component, void setSize(int, int)d.width
and heightd.height
. @param dThethe dimension specifying the new size of this component.@see #setSize @see #setBounds @since JDK1.1
Resizes this component so that it has widthClass Component, void setVisible(boolean)width
and heightheight
. @param widthThethe new width of this component in pixels.@param heightThethe new height of this component in pixels.@see #getSize @see #setBounds @since JDK1.1
Shows or hides this component depending on the value of parameterClass Component, String toString()b
. @param bIfiftrue
shows this component; otherwise hides this component.@see #isVisible @since JDK1.1
Returns a string representation of this component and its values. @return a string representation of this componentClass Component, void transferFocus().@since JDK1.0
Transfers the focus to the next component as though this Component were the focus owner. @seeClass Component, void update(Graphics)java.awt.Component#requestFocus() @since JDK1.1s1
Updates this component.Class Component, void validate()The AWT calls the
update
method in response to a call torepaint
. The appearance of the component on the screen has not changed since the last call toupdate or
paint
. You can assume that the background is not cleared.The
update
method ofComponent
doescalls thisthecomponent'sfollowing:paint
method toClearsredraw this component.byThis methodfilling it with the backgroundis commonly overridden by subclassescolor.whichSetsneedthe color of the graphics contextto do additional work in response tobeathecall toforegroundrepaint
.colorSubclasses ofthisComponentcomponent.thatCallsoverride thiscomponent'smethodpaintshouldmethod toeither callcompletelysuper.update(g)redraw thisor callcomponent.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.@seejava.awt.Component#paint @seejava.awt.Component#repaint() @since JDK1.0
Ensures that this component has a valid layout. This method is primarily intended to operate on instances ofContainer
. @seejava.awt.Component#invalidate @seejava.awt.Component#doLayout() @seejava.awt.LayoutManager @seejava.awt.Container#validate @since JDK1.0
Class ComponentOrientation, ComponentOrientation getOrientation(ResourceBundle)ReturnReturns the orientation that is appropriate for the given locale. @param localeused as a key to look uptheorientation in an internalspecifiedresource bundle.locale
ReturnReturns the orientation appropriate for the given ResourceBundle's localization. Three approaches are triedinnin the following order:@deprecated As of J2SE 1.4 use #getOrientation(java.util.Locale)
- Retrieve a ComponentOrientation object from the ResourceBundle using the string "Orientation" as the key.
- Use the ResourceBundle.getLocale to determine the bundle's locale then return the orientation for that locale.
- Return the default locale's orientation.
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 @seejava.awt.Container#add(java.awt.Component int) @seejava.awt.Container#getComponent(int) @seejava.awt.LayoutManager @since JDK1.0
FirePropertyChange
listener if one is registered when children are added/or removed.
Returns theClass Container.AccessibleAWTContainer, Accessible getAccessibleChild(int)Accessible
child if one exists contained at the local coordinatePoint
. @param pThethe point defining the top-left corner of theAccessible
given in the coordinate space of the object's parent.@return theAccessible
if it exists at the specified location; elsenull
Class Container.AccessibleAWTContainer, int getAccessibleChildrenCount()ReturnReturns the nthAccessible
child of the object. @param i zero-based index of child @return the nthAccessible
child of the object
Returns the number of accessible children in the object. If all of the children of this object implementAccessible
thanthen this method should return the number of children of this object. @return the number of accessible children in the object.
Class Container, void add(Component, Object)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.
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 @seeClass Container, void add(Component, Object, int)java.awt.#addImpl @see LayoutManager @since JDK1.1
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 LayoutManagerClass 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 addedClass Container, Component add(String, Component).@param index the position at which to insert the component or-1
toinsertappend the componentatto the end.@return the componentcomp
@see #addImpl @see #remove
Adds the specified component to this container.Class Container, void addContainerListener(ContainerListener)ItThis isstronglyaadvised to useconvenience method forthe#addImplThis method is obsolete as of 1.1. Please use the method
add(Component Object)
inplace of this methodinstead.
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 #getContainerListenersClass 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 theClass Container, void doLayout()addLayoutComponent
method. The constraints are defined by the particular layout manager being used. For example theBorderLayout
class defines five constraints:BorderLayout.NORTH
BorderLayout.SOUTH
BorderLayout.EAST
BorderLayout.WEST
andBorderLayout.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 layoutcontraintsconstraints for this component.@param index the position in the container's list at which to insert the component where-1
meansinsert atappend to the end.@exception IllegalArgumentException ifindex
is invalid @exception IllegalArgumentException if adding the container's parent to itself @exception IllegalArgumentException if adding a window to a container @seejava.awt.Container#add(java.awt.Component) @seejava.awt.Container#add(java.awt.Component int) @seejava.awt.Container#add(java.awt.Component java.lang.Object) @seejava.awt.LayoutManager @see LayoutManager2 @since JDK1.1
Causes this container to lay out its components. Most programs should not call this method directly but should invoke theClass Container, Component findComponentAt(Point)validate
method instead. @seejava.awt.LayoutManager#layoutContainer @see #setLayout @see #validate @since JDK1.1
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.Class Container, Component findComponentAt(int, int)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
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.Class Container, Component getComponentAt(Point)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
Gets the component that contains the specified point. @param p the point. @return returns the component that contains the point orClass Container, int getComponentCount()null
if the component does not contain the point. @seejava.awt.Component#contains @since JDK1.1
Gets the number of components in this panel. @return the number of components in this panel. @seeClass Container, Insets getInsets()java.awt.Container#getComponent @since JDK1.1
Determines the insets of this container which indicate the size of the container's border.Class Container, EventListener[] getListeners(Class)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. @seejava.awt.Insets @seejava.awt.LayoutManager @since JDK1.1
Class Container, Dimension getMinimumSize()ReturnReturns an array of all thelistenersobjectsthat were addedcurrently registered astoFooListener
sthe Containerupon thiswithContainer
.addXXXListener()FooListener
swhere XXX isare registered using thenameaddFooListener
ofmethod. You can specify thelistenerType
argument.For example to get all ofwith a class literal such astheFooListener.class
.ContainerListener(s)Forforexampletheyou cangivenquery aContainer
c
onefor its container listeners withwouldthe followingwritecode:If no suchContainerListener[] cls = (ContainerListener[])(c.getListeners(ContainerListener.class));listenerlisteners existlist exists thenthis method returns an empty arrayis returned. @param listenerTypeTypethe type of listeners requested; this parameter should specify an interface that descends fromjava.util.EventListener
@returnallan array oftheall objects registered asFooListener
s on this container or an empty array if no such listenersof the specifiedhave been addedtype@exceptionsupported byClassCastException ifthislistenerType
containerdoesn't specify a class or interface that implementsjava.util.EventListener
@see #getContainerListeners @since 1.3
Returns the minimum size of this container. @return an instance ofClass Container, Dimension getPreferredSize()Dimension
that represents the minimum size of this container. @seejava.awt.Container#getPreferredSize @seejava.awt.Container#getLayout @seejava.awt.LayoutManager#minimumLayoutSize(java.awt.Container) @seejava.awt.Component#getMinimumSize @since JDK1.1
Returns the preferred size of this container. @return an instance ofClass Container, void list(PrintStream, int)Dimension
that represents the preferred size of this container. @seejava.awt.Container#getMinimumSize @seejava.awt.Container#getLayout @seejava.awt.LayoutManager#preferredLayoutSize(java.awt.Container) @seejava.awt.Component#getPreferredSize
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. @seeClass Container, void paint(Graphics)java.awt.Component#list(java.io.PrintStream int) @sinceJDKJDK1.0
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 @seeClass Container, void paintComponents(Graphics)java.awt.Component#update(java.awt.Graphics)
Paints each of the components in this container. @param g the graphics context. @seeClass Container, String paramString()java.awt.Component#paint @seejava.awt.Component#paintAll
ReturnsClass Container, void print(Graphics)the parametera string representing the state of thiscontainerContainer
. Thisstringmethod isusefulintended 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 benull
. @return the parameter string of this container.
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 @seeClass Container, void printComponents(Graphics)java.awt.Component#update(java.awt.Graphics)
Prints each of the components in this container. @param g the graphics context. @seeClass Container, void processContainerEvent(ContainerEvent)java.awt.Component#print @seejava.awt.Component#printAll
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:Class Container, void processEvent(AWTEvent)a)
- A ContainerListener object is registered via
addContainerListener
()b)- Container events are enabled via
enableEvents
()@seeComponent#enableEventsNote 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
Processes events on this container. If the event is aClass Container, void removeContainerListener(ContainerListener)ContainerEvent
it invokes theprocessContainerEvent
method else it invokes its superclass'sprocessEvent
.Note that if the event parameter is
null
the behavior is unspecified and may result in an exception. @param e the event
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 #getContainerListenersClass 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 @seejava.awt.Component#update(java.awt.Graphics)
A class to encapsulate the bitmap representation of the mouse cursor. @see Component#setCursor @version 1.Class Cursor, constructor Cursor(int)30 0236 12/0203/0001 @author Amy Fowler
Creates a new cursor object with the specified type. @param type the type of cursor @throws IllegalArgumentException if the specified cursor type is invalidClass 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 invalidClass 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
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 theClass Dialog, constructor Dialog(Dialog)getInsets
method however since these dimensions are platform-dependent a valid insets value cannot be obtained until the dialog is made displayable by either callingpack
orshow
. 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 ofwidth - (insets.left + insets.right)
byheight - (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
. This can only be done while the dialog is not displayablesetUndecorated
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 orminimized the dialog will automatically be hidden from the user. When the owner window is subsequentlyre-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
appapplicationcontextexcept 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
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 ifClass Dialog, constructor Dialog(Dialog, String)owner
isnull
. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @since 1.2
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. AClass Dialog, constructor Dialog(Dialog, String, boolean)null
value will be accepted without causing a NullPointerException to be thrown. @exception java.lang.IllegalArgumentException ifowner
isnull
. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @since 1.2
Constructs an initially invisibleClass Dialog, constructor Dialog(Frame)Dialog
with the specified owner dialog title and modality. @param owner the owner of the dialog @exception IllegalArgumentException if theowner
'sGraphicsConfiguration
is not from a screen device @param title the title of the dialog. A; anull
value will be accepted without causing aNullPointerException
to be thrown.@param modal if true dialog blocks input to other app windows when shown @exception java.lang.IllegalArgumentException ifowner
isnull
; this exception is always thrown whenGraphicsEnvironment.isHeadless
returnstrue
@see java.awt.GraphicsEnvironment#isHeadless @since 1.2
Constructs an initially invisible non-modalClass Dialog, constructor Dialog(Frame, String)Dialog
with an empty title and the specified owner frame. @param owner the owner of the dialog @exception IllegalArgumentException if theowner
'sGraphicsConfiguration
is not from a screen device @exception java.lang.IllegalArgumentException ifowner
isnull
; this exception is always thrown whenGraphicsEnvironment.isHeadless
returnstrue
@see java.awt.GraphicsEnvironment#isHeadless @see Component#setSize @see Component#setVisible
Constructs an initially invisible non-modalClass Dialog, constructor Dialog(Frame, String, boolean)Dialog
with the specified owner frame and title. @param owner the owner of the dialog @param title the title of the dialog. A; anull
value will be accepted without causing aNullPointerException
to be thrown.@exception IllegalArgumentException if theowner
'sGraphicsConfiguration
is not from a screen device @exception java.lang.IllegalArgumentException ifowner
isnull
; this exception is always thrown whenGraphicsEnvironment.isHeadless
returnstrue
@see java.awt.GraphicsEnvironment#isHeadless @see Component#setSize @see Component#setVisible
Constructs an initially invisibleClass Dialog, constructor Dialog(Frame, boolean)Dialog
with the specified owner frame title and modality. @param owner the owner of the dialog @param title the title of the dialog. A; anull
value will be accepted without causing aNullPointerException
to be thrown.@param modal if true dialog blocks input to other app windows when shown @exception IllegalArgumentException if theowner
'sGraphicsConfiguration
is not from a screen device @exception java.lang.IllegalArgumentException ifowner
isnull
. This exception is always thrown whenGraphicsEnvironment.isHeadless
returnstrue
@see java.awt.GraphicsEnvironment#isHeadless @see Component#setSize @see Component#setVisible
Constructs an initially invisibleClass Dialog, boolean isModal()Dialog
with an empty title the specified owner frame and modality. @param owner the owner of the dialog @param modal iftrue
dialog blocks input to other app windows when shown @exception IllegalArgumentException if theowner
'sGraphicsConfiguration
is not from a screen device @exception java.lang.IllegalArgumentException ifowner
isnull
; this exception is always thrown whenGraphicsEnvironment.isHeadless
returnstrue
@see java.awt.GraphicsEnvironment#isHeadless
Indicates whether the dialog is modal. When a modal Dialog is made visible user input will be blocked to the other windows in theClass Dialog, String paramString()appapplicationcontextexcept for any windows created with this dialog as their owner. @returntrue
if this dialog window is modal;false
otherwise. @see java.awt.Dialog#setModal
ReturnsClass Dialog, void setTitle(String)the parametera string representing the state of this dialogwindow. Thisstringmethod isusefulintended 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 benull
. @return the parameter string of this dialog window.
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
TheClass Dimension, constructor Dimension(Dimension)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 theComponent
class and theLayoutManager
interface return aDimension
object.Normally the values of
width
andheight
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 ofwidth
orheight
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
Creates an instance ofClass Dimension, constructor Dimension(int, int)Dimension
whose width and height are the same as for the specified dimension. @param d the specified dimension for thewidth
andheight
values.
Constructs aClass Dimension, double getHeight()Dimension
and initializes it to the specified width and specified height. @param width the specified widthdimension@param height the specified heightdimension
Returns the height of this dimension in double precision. @return the height of this dimension in double precisionClass Dimension, Dimension getSize()
Gets the size of thisClass Dimension, double getWidth()Dimension
object. This method is included for completeness to parallel thegetSize
method defined byComponent
. @return the size of this dimension a new instance ofDimension
with the same width and height.@see java.awt.Dimension#setSize @see java.awt.Component#getSize @since JDK1.1
Returns the width of this dimension in double precision. @return the width of this dimension in double precisionClass Dimension, int hashCode()
Returns the hash code for thisClass Dimension, void setSize(Dimension)Dimension
. @return a hash code for thisDimension
.
Class Dimension, void setSize(double, double)SetSets the size of thisDimension
object to the specified size. This method is included for completeness to parallel thesetSize
method defined byComponent
. @param d the new size for thisDimension
object.@see java.awt.Dimension#getSize @see java.awt.Component#setSize @since JDK1.1
Class Dimension, void setSize(int, int)SetSets the size of thisDimension
object to the specified width and height in double precision. Note that ifwidth
orheight
are larger thanInteger.MAX_VALUE
they will be reset toInteger.MAX_VALUE
. @param width the new width for theDimension
object @param height the new height for theDimension
object
Class Dimension, String toString()SetSets the size of thisDimension
object to the specified width and height. This method is included for completeness to parallel thesetSize
method defined byComponent
. @param width the new width for thisDimension
object.@param height the new height for thisDimension
object.@see java.awt.Dimension#getSize @see java.awt.Component#setSize @since JDK1.1
Returns a string representation of the values of thisClass Dimension, int heightDimension
object'sheight
andwidth
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 benull
. @return a string representation of thisDimension
object.
The height dimensionClass Dimension, int width. Negative; negative values can be used. @serial @see #getSize @see #setSize
The width dimension. Negative; negative values can be used. @serial @see #getSize @see #setSize
NOTE: TheClass Event, constructor Event(Object, int, Object)Event
class is obsolete and is available only for backwards compatilibility. It has been replaced by theAWTEvent
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 theEvent
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 ofkey
is one of the defined action-key identifiers in theEvent
class (PGUP
PGDN
F1
F2
etc). @version 1.68 0272 12/0203/0001 @author Sami Shaio @since JDK1.0
NOTE: TheClass Event, constructor Event(Object, long, int, int, int, int, int)Event
class is obsolete and is available only for backwards compatilibility. It has been replaced by theAWTEvent
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.
NOTE: TheClass Event, constructor Event(Object, long, int, int, int, int, int, Object)Event
class is obsolete and is available only for backwards compatilibility. It has been replaced by theAWTEvent
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 tonull
. @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.
NOTE: TheClass Event, boolean controlDown()Event
class is obsolete and is available only for backwards compatilibility. It has been replaced by theAWTEvent
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.
NOTE: TheClass Event, boolean metaDown()Event
class is obsolete and is available only for backwards compatilibility. It has been replaced by theAWTEvent
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
NOTE: TheClass Event, String paramString()Event
class is obsolete and is available only for backwards compatilibility. It has been replaced by theAWTEvent
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, boolean shiftDown()ReturnsNOTE: TheEvent
class is obsolete and is available only for backwards compatilibility. It has been replaced by theparameterAWTEvent
class and its subclasses.Returns a string representing the state of this
eventEvent
. Thisstringmethod isusefulintended 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 benull
. @return the parameter string of this event.
NOTE: TheClass Event, String toString()Event
class is obsolete and is available only for backwards compatilibility. It has been replaced by theAWTEvent
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
NOTE: TheClass Event, void translate(int, int)Event
class is obsolete and is available only for backwards compatilibility. It has been replaced by theAWTEvent
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
NOTE: TheClass Event, Object argEvent
class is obsolete and is available only for backwards compatilibility. It has been replaced by theAWTEvent
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.
An arbitrary argument of the event. The value of this field depends on the type of event.arg
has been replacedbby event specific property. @serial
Class EventQueue, void dispatchEvent(AWTEvent)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 theEventQueue
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 theEventQueue
beforeAWTEvent
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 globalEventQueue
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, AWTEvent getNextEvent()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, void invokeAndWait(Runnable)RemoveRemoves an event from theEventQueue
andreturnreturns it. This method will block until an event has been posted by another thread. @return the nextAWTEvent
@exception InterruptedException if another thread has interrupted this thread.
CausesClass EventQueue, void invokeLater(Runnable)runnable
to have itsrun
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 theRunnable
whoserun
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 runningrunnable
@see #invokeLater @since 1.2
CausesClass EventQueue, boolean isDispatchThread()runnable
to have itsrun
method called in the dispatch thread of the()EventQueue
. This will happen after all pending events are processed. @param runnable theRunnable
whoserun
method should be executed synchronously on the()EventQueue
@see #invokeAndWait @since 1.2
Returns true if the calling thread is the current AWTClass EventQueue, AWTEvent peekEvent()EventQueue
's dispatch thread. Use this call the ensure that a given task is being executed (or not being) on the current AWTEventDispatchThread
. @return true if running on the current AWTEventQueue
's dispatch thread.
Class EventQueue, AWTEvent peekEvent(int)ReturnReturns the first event on theEventQueue
without removing it. @return the first event
Class EventQueue, void pop()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 ornull
if there is no such event
Class EventQueue, void postEvent(AWTEvent)StopStops dispatching events using thisEventQueue
. Any pending events are transferred to the previousinstanceEventQueue
for processing.Warning: To avoid deadlock do not
bydeclareitthis method synchronized in a subclass. @exception EmptyStackException if no previous push was made on thisEventQueue
@see java.awt.EventQueue#push.
Class EventQueue, void push(EventQueue)PostPosts a 1.1-style event to theEventQueue
. If there is an existing event on the queue with the same ID and event source the sourceComponent
'scoalesceEvents
method will be called. @param theEvent an instance ofjava.awt.AWTEvent
or a subclass of it.
ReplaceReplaces the existingEventQueue
with the specified one. Any pending events are transferred to the newEventQueue
for processing by it. @param newEventQueue anEventQueue
(or subclass thereof) instance to beused.use @see java.awt.EventQueue#pop
TheClass FileDialog, constructor FileDialog(Frame)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
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 forClass FileDialog, constructor FileDialog(Frame, String, int)FileDialog(parent title LOAD)
. @param parent the owner of the dialog.@param title the title of the dialog.
Creates a file dialog window with the specified title for loading or saving a file.Class FileDialog, String getDirectory()If the value of
mode
isLOAD
then the file dialog is finding a file to read and the files shown are those in the current directory. If the value ofmode
isSAVE
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; eitherFileDialog.LOAD
orFileDialog
.SAVE @exception IllegalArgumentException if an illegal file dialog mode is supplied @see java.awt.FileDialog#LOAD @see java.awt.FileDialog#SAVE
Gets the directory of this file dialog. @return the (potentiallyClass FileDialog, String getFile()null
or invalid) directory of thisFileDialog
@see java.awt.FileDialog#setDirectory.
Gets the selected file of this file dialog. If the user selectedClass FileDialog, FilenameFilter getFilenameFilter()CANCEL
the returned file isnull
. @return the currently selected file of this file dialog window ornull
if none is selected.@see java.awt.FileDialog#setFile
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 filterClass FileDialog, int getMode().@see java.io.FilenameFilter @see java.awt.FileDialog#setFilenameFilter
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 eitherClass FileDialog, String paramString()FileDialog.LOAD
orFileDialog.SAVE
.@see java.awt.FileDialog#LOAD @see java.awt.FileDialog#SAVE @see java.awt.FileDialog#setMode
ReturnsClass FileDialog, void setDirectory(String)the parametera string representing the state of thisfile dialogFileDialog
window. Thisstringmethod isusefulintended 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 benull
. @return the parameter string of this file dialog window.
Sets the directory of this file dialog window to be the specified directory. Specifying aClass FileDialog, void setFile(String)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 pointgetDirectory()
will return the value passed into this method.Specifying "" as the directory is exactly equivalent to specifying
null
as the directory. @param dir thespecificspecified directory.@see java.awt.FileDialog#getDirectory
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.Class FileDialog, void setFilenameFilter(FilenameFilter)Specifying "" as the file is exactly equivalent to specifying
null
as the file. @param file the file being set.@see java.awt.FileDialog#getFile
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 filterClass FileDialog, void setMode(int).@see java.io.FilenameFilter @see java.awt.FileDialog#getFilenameFilter
Sets the mode of the file dialog. Ifmode
is not a legal value an exception will be thrown andmode
will not be set. @param mode the mode for this file dialog eitherFileDialog.LOAD
orFileDialog.SAVE
.@see java.awt.FileDialog#LOAD @see java.awt.FileDialog#SAVE @see java.awt.FileDialog#getMode @exception IllegalArgumentException if an illegal file dialog mode isused.supplied @since JDK1.1
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.Class FlowLayout, constructor FlowLayout()For example the following picture shows an applet using the flow layout manager (its default layout manager) to position 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
Constructs a newClass FlowLayout, constructor FlowLayout(int)FlowFlowLayout
Layoutwith a centered alignment and a default 5-unit horizontal and vertical gap.
Constructs a newClass FlowLayout, constructor FlowLayout(int, int, int)Flow LayoutFlowLayout
with the specified alignment and a default 5-unit horizontal and vertical gap. The value of the alignment argument must be one ofFlowLayout.LEFT
FlowLayout.RIGHT
orFlowLayout.CENTER
. @param align the alignment value
Creates a new flow layout manager with the indicated alignment and the indicated horizontal and vertical gaps.Class FlowLayout, int getAlignment()The value of the alignment argument must be one of
FlowLayout.LEFT
FlowLayout.RIGHT
orFlowLayout.CENTER
. @param align the alignment value.@param hgap the horizontal gap between components.@param vgap the vertical gap between components.
Gets the alignment for this layout. Possible values areClass FlowLayout, int getHgap()FlowLayout.LEFT
FlowLayout.RIGHT
FlowLayout.CENTER
FlowLayout.LEADING
orFlowLayout.
. @return the alignment value for this layoutCENTERTRAILING.@see java.awt.FlowLayout#setAlignment @since JDK1.1
Gets the horizontal gap between components. @return the horizontal gap between componentsClass FlowLayout, int getVgap().@see java.awt.FlowLayout#setHgap @since JDK1.1
Gets the vertical gap between components. @return the vertical gap between componentsClass FlowLayout, void layoutContainer(Container).@see java.awt.FlowLayout#setVgap @since JDK1.1
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 thisClass FlowLayout, Dimension minimumLayoutSize(Container)FlowLayout
object. @param target the specified component being laid out.@see Container @see java.awt.Container#doLayout
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 containerClass FlowLayout, Dimension preferredLayoutSize(Container).@see #preferredLayoutSize @see java.awt.Container @see java.awt.Container#doLayout
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 containerClass FlowLayout, void setAlignment(int).@see Container @see #minimumLayoutSize @see java.awt.Container#getPreferredSize
Sets the alignment for this layout. Possible values areClass FlowLayout, String toString()@param align one of the alignment
FlowLayout.LEFT
FlowLayout.RIGHT
andFlowLayout.CENTER
FlowLayout.LEADING
- .TRAILING
FlowLayout
value.values shown above @see #getAlignment() @since JDK1.1
Returns a string representation of thisClass FlowLayout, int LEADINGFlowLayout
object and its values. @return a string representation of this layout.
This value indicates that each row of components should be justified to the leading edge of the container's orientationClass FlowLayout, int TRAILINGe.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
This value indicates that each row of components should be justified to theleadingtrailing edge of the container's orientatione.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
TheClass Font, constructor Font(String, int, int)Font
class represents fonts. Thecapabilities of this class have been extended over thewhich are used to render text in a visiblejava.awtway.Font classinAJDK(tm)font1.1providesand earlier releasesthe information needed toprovide formapdevelopers thesequences ofabilitycharacters toutilize more sophisticated typographicsequencesfeatures.of glyphsIt is important to present the conceptsand to render sequences of glyphs onbehindGraphics
usingandtheComponent
wordsobjects.characterCharacters and
A character is a symbol that representsglyph separately.Glyphsitems like letters and numbers inan item such as a letter aparticulardigitwritingorsystempunctuation in an abstract way. For examplelowercase-'g'
LATIN SMALL LETTER G is a character.WhenA glyph is a
particularshapecharacterused tohasrenderbeena characterrenderedor ashapesequence of characters. In simple writing systems such as Latinnowtypically one glyph representsthisone character.ThisInshape is called ageneral however characters andglyphglyphs do not have one-to-one correspondence. For exampleChararcterthe characterencoding'á'isLATIN SMALL LETTER A WITH ACUTE can be represented by two glyphs: one for 'a'conversion table thatand one formaps'´'. On the other hand the two-charactercodesstringto"fi" can be represented by a single glyphcodesanin"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
characterencoding usedsequences toinglyph sequences using a font technology such as TrueType or PostScript Type 1. All implementations of the Java2D(tm)2APIplatform must support TrueType fonts; support for other font technologies isUnicodeimplementation dependent.For more information on Unicode you can visit the sitePhysical fonts may use names such as Helvetica Palatino HonMinchohttp://wwwor any number of other font names.unicodeTypically each physical font supports only a limited set of writing systems for example only Latin characters or only Japanese and Basic Latin.orgThe set of available physical fonts varies between configurations. ApplicationsCharactersthat require specific fonts can bundle them andglyphs do not haveinstantiate them using theone-to-onecreateFontcorrespondencemethod.For
exampleLogicallowercase-afontsacutearecanthe five font families defined by the Java platform which must berepresentedsupported bytwoanyglyphsJava runtime environment:lowercase-aSerif SansSerif Monospaced Dialog andacuteDialogInput.Another example is ligatures such asThese logical fonts are not actualligaturefont-filibraries.whichInstead the logical font names are mapped to physical fonts by the Java runtime environment. The mapping isa single glyph representing twoimplementation and usually locale dependentcharactersso theflook andithe metrics provided by them vary. Typically each logical font name maps to several physical fonts in order to cover a large range of characters.
APeeredFontAWTiscomponents such as Label and TextField can only use logical fonts.For
acollectiondiscussion ofglyphsthe relative advantages and disadvantages of using physical or logical fonts see the Internationalization FAQ document.Font Faces and Names
AFont
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 isthe same assimply the name thatused by java.awt.Font inwasJDKused1.1toand 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 severalFont
objects associated with a font face each differing in size style transform and font features. The getAllFonts method of theGraphicsEnvironment
class returns an array of all font faces available in the system. These font faces are returned asFont
objects with a size of 1 identity transform and default font features. These base fonts can then be used to derive newFont
objects with varying sizes styles transforms and font features via thederiveFont
methods in this class. @see GraphicsEnvironment#getAllFonts @version 1.143 02171 12/1303/01
Creates a newClass Font, int canDisplayUpTo(CharacterIterator, int, int)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 SerifSansSeriforSymbolSansSerif. Ifname
isnull
thename
of the newFont
is set to the name "Default". @param style the style constant for theFont
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 theFont
@see GraphicsEnvironment#getAllFonts @see GraphicsEnvironment#getAvailableFontFamilyNames @since JDK1.0
Indicates whether or not thisClass Font, int canDisplayUpTo(char[], int, int)Font
can display the specifiedString
. For strings with Unicode encoding it is important to know if a particular font can display the string. This method returns an offset into theString
str
which is the first character thisFont
cannot display without using the missing glyph code . If thisFont
can display all characters-1
is returned. @paramtextiter 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 theString
object that can be displayed by thisFont
. @since 1.2
Indicates whether or not thisClass Font, Font createFont(int, InputStream)Font
can display the characters in the specifiedtext
starting atstart
and ending atlimit
. 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 intotext
that points to the first character intext
that thisFont
cannot display; or-1
if thisFont
can display all characters intext
. @since 1.2
Returns a newClass Font, GlyphVector createGlyphVector(FontRenderContext, CharacterIterator)Font
with the specified font type and input data. The newFont
is created with a point size of 1 and style PLAIN This base font can then be used with thederiveFont
methods in this class to derive newFont
objects with varying sizes styles transforms and font features. This method does not close the InputStream @paramfontTypefontFormat the type of theFont
which is TRUETYPE_FONT if a TrueType is desired. Other types might be provided in the future. @param fontStream anInputStream
object representing the input data for the font. @return a newFont
created with the specified font type. @throws IllegalArgumentException iffontType
is notTRUETYPE_FONT
@throws FontFormatException if thefontStream
data does not contain the required Truetype font tables. @throws IOException if thefontStream
cannot be completely read. @since 1.3
Class Font, GlyphVector createGlyphVector(FontRenderContext, String)ReturnsCreates anewGlyphVectorobjectbycreated withmapping the specifiedCharacterIteratorcharactersandto glyphs one-to-one based on thespecifiedUnicode cmap in this. 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
FontRenderContextFontFontRenderContext
@param ci the specifiedCharacterIterator
@return a newGlyphVector
created with the specifiedCharacterIterator
and the specifiedFontRenderContext
.
Class Font, GlyphVector createGlyphVector(FontRenderContext, char[])ReturnsCreates anewGlyphVectorobject createdby mappingwithcharacters to glyphs one-to-one based on thespecifiedUnicode cmap in this.
StringFontandThis method does no other processing besides thespecifiedmappingFontRenderContextof 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 specifiedFontRenderContext
@param str the specifiedString
@return a newGlyphVector
created with the specifiedString
and the specifiedFontRenderContext
.
Class Font, GlyphVector createGlyphVector(FontRenderContext, int[])ReturnsCreates anewGlyphVector by mapping characters to glyphs one-to-one based on the Unicode cmap in this.
GlyphVectorFontobject created with the specifiedThis method does no otherarrayprocessing besides the mapping of glyphs to characters. This means that this method is not useful for some scripts such as Arabic Hebrew Thai andthe specifiedIndic thatFontRenderContextrequire reordering shaping or ligature substitution. @param frc the specifiedFontRenderContext
@param chars the specified array of characters @return a newGlyphVector
created with the specified array of characters and the specifiedFontRenderContext
.
Class Font, Font decode(String)ReturnsCreates anewGlyphVector by mapping characters to glyphs one-to-one based on the Unicode cmap in this.
GlyphVectorFontobject createdThis methodwithdoes no other processing besides thespecified integermapping ofarrayglyphs to characters. This means that this method is not useful for some scripts such as Arabic Hebrew Thai andthe specifiedIndic thatFontRenderContextrequire reordering shaping or ligature substitution. @param frc the specifiedFontRenderContext
@paramglyphcodesglyphCodes the specified integer array @return a newGlyphVector
created with the specified integer array and the specifiedFontRenderContext
.
Returns theClass Font, String getFamily()Font
that thestr
argument describes. To ensure that this method returns the desired Font format thestr
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 thestr
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. Ifstr
isnull
a newFont
is returned with the family name "dialog" a size of 12 and a PLAIN style. Ifstr
isnull
a newFont
is returned with the name "dialog" a size of 12 and a PLAIN style. @param str the name of the font ornull
@return theFont
object thatstr
describes or a new defaultFont
ifstr
isnull
. @see #getFamily @since JDK1.1
Returns the family name of thisClass Font, String getFamily(Locale)Font
.ForThe
examplefamilyHelveticaname ofcouldabefont is font specific. Tworeturnedfonts such asaHelvetica Italic and Helvetica Bold have the same family nameforHelvetica whereasthetheir font facenamenamesofare 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. UsegetFontName
to get the font face name of the font. @return aString
that is the family name of thisFont
. @see #getName @see #getFontName @since JDK1.1
Returns the family name of thisClass Font, Font getFont(Map)Font
localized for the specified locale.ForThe
examplefamilyHelveticaname ofcouldabefont is font specific. Two fontsreturnedsuch asaHelvetica Italic and Helvetica Bold have the same family nameforHelveticathewhereas their font facename 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 aString
representing the family name of the font localized for the specified locale. @see #getFontName @see java.util.Locale @since 1.2
Returns aClass Font, Rectangle2D getStringBounds(CharacterIterator, int, int, FontRenderContext)Font
appropriate to this attribute set. @param attributes the attributes to assign to the newFont
@return a newFont
created with the specified attributes.@since 1.2 @see java.awt.font.TextAttribute
Returns the logical bounds of the characters indexed in the specified CharacterIterator in the specifiedClass Font, Rectangle2D getStringBounds(String, FontRenderContext)FontRenderContext
. The logical boundsiscontains 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 obtainlayouta visual bounding box which encloses all the text use the getBounds method of. @param ci the specified
StringTextLayoutCharacterIterator
@param beginIndex the initial offset inci
@param limit the end offset inci
@param frc the specifiedFontRenderContext
@return aRectangle2D
that is the bounding box of the characters indexed in the specifiedCharacterIterator
in the specifiedFontRenderContext
. @see FontRenderContext @see Font#createGlyphVector @since 1.2 @throws IndexOutOfBoundsException ifbeginIndex
is less than the start index ofci
orlimit
is greater than the end index ofci
orbeginIndex
is greater thanlimit
Returns the logical bounds of the specifiedClass Font, Rectangle2D getStringBounds(String, int, int, FontRenderContext)String
in the specifiedFontRenderContext
. The logical boundsiscontains 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. Tousedobtaintoa visual bounding box which encloses alllayoutthe text use the getBounds method of. @param str the specified
StringTextLayoutString
@param frc the specifiedFontRenderContext
@return a Rectangle2D that is the bounding box of the specifiedString
in the specifiedFontRenderContext
. @see FontRenderContext @see Font#createGlyphVector @since 1.2
Returns the logical bounds of the specifiedClass Font, Rectangle2D getStringBounds(char[], int, int, FontRenderContext)String
in the specifiedFontRenderContext
. The logical boundsiscontains 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 obtainlayouta visual bounding box which encloses all the text use the getBounds method of. @param str the specified
StringTextLayoutString
@param beginIndex the initial offset ofstr
@param limit the end offset ofstr
@param frc the specifiedFontRenderContext
@return aRectangle2D
that is the bounding box of the specifiedString
in the specifiedFontRenderContext
. @throws IndexOutOfBoundsException ifbeginIndex
is less than zero orlimit
is greater than the length ofstr
orbeginIndex
is greater thanlimit
. @see FontRenderContext @see Font#createGlyphVector @since 1.2
Returns the logical bounds of the specified array of characters in the specifiedClass Font, AffineTransform getTransform()FontRenderContext
. The logical boundsiscontains the origin ascent advance andused to layoutheight which includes theStringleading. The logical bounds doescreated withnot always enclose all thespecifiedtext.array of charactersFor example inbeginIndexsome 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. @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
limitTextLayoutFontRenderContext
@return aRectangle2D
that is the bounding box of the specified array of characters in the specifiedFontRenderContext
. @throws IndexOutOfBoundsException ifbeginIndex
is less than zero orlimit
is greater than the length ofchars
orbeginIndex
is greater thanlimit
. @see FontRenderContext @see Font#createGlyphVector @since 1.2
Returns a copy of the transform associated with thisClass Font, int CENTER_BASELINEFont
. @paramreturn an AffineTransform object representing the transform attribute of thisFont
object.
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.
Thrown by method createFont in theClass FontFormatException, constructor FontFormatException(String)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
Report a FontFormatException for the reason specified. @param reason a String
message indicating why the font is not accepted.
TheClass FontMetrics, int charWidth(char)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):
- {@link #getAscent()}
- {@link #getLeading()}
- {@link #getMaxAdvance()}
- {@link #charWidth(char)}
- {@link #charsWidth(char[] int int)}
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 theString
. This distance is the width that should be used for centering or right-aligning theString
. Note that the advance of aString
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
Returns the advance width of the specified character in thisClass FontMetrics, int getHeight()Font
. The advance is the distance from the leftmost point to the rightmost point on the character's baseline. Note that the advance of aString
is not necessarily the sum of the advances of its characters. @param ch the character to be measured @return the advance width of the specifiedchar
in theFont
described by thisFontMetrics
object. @see #charsWidth(char[] int int) @see #stringWidth(String)
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 theFont
. @see #getMaxDescent() @deprecated As of JDK version 1.1.1 replaced bygetMaxDescent()
.
AClass Frame, constructor Frame()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 thegetInsets
method however since these dimensions are platform-dependent a valid insets value cannot be obtained until the frame is made displayable by either callingpack
orshow
. 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 ofwidth - (insets.left + insets.right)
byheight - (insets.top + insets.bottom)
.The default layout for a frame is
BorderLayout
.A frame may have its native decorations (i.e.
. This can only be done while the frame is not displayableFrame
andTitlebar
) turned off withsetUndecorated
In a multi-screen environment you can create a
Frame
on a different screen device by constructing theFrame
with #Frame(GraphicsConfiguration) or titl GraphicsConfiguration)}. TheGraphicsConfiguration
object is one of theGraphicsConfiguration
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 callinggetLocationOnScreen
on aFrame
returns virtual device coordinates. Call thegetBounds
method of aGraphicsConfiguration
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 correspondingGraphicsConfiguration
. If the bounds of theGraphicsConfiguration
is not taken into account theFrame
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 specifiedGraphicsConfiguration
.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 eventsWindowEvent
s:WindowOpened@version 1.
WINDOW_OPENED
WINDOW_CLOSING
WINDOW_CLOSED
WINDOW_ICONIFIED
WINDOW_DEICONIFIED
WindowClosingWINDOW_ACTIVATED
WindowClosedWINDOW_DEACTIVATED
WindowIconifiedWINDOW_GAINED_FOCUS
WindowDeiconifiedWINDOW_LOST_FOCUS
WindowActivatedWINDOW_STATE_CHANGED
WindowDeactivated.108 04131 12/0603/0001 @author Sami Shaio @see WindowEvent @see Window#addWindowListener @since JDK1.0
Constructs a new instance ofClass Frame, constructor Frame(GraphicsConfiguration)Frame
that is initially invisible. The title of theFrame
is empty. @exception HeadlessException when GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless() @see Component#setSize @see Component#setVisible(boolean)
Create aClass Frame, constructor Frame(String)Frame
with the specifiedGraphicsConfiguration
of a screen device. @param gc theGraphicsConfiguration
of the target screen device. Ifgc
isnull
the system defaultGraphicsConfiguration
is assumed. @exception IllegalArgumentException ifgc
is not from a screen device. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless() @since 1.3
Constructs a new initially invisibleClass Frame, constructor Frame(String, GraphicsConfiguration)Frame
object with the specified title. @param title the title to be displayed in the frame's border. Anull
value is treated as an empty string "". @exceptionIllegalArgumentException ifHeadlessException whengc is notGraphicsEnvironment.isHeadless()from areturns truescreen@seedevicejava.awt.GraphicsEnvironment#isHeadless() @see java.awt.Component#setSize @see java.awt.Component#setVisible(boolean) @see java.awt.GraphicsConfiguration#getBounds
Constructs a new initially invisibleClass Frame, Image getIconImage()Frame
object with the specified title and aGraphicsConfiguration
. @param title the title to be displayed in the frame's border. Anull
value is treated as an empty string "". @param gc theGraphicsConfiguration
of the target screen device. Ifgc
isnull
the system defaultGraphicsConfiguration
is assumed. @exception IllegalArgumentException ifgc
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
Gets the image to be displayed in the minimized icon for this frame. @return the icon image for this frame orClass Frame, MenuBar getMenuBar()null
if this frame doesn't have an icon image. @seejava.awt.Frame#setIconImage(Icon)
Gets the menu bar for this frame. @return the menu bar for this frame orClass Frame, int getState()null
if this frame doesn't have a menu bar. @seejava.awt.Frame#setMenuBar(MenuBar)
Gets the state of this frame (obsolete).Class Frame, String getTitle()@return
Frame.In older versions of JDK a frame state could only be NORMAL or ICONIFIED. Since JDK 1.4 set ofifsupported frameinstatesiconicis expanded and frame state;is represented as a bitwise mask.For compatibility with old programs this method still
returnsFrame.NORMAL
ifandFrame.ICONIFIED
but it only reports the iconic state of the frameisother aspectsin normalof frame state are not reported by this method. @seereturnjava.awtFrame.NORMAL
orFrame.ICONIFIED
. @see #setState(int) @see #getExtendedState
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. @seeClass Frame, boolean isResizable()java.awt.Frame#setTitle(String)
Indicates whether this frame is resizable by the user. By default all frames are initially resizable. @returnClass Frame, String paramString()true
if the user can resize this frame;false
otherwise. @see java.awt.Frame#setResizable(boolean)
ReturnsClass Frame, void remove(MenuComponent)theaparameterstring representing theStringstate of thisFrame
. 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 benull
. @return the parameter string of this frame
Removes the specified menu bar from this frame. @param m the menu component to remove. IfClass Frame, void setIconImage(Image)this parameterm
isnull
thena NullPointerException is thrown andno action is taken.
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 isClass Frame, void setMenuBar(MenuBar)null
then the icon image is set to the default image which may vary with platform. @seejava.awt.Frame#getIconImage
Sets the menu bar for this frame to the specified menu bar. @param mb the menu bar being set. If this parameter isClass Frame, void setState(int)null
then any existing menu bar on this frame is removed. @seejava.awt.Frame#getMenuBar
Sets the state of this frame (obsolete).Class Frame, void setTitle(String)@paramIn older versions of JDK a frame state
Frame.could only be NORMAL or ICONIFIEDif. SincethisJDK 1.4 set of supported frame states isin iconicexpanded and frame state;is represented as a bitwise mask.For compatibility with old programs this method still accepts
Frame.NORMAL
ifandthisFrame.ICONIFIED
but it only changes the iconic state of the frameisother aspectsin normalof frame state are not affected by this method. @seeparamjava.awtstate eitherFrame
.NORMAL orFrame.ICONIFIED. @see #getState @see #setExtendedState(int)
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. Anull
value is treated as an empty string "". @seejava.awt.Frame#getTitle
Constructs a simple acyclicClass GradientPaint, constructor GradientPaint(Point2D, Color, Point2D, Color, boolean)GradientPaint
object. @param pt1 the first specifiedPoint
in user space @param color1Color
at the first specifiedPoint
@param pt2 the second specifiedPoint
in user space @param color2Color
at the second specifiedPoint
@throws NullPointerException if either one of colors or points is null
Constructs either a cyclic or acyclicClass GradientPaint, constructor GradientPaint(float, float, Color, float, float, Color)GradientPaint
object depending on theboolean
parameter. @param pt1 the first specifiedPoint
in user space @param color1Color
at the first specifiedPoint
@param pt2 the second specifiedPoint
in user space @param color2Color
at the second specifiedPoint
@param cyclictrue
if the gradient pattern should cycle repeatedly between the two colors;false
otherwise @throws NullPointerException if either one of colors or points is null
Constructs a simple acyclicGradientPaint
object. @param x1 y1 coordinates of the first specifiedPoint
in user space @param color1Color
at the first specifiedPoint
@param x2 y2 coordinates of the second specifiedPoint
in user space @param color2Color
at the second specifiedPoint
@throws NullPointerException if either one of colors is null
TheClass Graphics, boolean drawImage(Image, int, int, Color, ImageObserver)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:
- The
Component
object on which to draw.- A translation origin for rendering and clipping coordinates.
- The current clip.
- The current color.
- The current font.
- The current logical pixel operation function (XOR or Paint).
- The current XOR alternation color (see
Coordinates are infinitely thin and lie between the pixels of the output device. Operations that draw the outline of a figure operate by traversing an infinitely thin path between pixels with a pixel-sized pen that hangs down and to the right of the anchor point on the path. Operations that fill a figure operate by filling the interior of that infinitely thin path. Operations that render horizontal text render the ascending portion of character glyphs entirely above the baseline coordinate.
The graphics pen hangs down and to the right from the path it traverses. This has the following implications:
- If you draw a figure that covers a given rectangle that figure occupies one extra row of pixels on the right and bottom edges as compared to filling a figure that is bounded by that same rectangle.
- If you draw a horizontal line along the same y coordinate as the baseline of a line of text that line is drawn entirely below the text except for any descenders.
All coordinates that appear as arguments to the methods of this
Graphics
object are considered relative to the translation origin of thisGraphics
object prior to the invocation of the method.All rendering operations modify only pixels which lie within the area bounded by the current clip which is specified by a Shape in user space and is controlled by the program using the
Graphics
object. This user clip is transformed into device space 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 cannot be modified by the rendering system to reflect the resulting composite clip. The user clip can only be changed through thesetClip
orclipRect
methods. All drawing or writing is done in the current color using the current paint mode and in the current font. @version 1.63 0564 12/2403/01 @author Sami Shaio @author Arthur van Hoff @see java.awt.Component @see java.awt.Graphics#clipRect(int int int int) @see java.awt.Graphics#setColor(java.awt.Color) @see java.awt.Graphics#setPaintMode() @see java.awt.Graphics#setXORMode(java.awt.Color) @see java.awt.Graphics#setFont(java.awt.Font) @since JDK1.0
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.Class Graphics, boolean drawImage(Image, int, int, ImageObserver)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
returnsfalse
. 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. @returntrue
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)
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.Class Graphics, boolean drawImage(Image, int, int, int, int, Color, ImageObserver)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
returnsfalse
. 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. @returntrue
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)
Draws as much of the specified image as has already been scaled to fit inside the specified rectangle.Class Graphics, boolean drawImage(Image, int, int, int, int, ImageObserver)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
returnsfalse
. 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)
Draws as much of the specified image as has already been scaled to fit inside the specified rectangle.Class Graphics, boolean drawImage(Image, int, int, int, int, int, int, int, int, Color, ImageObserver)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
returnsfalse
. As more of the image becomes available the process that draws the image notifies the image observer by calling itsimageUpdate
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)
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.Class Graphics, boolean drawImage(Image, int, int, int, int, int, int, int, int, ImageObserver)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
returnsfalse
. 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
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.Class Graphics, Rectangle getClipRect()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
returnsfalse
. 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
Returns the bounding rectangle of the current clipping area. @return the bounding rectangle of the current clipping area orClass Graphics, Color getColor()null
if no clip is set. @deprecated As of JDK version 1.1 replaced bygetClipBounds()
.
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 areaClass Graphics, void setClip(int, int, int, int)intersects the boundingmightrectangle ofintersect the current clipping area. The coordinates of the specified rectangular area are in therectangleuser 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 @returntrue
if the specified rectangle intersects the bounds of the current clip;false
otherwise.
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
ThisClass Graphics2D, void drawGlyphVector(GlyphVector, float, float)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 aGraphics2D
object are specified in a device-independent coordinate system called User Space which is used by applications. TheGraphics2D
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 theGraphics2D
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 aGraphics2D
object.When creating a
Graphics2D
object theGraphicsConfiguration
specifies the default transform for the target of theGraphics2D
(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 theIdentity
transform.Rendering Process
The Rendering Process can be broken down into four phases that are controlled by theGraphics2D
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:
- Determine what to render.
- Constrain the rendering operation to the current
Clip
. TheClip
is specified by a Shape in user space and is controlled by the program using the various clip manipulation methods ofGraphics
andGraphics2D
. This user clip is transformed into device space by the currentTransform
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.- Determine what colors to render.
- 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:
Shape
operations
- If the operation is a
draw(Shape)
operation then the createStrokedShape method on the current Stroke attribute in theGraphics2D
context is used to construct a newShape
object that contains the outline of the specifiedShape
.- The
Shape
is transformed from user space to device space using the currentTransform
in theGraphics2D
context.- The outline of the
Shape
is extracted using the getPathIterator method ofShape
which returns a PathIterator object that iterates along the boundary of theShape
.- If the
Graphics2D
object cannot handle the curved segments that thePathIterator
object returns then it can call the alternate double getPathIterator} method ofShape
which flattens theShape
.- The current Paint in the
Graphics2D
context is queried for a PaintContext which specifies the colors to render in device space.- Text operations
- The following steps are used to determine the set of glyphs required to render the indicated
String
:
- If the argument is a
String
then the currentFont
in theGraphics2D
context is asked to convert the Unicode characters in theString
into a set of glyphs for presentation with whatever basic layout and shaping algorithms the font implements.- 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.- 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.- 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.- The character outlines are filled as indicated above under
Shape
operations.- The current
Paint
is queried for aPaintContext
which specifies the colors to render in device space.Image
Operations
- The region of interest is defined by the bounding box of the source
Image
. This bounding box is specified in Image Space which is theImage
object's local coordinate system.- If an
AffineTransform
is passed to java.awt.geom.AffineTransfor java.awt.image.ImageObserver) drawImage(Image AffineTransform ImageObserver)} theAffineTransform
is used to transform the bounding box from image space to user space. If noAffineTransform
is supplied the bounding box is treated as if it is already in user space.- The bounding box of the source
Image
is transformed from user space into device space using the currentTransform
. Note that the result of transforming the bounding box does not necessarily result in a rectangular region in device space.- The
Image
object determines what colors to render sampled according to the source to destination coordinate mapping specified by the currentTransform
and the optional image transform.Default Rendering Attributes
The default values for theGraphics2D
rendering attributes are:
Paint
- The color of the
Component
.Font
- The
Font
of theComponent
.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 theComponent
.Composite
- The AlphaComposite#SRC_OVER rule.
Clip
- No rendering
Clip
the output is clipped to theComponent
.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
andfill
methods are defined which clearly indicates howGraphics2D
extendsGraphics
based on settings ofStroke
andTransform
attributes and rendering hints. The definition performs identically under default attribute settings. For example the defaultStroke
is aBasicStroke
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.
- Device coordinates are defined to be between device pixels which avoids any inconsistent results between aliased and antaliased rendering. If coordinates were defined to be at a pixel's center some of the pixels covered by a shape such as a rectangle would only be half covered. With aliased rendering the half covered pixels would either be rendered inside the shape or outside the shape. With anti-aliased rendering the pixels on the entire edge of the shape would be half covered. On the other hand since coordinates are defined to be between pixels a shape like a rectangle would have no half covered pixels whether or not it is rendered using antialiasing.
- Lines and paths stroked using the
BasicStroke
object may be "normalized" to provide consistent rendering of the outlines when positioned at various points on the drawable and whether drawn with aliased or antialiased rendering. This normalization process is controlled by the KEY_STROKE_CONTROL hint. The exact normalization algorithm is not specified but the goals of this normalization are to ensure that lines are rendered with consistent visual appearance regardless of how they fall on the pixel grid and to promote more solid horizontal and vertical lines in antialiased mode so that they resemble their non-antialiased counterparts more closely. A typical normalization step might promote antialiased line endpoints to pixel centers to reduce the amount of blending or adjust the subpixel positioning of non-antialiased lines so that the floating point line widths round to even or odd pixel counts with equal likelihood. This process can move endpoints by up to half a pixel (usually towards positive infinity along both axes) to promote these consistent results.The following definitions of general legacy methods perform identically to previously specified behavior under default attribute settings:
The
- For
fill
operations includingfillRect
fillRoundRect
fillOval
fillArc
fillPolygon
andclearRect
fill can now be called with the desiredShape
. For example when filling a rectangle:fill(new Rectangle(x y w h));is called.
- Similarly for draw operations including
drawLine
drawRect
drawRoundRect
drawOval
drawArc
drawPolyline
anddrawPolygon
draw can now be called with the desiredShape
. For example when drawing a rectangle:draw(new Rectangle(x y w h));is called.
- The
draw3DRect
andfill3DRect
methods were implemented in terms of thedrawLine
andfillRect
methods in theGraphics
class which would predicate their behavior upon the currentStroke
andPaint
objects in aGraphics2D
context. This class overrides those implementations with versions that use the currentColor
exclusively overriding the currentPaint
and which usesfillRect
to describe the exact same behavior as the preexisting methods regardless of the setting of the currentStroke
.Graphics
class defines only thesetColor
method to control the color to be painted. Since the Java 2D API extends theColor
object to implement the newPaint
interface the existingsetColor
method is now a convenience method for setting the currentPaint
attribute to aColor
object.setColor(c)
is equivalent tosetPaint(c)
.The
Graphics
class defines two methods for controlling how colors are applied to the destination.@version 1.
- The
setPaintMode
method is implemented as a convenience method to set the defaultComposite
equivalent tosetComposite(new AlphaComposite.SrcOver)
.- The
setXORMode(Color xorcolor)
method is implemented as a convenience method to set a specialComposite
object that ignores theAlpha
components of source colors and sets the destination color to the value:dstpixel = (PixelOf(srccolor) ^ PixelOf(xorcolor) ^ dstpixel);70 0276 12/0203/0001 @author Jim Graham @see java.awt.RenderingHints
Renders the text of the specified GlyphVector using theClass Graphics2D, void drawString(String, float, float)Graphics2D
context's rendering attributes. The rendering attributes applied include theClip
Transform
Paint
andComposite
attributes. TheGlyphVector
specifies individual glyphs from a Font TheGlyphVector
can also contain the glyph positions. This is the fastest way to render a set of characters to the screen. @param g theGlyphVector
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
Renders the text specified by the specifiedClass Graphics2D, void drawString(String, int, int)String
using the currentFont andtextPaintattributeattributesstate in theGraphics2D
context. The baseline of the first character is at position (x y) in the User Space. The rendering attributes applied include theClip
Transform
Paint
Font
andComposite
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 theString
to be rendered @param x y the coordinates where theString
should be rendered @throws NullPointerException ifstr
isnull
@see #setPaint @see java.awt.Graphics#setColor @see java.awt.Graphics#setFont @see #setTransform @see #setComposite @see #setClip
Renders the text of the specifiedClass Graphics2D, GraphicsConfiguration getDeviceConfiguration()String
using the currentFont andtextPaintattributeattributesstate in theGraphics2D
context. The baseline of the first character is at position (x y) in the User Space. The rendering attributes applied include theClip
Transform
Paint
Font
andComposite
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 theString
should be rendered @throws NullPointerException ifstr
isnull
@see java.awt.Graphics#drawBytes @see java.awt.Graphics#drawChars @since JDK1.0
Returns the device configuration associated with thisClass Graphics2D, Object getRenderingHint(Key)Graphics2D
. @return the device configuration of thisGraphics2D
.
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 theClass Graphics2D, RenderingHints getRenderingHints()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 theRenderingHints
class. @see RenderingHints @see #setRenderingHint(RenderingHints.Key Object)
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 theClass Graphics2D, void setComposite(Composite)RenderingHints
class for definitions of some common keys and values. @return a reference to an instance ofRenderingHints
that contains the current preferences. @see RenderingHints @see #setRenderingHints(Map)
Sets theClass Graphics2D, void setPaint(Paint)Composite
for theGraphics2D
context. TheComposite
is used in all drawing methods such asdrawImage
drawString
draw
andfill
. 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 aComponent
on the display screen and theComposite
is a custom object rather than an instance of theAlphaComposite
class and if there is a security manager itscheckPermission
method is called with anAWTPermission("readDisplayPixels")
permission. @throws SecurityException if a customComposite
object is being used to render to the screen and a security manager is set and itscheckPermission
method does not allow the operation. @param comp theComposite
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
Sets theClass Graphics2D, void setRenderingHint(Key, Object)Paint
attribute for theGraphics2D
context. Calling this method with anull
Paint
object does not have any effect on the currentPaint
attribute of thisGraphics2D
. @param paint thePaint
object to be used to generate color during the rendering process ornull
@see java.awt.Graphics#setColor @see #getPaint @see GradientPaint @see TexturePaint
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 specifiedClass Graphics2D, void setStroke(Stroke)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 theRenderingHints
class for definitions of some common keys and values. @param hints the rendering hints to be set @see #getRenderingHints @see RenderingHints
Sets theClass Graphics2D, void setTransform(AffineTransform)Stroke
for theGraphics2D
context. @param s theStroke
object to be used to stroke aShape
during the rendering process @see BasicStroke @see #getStroke
SetsOverwrites the Transform in theGraphics2D
context. WARNING: This method should never be used to apply a new coordinate transform on top of an existing transform because theGraphics2D
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
orshear
methods. ThesetTransform
method is intended only for restoring the originalGraphics2D
transform after rendering as shown in this example:@param Tx the// Get the current transform AffineTransform saveAT = g2.getTransform(); // Perform transformation g2d.transform(...); // Render g2d.draw(...); // Restore original transform g2d.setTransform(saveAT);AffineTransform
object tothatbe used inwas retrieved from therenderinggetTransform
processmethod @see #transform @see #getTransform @see AffineTransform
TheGraphicsConfigTemplate
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 thisGraphicsConfigTemplate
. A validGraphicsConfiguration
is returned that meets or exceeds what was requested in theGraphicsConfigTemplate
. @see GraphicsDevice @see GraphicsConfiguration @version 1.13 0214 12/0203/0001 @since 1.2
TheGraphicsDevice
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 theGraphicsDevice
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 aJFrame
object for eachGraphicsConfiguration
on each screen device in theGraphicsEnvironment
:GraphicsEnvironment ge = GraphicsEnvironment. getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); for (int j = 0; j@see GraphicsEnvironment @see GraphicsConfiguration @version 1. 21 0225 12/0903/01
TheClass GraphicsEnvironment, String[] getAvailableFontFamilyNames()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 thisGraphicsEnvironment
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. EachGraphicsDevice
has a number of GraphicsConfiguration objects associated with it. These objects specify the different configurations in which theGraphicsDevice
can be used. @see GraphicsDevice @see GraphicsConfiguration @version 1.42 0251 12/0203/0001
Returns an array containing the names of all font families available in thisClass GraphicsEnvironment, String[] getAvailableFontFamilyNames(Locale)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 theFont
object more flexibility in choosing its own best match among multiple fonts in the same font family. @return an array ofString
containing names of font families.@see #getAllFonts @see java.awt.Font @see java.awt.Font#getFamily @since 1.2
Returns an array containing the localized names of all font families available in thisClass GraphicsEnvironment, GraphicsDevice getDefaultScreenDevice()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 theFont
object more flexibility in choosing its own best match among multiple fonts in the same font family. Ifl
isnull
this method returns an array containing all font family names available in thisGraphicsEnvironment
. @param l a Locale object that represents a particular geographical political or cultural region @return an array ofString
objects containing names of font families specific to the specifiedLocale
.@see #getAllFonts @see java.awt.Font @see java.awt.Font#getFamily @since 1.2
Returns the default screenClass GraphicsEnvironment, GraphicsDevice[] getScreenDevices()GraphicsDevice
. @return theGraphicsDevice
that represents the default screen device. @exception HeadlessException if isHeadless() returns true @see isHeadless
Returns an array of all of the screenGraphicsDevice
objects. @return an array containing all theGraphicsDevice
objects that represent screen devices. @exception HeadlessException if isHeadless() returns true @see isHeadless
TheClass GridBagConstraints, int RELATIVEGridBagConstraints
class specifies constraints for components that are laid out using theGridBagLayout
class. @version 1.26 0229 12/0203/0001 @author Doug Stein @see java.awt.GridBagLayout @since JDK1.0
Class GridBagConstraints, int REMAINDERSpecifySpecifies 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 anchorSpecifySpecifies that this component is the last component in its column or row.
This field is used when the component is smaller than its display area. It determines where within the display area to place the component.Class GridBagConstraints, int gridheightPossibleThere 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
andNORTHWEST
. The relative values are:PAGE_START
PAGE_END
LINE_START
LINE_END
FIRST_LINE_START
FIRST_LINE_END
LAST_LINE_START
andLAST_LINE_END
. The default value isCENTER
. @serial @see #clone() @see java.awt.ComponentOrientation
Specifies the number of cells in a column for the component's display area.Class GridBagConstraints, int gridwidthUse
REMAINDER
to specify that the component be the last one in its column. UseRELATIVE
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
Specifies the number of cells in a row for the component's display area.Class GridBagConstraints, int gridxUse
REMAINDER
to specify that the component be the last one in its row. UseRELATIVE
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
Specifies the cellClass GridBagConstraints, int gridyatcontaining theleftleading edge of the component's display area where theleftmostfirst cell in a row hasgridx=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 valueRELATIVE
specifies that the component be placedjust to the rightimmediatelyoffollowing 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
Specifies the cell at the top of the component's display area where the topmost cell hasClass GridBagConstraints, double weightxgridy=0
. The valueRELATIVE
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
Specifies how to distribute extra horizontal space.Class GridBagConstraints, double weightyThe 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
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
TheClass GridBagLayout, GridBagLayoutInfo GetLayoutInfo(Container, int)GridBagLayout
class is a flexible layout manager that aligns components vertically and horizontally without requiring that the components be of the same size. EachGridBagLayout
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 GridBagConstraintsthatThe constraints object specifies where a component's display area should be located on the grid and how the componentis laid outshould be positioned within its display area. InHowadditionato its constraints object theGridBagLayout
objectalso considers each component's minimum and preferred sizes in order toplacesdetermine asetcomponent's size.The overall
orientation ofcomponentsthe grid depends on theGridBagConstraintscontainer'sobjectComponentOrientationassociatedproperty.with eachFor horizontalcomponentleft-to-rightand onorientations grid coordinate (0 0) is in theminimum 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 thepreferreduppersizeright corner of thecomponents'container with x increasing to the left andcontainersy 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 aGridBagConstraints
object by setting one or more of its instance variables:
- {@link GridBagConstraints#gridx} GridBagConstraints#gridy
- Specifies the cell
atcontaining theupperleadingleftcorner of the component's display area where theupper-left-mostcell at the origin of the grid has addressgridx = 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. UseGridBagConstraints.RELATIVE
(the default value) to specify that the component bejustplacedjustimmediatelytofollowing (along theright ofx axis(forgridx
)orjust belowthe y(axis forgridy
) 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 (forgridheight
) in the component's display area. The default value is 1. UseGridBagConstraints.REMAINDER
to specify that the component be the last one in its row (forgridwidth
) or column (forgridheight
). UseGridBagConstraints.RELATIVE
to specify that the component be the next to last one in its row (forgridwidth
) or column (forgridheight
).- {@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) andGridBagConstraints.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_STARTGridBagConstraints.
NORTHEASTPAGE_ENDGridBagConstraints.
EASTLINE_STARTGridBagConstraints.
SOUTHEASTLINE_ENDGridBagConstraints.
SOUTHFIRST_LINE_STARTGridBagConstraints.
SOUTHWESTFIRST_LINE_ENDGridBagConstraints.
WESTLAST_LINE_STARTandGridBagConstraints.
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) theGridBagLayout
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 associatedGridBagConstraints
object set toGridBagConstraints.BOTH
. In addition the components have the following non-default constraints:
- Button1 Button2 Button3:
weightx = 1.0
- Button4:
weightx = 1.0
gridwidth = GridBagConstraints.REMAINDER
- Button5:
gridwidth = GridBagConstraints.REMAINDER
- Button6:
gridwidth = GridBagConstraints.RELATIVE
- Button7:
gridwidth = GridBagConstraints.REMAINDER
- Button8:
gridheight = 2
weighty = 1.0
- Button9 Button 10:
gridwidth = GridBagConstraints.REMAINDER
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, void addLayoutComponent(Component, Object)Print the layoutThis method isconstraints. Usefulsupplied fordebuggingbackwards compatability only; new code should call getLayoutInfo() instead. @see getLayoutInfo
Adds the specified component to the layout using the specifiedClass GridBagLayout, void addLayoutComponent(String, Component)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 ifconstraints
is not aGridBagConstraint
Adds the specified component with the specified name to the layout. @param name the name of the componentClass GridBagLayout, GridBagConstraints getConstraints(Component).@param comp the component to be added.
Gets the constraints for the specified component. A copy of the actualClass GridBagLayout, int[][] getLayoutDimensions()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.
Determines column widths and row heights for the layout grid.Class GridBagLayout, Point getLayoutOrigin()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
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.Class GridBagLayout, Point location(int, int)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
Determines which cell in the layout grid contains the point specified byClass GridBagLayout, GridBagConstraints lookupConstraints(Component)(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 ifx
lies to the left of the layoutandfor 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 ifx
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 ify
lies above the layout and as the number of rows ify
lies below the layout. The orientation of a container is determined by itsComponentOrientation
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
Retrieves the constraints for the specified component. The return value is not a copy but is the actualClass GridBagLayout, void setConstraints(Component, GridBagConstraints)GridBagConstraints
object used by the layout mechanism. @param comp the component to be queried @return the contraints for the specifiedcomponentcomponen.
Sets the constraints for the specified component in this layout. @param comp the component to be modifiedClass GridBagLayout, double[] columnWeights.@param constraints the constraints to be applied.
This field holds the overrides to the column weights. If this field is non-Class GridBagLayout, int[] columnWidthsnull
the values are applied to the gridbag after all of the columns weights have been calculated. IfcolumnWeights[i]
> weight for column i then column i is assigned the weight incolumnWeights[i]
. IfcolumnWeights
has more elements than the number of columns the excess elements are ignored - they do not cause more columns to be created. @serial
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 comptableThis 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 layoutInfoThis field holdsClass GridBagLayout, int[] rowHeightsthathe layout information for the gridbag. The information in this field is based on the most recent validation of the gridbag. IflayoutInfo
isnull
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)
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. IfClass GridBagLayout, double[] rowWeightsrowHeights
has more elements than the number of rows rowa are added to the gridbag to match the number of elements inrowHeights
. @serial @see #getLayoutDimensions()
This field holds the overrides to the row weights. If this field is non-null the values are applied to the gridbag after all of the rows weights have been calculated. IfrowWeights[i]
> weight for row i then row i is assigned the weight inrowWeights[i]
. IfrowWeights
has more elements than the number of rows the excess elements are ignored - they do not cause more rows to be created. @serial
TheClass GridLayout, constructor GridLayout(int, int, int, int)GridLayout
class is a layout manager that lays out a container's components in a rectangular grid.The container is divided into equal-sized rectangles and one component is placed in each rectangle.For example the following is an applet that lays out six buttons into three rows and two columns:
import java.awt.*; import java.applet.Applet; public class ButtonGrid extends Applet { public void init() { setLayout(new GridLayout(3 2)); add(new Button("1")); add(new Button("2")); add(new Button("3")); add(new Button("4")); add(new Button("5")); add(new Button("6")); } }
ItIf the container'sComponentOrientation
property is horizontal and left-to-right the above example produces thefollowingoutput shown in Figure 1. If the container'sComponentOrientation
property is horizontal and right-to-left the example produces the output:shown in Figure 2.
Figure 1: Horizontal Left-to-Right Figure 2: Horizontal Right-to-Left When both the number of rows and the number of columns have been set to non-zero values either by a constructor or by the setRows and setColumns methods the number of columns specified is ignored. Instead the number of columns is determined from the specified number or rows and the total number of components in the layout. So for example if three rows and two columns have been specified and nine components are added to the layout
thenthey will be displayed as three rows of three columns. Specifying the number of columns affects the layout only when the number of rows is set to zero. @version 1.28 0231 12/0203/0001 @author Arthur van Hoff @since JDK1.0
Creates a grid layout with the specified number of rows and columns. All components in the layout are given equal size.Class GridLayout, void addLayoutComponent(String, Component)In addition the horizontal and vertical gaps are set to the specified values. Horizontal gaps are placed at the left and right edges and between each of the columns. Vertical gaps are placed at the top and bottom edges and between each of the rows.
One but not both of
rows
andcols
can be zero which means that any number of objects can be placed in a row or in a column.All
GridLayout
constructors defer to this one. @param rows the rows with the value zero meaning any number of rows.@param cols the columns with the value zero meaning any number of columns.@param hgap the horizontal gap.@param vgap the vertical gap.@exception IllegalArgumentException if the value of bothrows
orandcols
isinvalid.set to zero
Adds the specified component with the specified name to the layout. @param name the name of the componentClass GridLayout, int getColumns().@param comp the component to be added.
Gets the number of columns in this layout. @return the number of columns in this layoutClass GridLayout, int getHgap().@since JDK1.1
Gets the horizontal gap between components. @return the horizontal gap between componentsClass GridLayout, int getRows().@since JDK1.1
Gets the number of rows in this layout. @return the number of rows in this layoutClass GridLayout, int getVgap().@since JDK1.1
Gets the vertical gap between components. @return the vertical gap between componentsClass GridLayout, void layoutContainer(Container).@since JDK1.1
Lays out the specified container using this layout.Class GridLayout, Dimension minimumLayoutSize(Container)This method reshapes the components in the specified target container in order to satisfy the constraints of the
GridLayout
object.The grid layout manager determines the size of individual components by dividing the free space in the container into equal-sized portions according to the number of rows and columns in the layout. The container's free space equals the container's size minus any insets and any specified horizontal or vertical gap. All components in a grid layout are given the same size. @param target the container in which to do the layout
.@see java.awt.Container @see java.awt.Container#doLayout
Determines the minimum size of the container argument using this grid layout.Class GridLayout, Dimension preferredLayoutSize(Container)The minimum width of a grid layout is the largest minimum width of any of the widths in the container times the number of columns plus the horizontal padding times the number of columns plus one plus the left and right insets of the target container.
The minimum height of a grid layout is the largest minimum height of any of the heights in the container times the number of rows plus the vertical padding times the number of rows plus one plus the top and bottom insets of the target container. @param target the container in which to do the layout
.@return the minimum dimensions needed to lay out the subcomponents of the specified container.@see java.awt.GridLayout#preferredLayoutSize @see java.awt.Container#doLayout
Determines the preferred size of the container argument using this grid layout.Class GridLayout, void removeLayoutComponent(Component)The preferred width of a grid layout is the largest preferred width of any of the widths in the container times the number of columns plus the horizontal padding times the number of columns plus one plus the left and right insets of the target container.
The preferred height of a grid layout is the largest preferred height of any of the heights in the container times the number of rows plus the vertical padding times the number of rows plus one plus the top and bottom insets of the target container. @param target the container in which to do the layout
.@return the preferred dimensions to lay out the subcomponents of the specified container.@see java.awt.GridLayout#minimumLayoutSize @see java.awt.Container#getPreferredSize()
Removes the specified component from the layout. @param comp the component to be removedClass GridLayout, void setColumns(int).
Sets the number of columns in this layout to the specified value. Setting the number of columns has no affect on the layout if the number of rows specified by a constructor or by the setRows method is non-zero. In that case the number of columns displayed in the layout is determined by the total number of components and the number of rows specified. @param cols the number of columns in this layoutClass GridLayout, void setHgap(int).@exception IllegalArgumentException if the value of bothrows
andcols
is set to zero.@since JDK1.1
Sets the horizontal gap between components to the specified value. @param hgap the horizontal gap between componentsClass GridLayout, void setRows(int).@since JDK1.1
Sets the number of rows in this layout to the specified value. @param rows the number of rows in this layoutClass GridLayout, void setVgap(int).@exception IllegalArgumentException if the value of bothrows
andcols
is set to zero.@since JDK1.1
Sets the vertical gap between components to the specified value. @param vgap the vertical gap between componentsClass GridLayout, String toString().@since JDK1.1
Returns the string representation of this grid layout's values. @return a string representation of this grid layout.
Signals that an AWT component is not in an appropriate state for the requested operation. @version 1.9 0210 12/0203/0001 @author Jonni Kanerva
The abstract classImage
is the superclass of all classes that represent graphical images. The image must be obtained in a platform-specific manner. @version 1.31 0232 12/0203/0001 @author Sami Shaio @author Arthur van Hoff @since JDK1.0
AnInsets
object is a representation of the borders of a container. It specifies the space that a container must leave at each of its edges. The space can be a border a blank space or a title. @version 1.25 0227 12/0203/0001 @author Arthur van Hoff @author Sami Shaio @see java.awt.LayoutManager @see java.awt.Container @since JDK1.0
The interface for objects which contain a set of items for which zero or more can be selected. @version 1.Class ItemSelectable, void addItemListener(ItemListener)11 0214 12/0203/0001 @author Amy Fowler
Class ItemSelectable, Object[] getSelectedObjects()AddAdds a listener torecievereceive item events when the state of an itemchangesis changed by the user. Item events are not sent when an item's state is set programmatically. Ifl
isnull
no exception is thrown and no action is performed. @param l the listener torecievereceive events @see ItemEvent
Returns the selected items or null
if no items are selected.
Class ItemSelectable, void removeItemListener(ItemListener)Removes an item listener. Ifl
isnull
no exception is thrown and no action is performed. @param l the listener being removed @see ItemEvent
A set of attributes which control a print job.Instances of this class control the number of copies default selection destination print dialog file and printer names page ranges multiple document handling (including collation) and multi-page imposition (such as duplex) of every print job which uses the instance. Attribute names are compliant with the Internet Printing Protocol (IPP) 1.1 where possible. Attribute values are partially compliant where possible.
To use a method which takes an inner class type pass a reference to one of the constant fields of the inner class. Client code cannot create new instances of the inner class types because none of those classes has a public constructor. For example to set the print dialog type to the cross-platform pure Java print dialog use the following code:
import java.awt.JobAttributes; public class PureJavaPrintDialogExample { public void setPureJavaPrintDialog(JobAttributes jobAttributes) { jobAttributes.setDialog(JobAttributes.DialogType.COMMON); } }Every IPP attribute which supports an attributeName-default value has a corresponding
setattributeNameToDefault
method. Default value fields are not provided. @version 1.4 026 12/0203/0001 @author David Mendenhall
The DefaultSelectionType
instance to use for specifying that all pages of the job should be printed.
Class JobAttributes.DefaultSelectionType, DefaultSelectionType RANGEThe DefaultSelectionType
instance to use for specifying that a range of pages of the job should be printed.
Class JobAttributes.DefaultSelectionType, DefaultSelectionType SELECTIONThe DefaultSelectionType
instance to use for specifying that the current selection should be printed.
The DestinationType
instance to use for specifying print to file.
Class JobAttributes.DestinationType, DestinationType PRINTERThe DestinationType
instance to use for specifying print to printer.
The DialogType
instance to use for specifying the cross-platform pure Java print dialog.
Class JobAttributes.DialogType, DialogType NATIVEThe DialogType
instance to use for specifying the platform's native print dialog.
Class JobAttributes.DialogType, DialogType NONEThe DialogType
instance to use for specifying no print dialog.
The MultipleDocumentHandlingType
instance to use for specifying that the job should be divided into separate collated documents.
Class JobAttributes.MultipleDocumentHandlingType, MultipleDocumentHandlingType SEPARATE_DOCUMENTS_UNCOLLATED_COPIESThe MultipleDocumentHandlingType
instance to use for specifying that the job should be divided into separate uncollated documents.
The SidesType
instance to use for specifying that consecutive job pages should be printed upon the same side of consecutive media sheets.
Class JobAttributes.SidesType, SidesType TWO_SIDED_LONG_EDGEThe SidesType
instance to use for specifying that consecutive job pages should be printed upon front and back sides of consecutive media sheets such that the orientation of each pair of pages on the medium would be correct for the reader as if for binding on the long edge.
Class JobAttributes.SidesType, SidesType TWO_SIDED_SHORT_EDGEThe SidesType
instance to use for specifying that consecutive job pages should be printed upon front and back sides of consecutive media sheets such that the orientation of each pair of pages on the medium would be correct for the reader as if for binding on the short edge.
Constructs aClass JobAttributes, constructor JobAttributes(JobAttributes)JobAttributes
instance with default values for every attribute. The dialog defaults toDialogType.NATIVE
. Min page defaults to1
. Max page defaults toInteger.MAX_VALUE
. Destination defaults toDestinationType.PRINTER
. Selection defaults toDefaultSelectionType.ALL
. Number of copies defaults to1
. Multiple document handling defaults toMultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES
. Sides defaults toSidesType.ONE_SIDED
. File name defaults tonull
.
Constructs aClass JobAttributes, constructor JobAttributes(int, DefaultSelectionType, DestinationType, DialogType, String, int, int, MultipleDocumentHandlingType, int[][], String, SidesType)JobAttributes
instance which is a copy of the suppliedJobAttributes
. @param obj theJobAttributes
to copy.
Constructs aClass JobAttributes, Object clone()JobAttributes
instance with the specified values for every attribute. @param copies an integer greater than 0.@param defaultSelectionDefaultSelectionType.ALL
DefaultSelectionType.RANGE
orDefaultSelectionType.SELECTION
@param destination.DesintationType.FILE
orDesintationType.PRINTER
@param dialog.DialogType.COMMON
DialogType.NATIVE
orDialogType.NONE
@param fileName the possibly.null
file name.@param maxPage an integer greater than zero and greater than or equal to minPage.@param minPage an integer greater than zero and less than or equal to maxPage.@param multipleDocumentHandlingMultipleDocumentHandlingType.SEPARATE_DOCUMENTS_COLLATED_COPIES
orMultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES
@param pageRanges an array of integer arrays of.2two elements. An; an array is interpreted as a range spanning all pages including and between the specified pages.;Rangesranges must be in ascending order and must not overlap.;Specifiedspecified page numbers cannot be less than minPage nor greater than maxPage.;Forfor example:(new int[][] { new int[] { 1 3 } new int[] { 5 5 } new int[] { 15 19 } })
specifies pages 1 2 3 5 15 16 17 18 and 19. Note that (new int[][] { new int[] { 1 1 } new int[] { 1 2 } }
) is an invalid set of page ranges because the two ranges overlap.@param printer the possiblynull
printer name.@param sidesSidesType.ONE_SIDED
SidesType.TWO_SIDED_LONG_EDGE
orSidesType.TWO_SIDED_SHORT_EDGE
@throws IllegalArgumentException if one or more of the above conditions is violated..
Creates and returns a copy of thisClass JobAttributes, DefaultSelectionType getDefaultSelection()JobAttributes
. @return the newly created copy. It; it is safe to cast this Object into aJobAttributes
.
Specifies whether for jobs using these attributes the application should print all pages the range specified by the return value ofClass JobAttributes, DestinationType getDestination()getPageRanges
or the current selection. This attribute is updated to the value chosen by the user. @return DefaultSelectionType.ALL DefaultSelectionType.RANGE or DefaultSelectionType.SELECTION.
Specifies whether output will be to a printer or a file for jobs using these attributes. This attribute is updated to the value chosen by the user. @return DesintationType.FILE or DesintationType.PRINTERClass JobAttributes, DialogType getDialog().
Returns whether for jobs using these attributes the user should see a print dialog in which to modify the print settings and which type of print dialog should be displayed. DialogType.COMMON denotes a cross- platform pure Java print dialog. DialogType.NATIVE denotes the platform's native print dialog. If a platform does not support a native print dialog the pure Java print dialog is displayed instead. DialogType.NONE specifies no print dialog (i.e. background printing). This attribute cannot be modified by and is not subject to any limitations of the implementation or the target printer. @returnClass JobAttributes, String getFileName()DialogType.COMMON
DialogType.NATIVE
orDialogType.NONE
.
Specifies the file name for the output file for jobs using these attributes. This attribute is updated to the value chosen by the user. @return the possiblyClass JobAttributes, void set(JobAttributes)null
file name.
Sets all of the attributes of thisClass JobAttributes, void setCopies(int)JobAttributes
to the same values as the attributes of obj. @param obj theJobAttributes
to copy.
Specifies the number of copies the application should render for jobs using these attributes. Not specifying this attribute is equivalent to specifyingClass JobAttributes, void setDefaultSelection(DefaultSelectionType)1
. @param copies an integer greater than 0.@throws IllegalArgumentException ifcopies
is less than or equal to 0.
Specifies whether for jobs using these attributes the application should print all pages the range specified by the return value ofClass JobAttributes, void setMaxPage(int)getPageRanges
or the current selection. Not specifying this attribute is equivalent to specifying DefaultSelectionType.ALL. @param defaultSelection DefaultSelectionType.ALL DefaultSelectionType.RANGE or DefaultSelectionType.SELECTION. @throws IllegalArgumentException if defaultSelection isnull
.
Specifies the maximum value the user can specify as the last page to be printed for jobs using these attributes. Not specifying this attribute is equivalent to specifyingInteger.MAX_VALUE
. @param maxPage an integer greater than zero and greater than or equal to minPage.@throws IllegalArgumentException if one or more of the above conditions is violated.
AClass Label, constructor Label()Label
object is a component for placing text in a container. A label displays a single line of read-only text. The text can be changed by the application but a user cannot edit it directly.For example the code . . .
setLayout(new FlowLayout(FlowLayout.CENTER 10 10)); add(new Label("Hi There ")); add(new Label("Another Label"));
produces the following label:
@version 1.
47 0452 12/0603/0001 @author Sami Shaio @since JDK1.0
Constructs an empty label. The text of the label is the empty string ""
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless
Class Label, constructor Label(String)Constructs a new label with the specified string of text left justified. @param text the string that the label presents. A null
value will be accepted without causing a NullPointerException to be thrown. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless
Class Label, constructor Label(String, int)Constructs a new label that presents the specified string of text with the specified alignment. Possible values forClass Label, String paramString()alignment
areLabel.LEFT
Label.RIGHT
andLabel.CENTER
. @param text the string that the label presents. Anull
value will be accepted without causing a NullPointerException to be thrown. @param alignment the alignment value. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless
Returnsthe parametera string representing the state of thislabelLabel
. Thisstringmethod isusefulintended 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 benull
. @return the parameter string of this label.
Defines the interface for classes that know how toClass LayoutManager, void addLayoutComponent(String, Component)layoutlayContainersoutContainer
s. @see Container @version 1.21 0223 12/0203/0001 @author Sami Shaio @author Arthur van Hoff
Class LayoutManager, void layoutContainer(Container)AddsIf thespecifiedlayout manager uses a per-componentwithstring adds thespecifiedcomponentnamecomp
to the layout associating it with the string specified byname
. @param name thecomponentstringnameto be associated with the component @param comp the component to be added
Lays out theClass LayoutManager, Dimension minimumLayoutSize(Container)container in thespecifiedpanelcontainer. @param parent thecomponent which needscontainer to be laid out
Calculates the minimum size dimensions for the specifiedClass LayoutManager, Dimension preferredLayoutSize(Container)panelcontainer given the componentsin the specified parentitcontainercontains. @param parent the component to be laid out @see #preferredLayoutSize
Calculates the preferred size dimensions for the specifiedpanelcontainer given the componentsin the specified parentitcontainercontains. @param parent thecomponentcontainer to be laid out @see #minimumLayoutSize
Defines an interface for classes that know how to layout Containers based on a layout constraints object. This interface extends the LayoutManager interface to deal with layouts explicitly in terms of constraint objects that specify how and where components should be added to the layout.Class LayoutManager2, Dimension maximumLayoutSize(Container)This minimal extension to LayoutManager is intended for tool providers who wish to the creation of constraint-based layouts. It does not yet provide full general support for custom constraint-based layout managers. @see LayoutManager @see Container @version 1.
10 0212 12/0203/0001 @author Jonni Kanerva
ReturnsCalculates the maximum sizeofdimensionsthisforcomponent.the@seespecifiedjava.awtcontainer given the components it contains.Component#getMinimumSize()@see java.awt.Component#getPreferredSize()getMaximumSize @see LayoutManager
TheList
component presents the user with a scrolling list of text items. The list can be set up so that the user can choose either one item or multiple items.For example the code . . .
List lst = new List(4 false); lst.add("Mercury"); lst.add("Venus"); lst.add("Earth"); lst.add("JavaSoft"); lst.add("Mars"); lst.add("Jupiter"); lst.add("Saturn"); lst.add("Uranus"); lst.add("Neptune"); lst.add("Pluto"); cnt.add(lst);
where
cnt
is a container produces the following scrolling list:
![]()
Clicking on an item that isn't selected selects it. Clicking on an item that is already selected deselects it. In the preceding example only one item from the scrolling list can be selected at a time since the second argument when creating the new scrolling list is
false
. Selecting an item causes any other selected item to be automatically deselected.Note that the list in the example shown was created with four visible rows. Once the list has been created the number of visible rows cannot be changed. A default
List
is created with four rows so thatlst = new List()
is equivalent tolist = new List(4 false)
.Beginning with Java 1.1 the Abstract Window Toolkit sends the
List
object all mouse keyboard and focus events that occur over it. (The old AWT event model is being maintained only for backwards compatibility and its use is discouraged.)When an item is selected or deselected by the user AWT sends an instance of
ItemEvent
to the list. When the user double-clicks on an item in a scrolling list AWT sends an instance ofActionEvent
to the list following the item event. AWT also generates an action event when the user presses the return key while an item in the list is selected.If an application wants to perform some action based on an item in this list being selected or activated by the user it should implement
ItemListener
orActionListener
as appropriate and register the new listener to receive events from this list.For multiple-selection scrolling lists it is considered a better user interface to use an external gesture (such as clicking on a button) to trigger the action. @version 1.
78 0491 12/0603/0001 @author Sami Shaio @see java.awt.event.ItemEvent @see java.awt.event.ItemListener @see java.awt.event.ActionEvent @see java.awt.event.ActionListener @since JDK1.0
Returns theClass List.AccessibleAWTList.AccessibleAWTListChild, boolean isFocusTraversable()Accessible
child if one exists contained at the local coordinatePoint
. @param pThethe point relative to the coordinate system of this object.@return theAccessible
if it exists at the specified location; otherwisenull
Returns whether this object can accept focus or not. Objects that can accept focus will also have theAccessibleState.FOCUSABLE
state set in theirAccessibleStateSet
. @return true if object can accept focus; otherwise false @see AccessibleContext#getAccessibleStateSet @see AccessibleState#FOCUSABLE @see AccessibleState#FOCUSED @see AccessibleStateSet
Creates a new scrolling list. By default there are four visible lines and multiple selections are not allowed. Note that this is a convenience method for List(0 false)
. Also note that the number of visible lines in the list cannot be changed after it has been created. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless
Class List, constructor List(int)Creates a new scrolling list initialized with the specified number of visible lines. By default multiple selections are not allowed. Note that this is a convenience method for List(rows false)
. Also note that the number of visible rows in the list cannot be changed after it has been created. @param rows the number of items to show. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless @since JDK1.1
Class List, constructor List(int, boolean)Creates a new scrolling list initialized to display the specified number of rows. Note that if zero rows are specified then the list will be created with a default of four rows. Also note that the number of visible rows in the list cannot be changed after it has been created. If the value ofClass List, void add(String)multipleMode
istrue
then the user can select multiple items from the list. If it isfalse
only one item at a time can be selected. @param rows the number of items to show. @param multipleMode iftrue
then multiple selections are allowed; otherwise only one item can be selected at a time. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless
Adds the specified item to the end of scrolling list. @param item the item to be addedClass List, void add(String, int).@since JDK1.1
Adds the specified item to the the scrolling list at the position indicated by the index. The index is zero-based. If the value of the index is less than zero or if the value of the index is greater than or equal to the number of items in the list then the item is added to the end of the list. @param item the item to be addedClass List, void addActionListener(ActionListener). If; if this parameter isnull
then the item is treated as an empty string""
.@param index the position at which to add the item.@since JDK1.1
Adds the specified action listener to receive action events from this list. Action events occur when a user double-clicks on a list item. If listenerClass List, void addItemListener(ItemListener)l is
null
no exception is thrown and no action is performed. @param l the action listener.@seejava.awt.event.ActionEvent#removeActionListener @see #getActionListeners @see java.awt.event.ActionListenerActionEvent @see java.awt.List#removeActionListenerevent.ActionListener @since JDK1.1
Adds the specified item listener to receive item events from this list. Item events are sent in response to user input but not in response to calls toClass List, void deselect(int)select
ordeselect
. If listenerl is
null
no exception is thrown and no action is performed. @param l the item listener.@seejava.awt.event.ItemEvent#removeItemListener @see #getItemListeners @see #select @see #deselect @see java.awt.event.ItemListenerItemEvent @see java.awt.List#removeItemListenerevent.ItemListener @since JDK1.1
Deselects the item at the specified index.Class List, AccessibleContext getAccessibleContext()If the item at the specified index is not selected or if the index is out of range then the operation is ignored. @param index the position of the item to deselect
.@seejava.awt.List#select @seejava.awt.List#getSelectedItem @seejava.awt.List#isIndexSelected
Gets theClass List, String getItem(int)AccessibleContext
associated with thisList
. For lists theAccessibleContext
takes the form of anAccessibleAWTList
. A newAccessibleAWTList
instance is created if necessary. @return anAccessibleAWTList
that serves as theAccessibleContext
of thisList
Gets the item associated with the specified index. @return an item that is associated with the specified indexClass List, int getItemCount().@param index the position of the item.@seejava.awt.List#getItemCount
Gets the number of items in the list. @return the number of items in the listClass List, String[] getItems().@seejava.awt.List#getItem @since JDK1.1
Gets the items in the list. @return a string array containing items of the listClass List, EventListener[] getListeners(Class).@seejava.awt.List#select @seejava.awt.List#deselect @seejava.awt.List#isIndexSelected @since JDK1.1
Class List, Dimension getMinimumSize()ReturnReturns an array of all thelistenersobjectsthat were addedcurrently registered astoFooListener
sthe Listupon thiswithList
.addXXXListener()FooListener
swhere XXX isare registered using thenameaddFooListener
ofmethod. You can specify thelistenerType
argument.For example to get all ofwith a class literal such astheFooListener.class
.ItemListener(s)Forforexampletheyou cangivenquery aList
l
onefor its itemwouldlisteners with thewritefollowing code:If no suchItemListener[] ils = (ItemListener[])(l.getListeners(ItemListener.class));listenerlisteners existlist exists thenthis method returns an empty arrayis returned. @param listenerTypeTypethe type of listeners requested; this parameter should specify an interface that descends fromjava.util.EventListener
@returnallan array oftheall objects registered asFooListener
s on this list or an empty array if no such listenersof the specifiedhave been addedtype@exceptionsupported byClassCastException ifthislistenerType
listdoesn't specify a class or interface that implementsjava.util.EventListener
@see #getItemListeners @since 1.3
Determines the minimum size of this scrolling list. @return the minimum dimensions needed to display this scrolling listClass List, Dimension getMinimumSize(int).@see java.awt.Component#getMinimumSize() @since JDK1.1
Gets the minumum dimensions for a list with the specified number of rows. @param rows number of rows in the listClass List, Dimension getPreferredSize().@return the minimum dimensions for displaying this scrolling list given that the specified number of rows must be visible.@see java.awt.Component#getMinimumSize @since JDK1.1
Gets the preferred size of this scrolling list. @return the preferred dimensions for displaying this scrolling listClass List, Dimension getPreferredSize(int).@see java.awt.Component#getPreferredSize @since JDK1.1
Gets the preferred dimensions for a list with the specified number of rows. @param rows number of rows in the listClass List, int getRows().@return the preferred dimensions for displaying this scrolling list given that the specified number of rows must be visible.@see java.awt.Component#getPreferredSize @since JDK1.1
Class List, int getSelectedIndex()GetGets the number of visible lines in this list. Note that once theList
has been created this number will never change. @return the number of visible lines in this scrolling list.
Gets the index of the selected item on the list @return the index of the selected item orClass List, int[] getSelectedIndexes()-1
if no item is selected or if more that one item is selected.@seejava.awt.List#select @seejava.awt.List#deselect @seejava.awt.List#isIndexSelected
Gets the selected indexes on the list. @return an array of the selected indexes of this scrolling listClass List, String getSelectedItem(). If; if no items are selected a zero-length array is returned.@seejava.awt.List#select @seejava.awt.List#deselect @seejava.awt.List#isIndexSelected
Class List, String[] getSelectedItems()GetGets the selected item on this scrolling list. @return the selected item on the list ornull
if no item is selected.@seejava.awt.List#select @seejava.awt.List#deselect @seejava.awt.List#isIndexSelected
Class List, Object[] getSelectedObjects()GetGets the selected items on this scrolling list. @return an array of the selected items on this scrolling list.@seejava.awt.List#select @seejava.awt.List#deselect @seejava.awt.List#isIndexSelected
Returns the selected items on the list in an array ofClass List, int getVisibleIndex()Objectsobjects. @see ItemSelectable
Gets the index of the item that was last made visible by the methodClass List, boolean isIndexSelected(int)makeVisible
. @return the index of the item that was last made visible.@seejava.awt.List#makeVisible
Determines if the specified item in this scrolling list is selected. @param index the item to be checkedClass List, boolean isMultipleMode().@returntrue
if the specified item has been selected;false
otherwise.@seejava.awt.List#select @seejava.awt.List#deselect @since JDK1.1
Determines whether this list allows multiple selections. @returnClass List, void makeVisible(int)true
if this list allows multiple selections; otherwisefalse
.@seejava.awt.List#setMultipleMode @since JDK1.1
Makes the item at the specified index visible. @param index the position of the itemClass List, String paramString().@seejava.awt.List#getVisibleIndex
Returns the parameter string representing the state of this scrolling list. This string is useful for debugging. @return the parameter string of this scrolling listClass List, void processActionEvent(ActionEvent).
Processes action events occurring on this component by dispatching them to any registeredClass List, void processEvent(AWTEvent)ActionListener
objects.This method is not called unless action events are enabled for this component. Action events are enabled when one of the following occurs:
- An
ActionListener
object is registered viaaddActionListener
.- Action events are enabled via
enableEvents
.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.ActionEvent @see java.awt.event.ActionListener @seejava.awt.List#addActionListener @see java.awt.Component#enableEvents @since JDK1.1
Processes events on this scrolling list. If an event is an instance ofClass List, void processItemEvent(ItemEvent)ItemEvent
it invokes theprocessItemEvent
method. Else if the event is an instance ofActionEvent
it invokesprocessActionEvent
. If the event is not an item event or an action event it invokesprocessEvent
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.event.ItemEvent @seejava.awt.List#processActionEvent @seejava.awt.List#processItemEvent @since JDK1.1
Processes item events occurring on this list by dispatching them to any registeredClass List, void remove(String)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:
- An
ItemListener
object is registered viaaddItemListener
.- Item events are enabled via
enableEvents
.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 @seejava.awt.List#addItemListener @see java.awt.Component#enableEvents @since JDK1.1
Removes the first occurrence of an item from the list. @param item the item to remove from the listClass List, void remove(int).@exception IllegalArgumentException if the item doesn't exist in the list.@since JDK1.1
Remove the item at the specified position from this scrolling list. @param position the index of the item to deleteClass List, void removeActionListener(ActionListener).@seejava.awt.List#add(String int) @since JDK1.1 @exception ArrayIndexOutOfBoundsException if theposition
is less than 0 or greater thangetItemCount()-1
Removes the specified action listener so that it no longer receives action events from this list. Action events occur when a user double-clicks on a list item. If listenerClass List, void removeItemListener(ItemListener)l is
null
no exception is thrown and no action is performed. @param l the action listener.@seejava.awt.event.ActionEvent#addActionListener @see #getActionListeners @see java.awt.event.ActionListenerActionEvent @see java.awt.List#addActionListenerevent.ActionListener @since JDK1.1
Removes the specified item listener so that it no longer receives item events from this list. If listenerClass List, void replaceItem(String, int)l is
null
no exception is thrown and no action is performed. @param l the item listener.@seejava.awt.event.ItemEvent#addItemListener @see #getItemListeners @see java.awt.event.ItemListenerItemEvent @see java.awt.List#addItemListenerevent.ItemListener @since JDK1.1
Replaces the item at the specified index in the scrolling list with the new string. @param newValue a new string to replace an existing itemClass List, void select(int).@param index the position of the item to replace.@exception ArrayIndexOutOfBoundsException ifindex
is out of range
Selects the item at the specified index in the scrolling list.Class List, void setMultipleMode(boolean)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 anItemEvent
is by user interaction. @param index the position of the item to select.@seejava.awt.List#getSelectedItem @seejava.awt.List#deselect @seejava.awt.List#isIndexSelected
Sets the flag that determines whether this list allows multiple selections. @param b iftrue
then multiple selections are allowed; otherwise only one item from the list can be selected at once.@seejava.awt.List#isMultipleMode @since JDK1.1
TheClass MediaTracker, constructor MediaTracker(Component)MediaTracker
class is a utility class to track the status of a number of media objects. Media objects could include audio clips as well as images though currently only images are supported.To use a media tracker create an instance of
MediaTracker
and call itsaddImage
method for each image to be tracked. In addition each image can be assigned a unique identifier. This identifier controls the priority order in which the images are fetched. It can also be used to identify unique subsets of the images that can be waited on independently. Images with a lower ID are loaded in preference to those with a higher ID number.Here is an example:
import java.applet.Applet; import java.awt.Color; import java.awt.Image; import java.awt.Graphics; import java.awt.MediaTracker; public class ImageBlaster extends Applet implements Runnable { MediaTracker tracker; Image bg; Image anim[] = new Image[5]; int index; Thread animator; // Get the images for the background (id == 0) // and the animation frames (id == 1) // and add them to the MediaTracker public void init() { tracker = new MediaTracker(this); bg = getImage(getDocumentBase() "images/background.gif"); tracker.addImage(bg 0); for (int i = 0; i <5; i++) { anim[i] = getImage(getDocumentBase() "images/anim"+i+".gif"); tracker.addImage(anim[i] 1); } } // Start the animation thread. public void start() { animator = new Thread(this); animator.start(); } // Stop the animation thread. public void stop() { animator = null; } // Run the animation thread. // First wait for the background image to fully load // and paint. Then wait for all of the animation // frames to finish loading. Finally loop and // increment the animation frame index. public void run() { try { tracker.waitForID(0); tracker.waitForID(1); } catch (InterruptedException e) { return; } Thread me = Thread.currentThread(); while (animator == me) { try { Thread.sleep(100); } catch (InterruptedException e) { break; } synchronized (this) { index++; if (index >= anim.length) { index = 0; } } repaint(); } } // The background image fills the frame so we // don't need to clear the applet on repaints. // Just call the paint method. public void update(Graphics g) { paint(g); } // Paint a large red rectangle if there are any errors // loading the images. Otherwise always paint the // background so that it appears incrementally as it // is loading. Finally only paint the current animation // frame if all of the frames (id == 1) are done loading // so that we don't get partial animations. public void paint(Graphics g) { if ((tracker.statusAll(false) & MediaTracker.ERRORED) = 0) { g.setColor(Color.red); g.fillRect(0 0 size().width size().height); return; } g.drawImage(bg 0 0 this); if (tracker.statusID(1 false) == MediaTracker.COMPLETE) { g.drawImage(anim[index] 10 10 this); } } }
@version 1.
34 0737 12/1403/0001 @author Jim Graham @since JDK1.0
Creates a media tracker to track images for a given component. @param comp the component on which the images will eventually be drawnClass MediaTracker, void addImage(Image, int).
Adds an image to the list of images being tracked by this media tracker. The image will eventually be rendered at its default (unscaled) size. @param image the image to be trackedClass MediaTracker, void addImage(Image, int, int, int).@param id an identifier used to track this image.
Adds a scaled image to the list of images being tracked by this media tracker. The image will eventually be rendered at the indicated width and height. @param image the image to be trackedClass MediaTracker, boolean checkAll().@param id an identifier that can be used to track this image.@param w the width at which the image is rendered.@param h the height at which the image is rendered.
Checks to see if all images being tracked by this media tracker have finished loading.Class MediaTracker, boolean checkAll(boolean)This method does not start loading the images if they are not already loading.
If there is an error while loading or scaling an image then that image is considered to have finished loading. Use the
isErrorAny
orisErrorID
methods to check for errors. @returntrue
if all images have finished loading have been aborted or have encountered an error;false
otherwise.@see java.awt.MediaTracker#checkAll(boolean) @see java.awt.MediaTracker#checkID @see java.awt.MediaTracker#isErrorAny @see java.awt.MediaTracker#isErrorID
Checks to see if all images being tracked by this media tracker have finished loading.Class MediaTracker, boolean checkID(int)If the value of the
load
flag istrue
then this method starts loading any images that are not yet being loaded.If there is an error while loading or scaling an image that image is considered to have finished loading. Use the
isErrorAny
andisErrorID
methods to check for errors. @param load iftrue
start loading any images that are not yet being loaded.@returntrue
if all images have finished loading have been aborted or have encountered an error;false
otherwise.@see java.awt.MediaTracker#checkID @see java.awt.MediaTracker#checkAll() @see java.awt.MediaTracker#isErrorAny() @see java.awt.MediaTracker#isErrorID(int)
Checks to see if all images tracked by this media tracker that are tagged with the specified identifier have finished loading.Class MediaTracker, boolean checkID(int, boolean)This method does not start loading the images if they are not already loading.
If there is an error while loading or scaling an image then that image is considered to have finished loading. Use the
isErrorAny
orisErrorID
methods to check for errors. @param id the identifier of the images to check.@returntrue
if all images have finished loading have been aborted or have encountered an error;false
otherwise.@see java.awt.MediaTracker#checkID(int boolean) @see java.awt.MediaTracker#checkAll() @see java.awt.MediaTracker#isErrorAny() @see java.awt.MediaTracker#isErrorID(int)
Checks to see if all images tracked by this media tracker that are tagged with the specified identifier have finished loading.Class MediaTracker, Object[] getErrorsAny()If the value of the
load
flag istrue
then this method starts loading any images that are not yet being loaded.If there is an error while loading or scaling an image then that image is considered to have finished loading. Use the
isErrorAny
orisErrorID
methods to check for errors. @param id the identifier of the images to check.@param load iftrue
start loading any images that are not yet being loaded.@returntrue
if all images have finished loading have been aborted or have encountered an error;false
otherwise.@see java.awt.MediaTracker#checkID(int boolean) @see java.awt.MediaTracker#checkAll() @see java.awt.MediaTracker#isErrorAny() @see java.awt.MediaTracker#isErrorID(int)
Returns a list of all media that have encountered an error. @return an array of media objects tracked by this media tracker that have encountered an error orClass MediaTracker, Object[] getErrorsID(int)null
if there are none with errors.@see java.awt.MediaTracker#isErrorAny @see java.awt.MediaTracker#getErrorsID
Returns a list of media with the specified ID that have encountered an error. @param id the identifier of the images to checkClass MediaTracker, boolean isErrorAny().@return an array of media objects tracked by this media tracker with the specified identifier that have encountered an error ornull
if there are none with errors.@see java.awt.MediaTracker#isErrorID @see java.awt.MediaTracker#isErrorAny @see java.awt.MediaTracker#getErrorsAny
Checks the error status of all of the images. @returnClass MediaTracker, boolean isErrorID(int)true
if any of the images tracked by this media tracker had an error during loading;false
otherwise.@see java.awt.MediaTracker#isErrorID @see java.awt.MediaTracker#getErrorsAny
Checks the error status of all of the images tracked by this media tracker with the specified identifier. @param id the identifier of the images to checkClass MediaTracker, void removeImage(Image).@returntrue
if any of the images with the specified identifier had an error during loading;false
otherwise.@see java.awt.MediaTracker#isErrorAny @see java.awt.MediaTracker#getErrorsID
Class MediaTracker, void removeImage(Image, int)RemoveRemoves the specified image from this media tracker. All instances of the specified image are removed regardless of scale or ID. @param image the image to be removed @see java.awt.MediaTracker#removeImage(java.awt.Image int) @see java.awt.MediaTracker#removeImage(java.awt.Image int int int) @since JDK1.1
Class MediaTracker, void removeImage(Image, int, int, int)RemoveRemoves the specified image from the specified tracking ID of this media tracker. All instances ofImage
being tracked under the specified ID are removed regardless of scale. @param image the image to be removed.@param id the tracking ID frrom which to remove the image.@see java.awt.MediaTracker#removeImage(java.awt.Image) @see java.awt.MediaTracker#removeImage(java.awt.Image int int int) @since JDK1.1
Class MediaTracker, int statusAll(boolean)RemoveRemoves the specified image with the specified width height and ID from this media tracker. Only the specified instance (with any duplicates) is removed. @param image the image to be removed @param id the tracking ID from which to remove the image.@param width the width to remove (-1 for unscaled).@param height the height to remove (-1 for unscaled).@see java.awt.MediaTracker#removeImage(java.awt.Image) @see java.awt.MediaTracker#removeImage(java.awt.Image int) @since JDK1.1
Calculates and returns the bitwise inclusive OR of the status of all media that are tracked by this media tracker.Class MediaTracker, int statusID(int, boolean)Possible flags defined by the
MediaTracker
class areLOADING
ABORTED
ERRORED
andCOMPLETE
. An image that hasn't started loading has zero as its status.If the value of
load
istrue
then this method starts loading any images that are not yet being loaded. @param load iftrue
start loading any images that are not yet being loaded.@return the bitwise inclusive OR of the status of all of the media being tracked.@see java.awt.MediaTracker#statusID(int boolean) @see java.awt.MediaTracker#LOADING @see java.awt.MediaTracker#ABORTED @see java.awt.MediaTracker#ERRORED @see java.awt.MediaTracker#COMPLETE
Calculates and returns the bitwise inclusive OR of the status of all media with the specified identifier that are tracked by this media tracker.Class MediaTracker, void waitForAll()Possible flags defined by the
MediaTracker
class areLOADING
ABORTED
ERRORED
andCOMPLETE
. An image that hasn't started loading has zero as its status.If the value of
load
istrue
then this method starts loading any images that are not yet being loaded. @param id the identifier of the images to check.@param load iftrue
start loading any images that are not yet being loaded.@return the bitwise inclusive OR of the status of all of the media with the specified identifier that are being tracked.@see java.awt.MediaTracker#statusAll(boolean) @see java.awt.MediaTracker#LOADING @see java.awt.MediaTracker#ABORTED @see java.awt.MediaTracker#ERRORED @see java.awt.MediaTracker#COMPLETE
Starts loading all images tracked by this media tracker. This method waits until all the images being tracked have finished loading.Class MediaTracker, boolean waitForAll(long)If there is an error while loading or scaling an image then that image is considered to have finished loading. Use the
isErrorAny
orisErrorID
methods to check for errors. @see java.awt.MediaTracker#waitForID(int) @see java.awt.MediaTracker#waitForAll(long) @see java.awt.MediaTracker#isErrorAny @see java.awt.MediaTracker#isErrorID @exception InterruptedException if another thread has interrupted this thread.
Starts loading all images tracked by this media tracker. This method waits until all the images being tracked have finished loading or until the length of time specified in milliseconds by theClass MediaTracker, void waitForID(int)ms
argument has passed.If there is an error while loading or scaling an image then that image is considered to have finished loading. Use the
isErrorAny
orisErrorID
methods to check for errors. @param ms the number of milliseconds to wait for the loading to complete.@returntrue
if all images were successfully loaded;false
otherwise.@see java.awt.MediaTracker#waitForID(int) @see java.awt.MediaTracker#waitForAll(long) @see java.awt.MediaTracker#isErrorAny @see java.awt.MediaTracker#isErrorID @exception InterruptedException if another thread has interrupted this thread.
Starts loading all images tracked by this media tracker with the specified identifier. This method waits until all the images with the specified identifier have finished loading.Class MediaTracker, boolean waitForID(int, long)If there is an error while loading or scaling an image then that image is considered to have finished loading. Use the
isErrorAny
andisErrorID
methods to check for errors. @param id the identifier of the images to check.@see java.awt.MediaTracker#waitForAll @see java.awt.MediaTracker#isErrorAny() @see java.awt.MediaTracker#isErrorID(int) @exception InterruptedException if another thread has interrupted this thread.
Starts loading all images tracked by this media tracker with the specified identifier. This method waits until all the images with the specified identifier have finished loading or until the length of time specified in milliseconds by theClass MediaTracker, int ABORTEDms
argument has passed.If there is an error while loading or scaling an image then that image is considered to have finished loading. Use the
statusID
isErrorID
andisErrorAny
methods to check for errors. @param id the identifier of the images to check.@param ms the length of time in milliseconds to wait for the loading to complete.@see java.awt.MediaTracker#waitForAll @see java.awt.MediaTracker#waitForID(int) @see java.awt.MediaTracker#statusID @see java.awt.MediaTracker#isErrorAny() @see java.awt.MediaTracker#isErrorID(int) @exception InterruptedException if another thread has interrupted this thread.
Flag indicating that the downloading ofClass MediaTracker, int ERROREDsomemedia was aborted. @see java.awt.MediaTracker#statusAll @see java.awt.MediaTracker#statusID
Flag indicating that the downloading ofClass MediaTracker, int LOADINGsomemedia encountered an error. @see java.awt.MediaTracker#statusAll @see java.awt.MediaTracker#statusID
Flag indicatingsomethat media is currently being loaded. @see java.awt.MediaTracker#statusAll @see java.awt.MediaTracker#statusID
AClass Menu, constructor Menu()Menu
object is a pull-down menu component that is deployed from a menu bar.A menu can optionally be a tear-off menu. A tear-off menu can be opened and dragged away from its parent menu bar or menu. It remains on the screen after the mouse button has been released. The mechanism for tearing off a menu is platform dependent since the look and feel of the tear-off menu is determined by its peer. On platforms that do not support tear-off menus the tear-off property is ignored.
Each item in a menu must belong to the
MenuItem
class. It can be an instance ofMenuItem
a submenu (an instance ofMenu
) or a check box (an instance ofCheckboxMenuItem
). @version 1.61 0468 12/0603/0001 @author Sami Shaio @see java.awt.MenuItem @see java.awt.CheckboxMenuItem @since JDK1.0
Constructs a new menu with an empty label. This menu is not a tear-off menu. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless @since JDK1.1Class Menu, constructor Menu(String)
Constructs a new menu with the specified label. This menu is not a tear-off menu. @param label the menu's label in the menu bar or in another menu of which this menu is a submenu. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadlessClass Menu, constructor Menu(String, boolean)
Constructs a new menu with the specified label indicating whether the menu can be torn off.Class Menu, MenuItem add(MenuItem)Tear-off functionality may not be supported by all implementations of AWT. If a particular implementation doesn't support tear-off menus this value is silently ignored. @param label the menu's label in the menu bar or in another menu of which this menu is a submenu. @param tearOff if
true
the menu is a tear-off menu. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless @since JDK1.0.
Adds the specified menu item to this menu. If the menu item has been part of another menuClass Menu, void add(String)removeremoves it from that menu. @param mi the menu item to be added.@return the menu item added.@see java.awt.Menu#insert(java.lang.String int) @see java.awt.Menu#insert(java.awt.MenuItem int)
Adds an item with the specified label to this menu. @param label the text on the itemClass Menu, void insert(MenuItem, int).@see java.awt.Menu#insert(java.lang.String int) @see java.awt.Menu#insert(java.awt.MenuItem int)
Inserts a menu item into this menu at the specified position. @param menuitem the menu item to be inserted. @param index the position at which the menu item should be inserted. @see java.awt.Menu#add(java.lang.String) @see java.awt.Menu#add(java.awt.MenuItem) @exception IllegalArgumentException if the value ofClass Menu, void insert(String, int)index
is less than zero.@since JDK1.1
Inserts a menu item with the specified label into this menu at the specified position. This is a convenience method forClass Menu, String paramString()insert(menuItem index)
. @param label the text on the item.@param index the position at which the menu item should be inserted.@see java.awt.Menu#add(java.lang.String) @see java.awt.Menu#add(java.awt.MenuItem) @exception IllegalArgumentException if the value ofindex
is less than zero @since JDK1.1
GetsReturnsthe parametera string representing the state of thismenuMenu
. Thisstringmethod isusefulintended to be used only for debugging.@sincepurposes and the content and format of the returned string may vary betweenJDK1implementations.0nuThe returned string may be empty but may not benull
. @return the parameter string of this menu
TheClass MenuBar, constructor MenuBar()MenuBar
class encapsulates the platform's concept of a menu bar bound to a frame. In order to associate the menu bar with aFrame
object call the frame'ssetMenuBar
method.<-- target for cross references --> This is what a menu bar might look like:
![]()
A menu bar handles keyboard shortcuts for menu items passing them along to its child menus. (Keyboard shortcuts which are optional provide the user with an alternative to the mouse for invoking a menu item and the action that is associated with it.) Each menu item can maintain an instance of
MenuShortcut
. TheMenuBar
class defines several methods MenuBar#shortcuts and MenuBar#getShortcutMenuItem that retrieve information about the shortcuts a given menu bar is managing. @version 1.54 0460 12/0603/0001 @author Sami Shaio @see java.awt.Frame @see java.awt.Frame#setMenuBar(java.awt.MenuBar) @see java.awt.Menu @see java.awt.MenuItem @see java.awt.MenuShortcut @since JDK1.0
Creates a new menu bar. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless
The abstract classMenuComponent
is the superclass of all menu-related components. In this respect the classMenuComponent
is analogous to the abstract superclassComponent
for AWT components.Menu components receive and process AWT events just as components do through the method
processEvent
. @version 1.56 0465 12/0603/0001 @author Arthur van Hoff @since JDK1.0
Inner class of MenuComponent used to provide default support for accessibility. This class is not meant to be used directly by application developers but is instead meant only to be subclassed by menu component developers. The class used to obtain the accessible role for this object.
Class MenuComponent.AccessibleAWTMenuComponent, void addAccessibleSelection(int)Adds the specified Accessible
child of the object to the object's selection. If the object supports multiple selections the specified child is added to any existing selection otherwise it replaces any existing selection in the object. If the specified child is already selected this method has no effect. @param i the zero-based index of the child @see AccessibleContext#getAccessibleChild
Class MenuComponent.AccessibleAWTMenuComponent, 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 theClass MenuComponent.AccessibleAWTMenuComponent, Accessible getAccessibleAt(Point)Point
relative to the coordinate system of the object @return true if object containsPoint
; otherwise false
Returns theClass MenuComponent.AccessibleAWTMenuComponent, Accessible getAccessibleChild(int)Accessible
child if one exists contained at the local coordinatePoint
. If there is noAccessible
childnull
is returned. @param pThethe point defining the top-left corner of theAccessible
given in the coordinate space of the object's parent.@return theAccessible
if it exists at the specified location; elsenull
Class MenuComponent.AccessibleAWTMenuComponent, int getAccessibleChildrenCount()ReturnReturns the nthAccessible
child of the object. @param i zero-based index of child @return the nth Accessible child of the object
Returns the number of accessible children in the object. If all of the children of this object implementClass MenuComponent.AccessibleAWTMenuComponent, AccessibleComponent getAccessibleComponent()Accessible
thanthen this method should return the number of children of this object. @return the number of accessible children in the object.
Class MenuComponent.AccessibleAWTMenuComponent, String getAccessibleDescription()GetGets theAccessibleComponent
associated with this object if one exists. Otherwise returnnull
. @return the component
Class MenuComponent.AccessibleAWTMenuComponent, int getAccessibleIndexInParent()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 benull
if this object does not have a description @see AccessibleContext#setAccessibleDescription
Class MenuComponent.AccessibleAWTMenuComponent, String getAccessibleName()GetGets the index of this object in its accessible parent. @return the index of this object in its parent; -1 if this object does not have an accessible parent.@see #getAccessibleParent
Class MenuComponent.AccessibleAWTMenuComponent, Accessible getAccessibleParent()GetGets the accessible name of this object. This should almost never returnjava.awt.MenuComponent.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 AccessibleContext#setAccessibleName
Class MenuComponent.AccessibleAWTMenuComponent, AccessibleRole getAccessibleRole()GetGets theAccessible
parent of this object. If the parent of this object implementsAccessible
this method should simply returngetParent
. @return the()Accessible
parent of this object -- can benull
if this object does not have anAccessible
parent
Class MenuComponent.AccessibleAWTMenuComponent, AccessibleSelection getAccessibleSelection()GetGets the role of this object. @return an instance ofAccessibleRole
describing the role of the object @see AccessibleRole
Class MenuComponent.AccessibleAWTMenuComponent, Accessible getAccessibleSelection(int)GetGets theAccessibleSelection
associated with this object which allows itsAccessible
children to be selected. @returnAccessibleSelection
if supported by object; else returnnull
@see AccessibleSelection
Returns anClass MenuComponent.AccessibleAWTMenuComponent, int getAccessibleSelectionCount()Accessible
representing the specified selected child in the object. If there isn't a selection or there are fewer children selected than the integer passed in the return value will benull
.Note that the index represents the i-th selected child which is different from the i-th child. @param i the zero-based index of selected children @return the i-th selected child @see #getAccessibleSelectionCount
Returns the number ofClass MenuComponent.AccessibleAWTMenuComponent, AccessibleStateSet getAccessibleStateSet()Accessible
children currently selected. If no children are selected the return value will be 0. @return the number of items currently selected.
Class MenuComponent.AccessibleAWTMenuComponent, Color getBackground()GetGets the state of this object. @return an instance ofAccessibleStateSet
containing the current state set of the object @see AccessibleState
Class MenuComponent.AccessibleAWTMenuComponent, Rectangle getBounds()GetGets the background color of this object. @return the background color if supported of the object; otherwisenull
Gets the bounds of this object in the form of aClass MenuComponent.AccessibleAWTMenuComponent, Cursor getCursor()Rectangle
object. The bounds specify this object's width height and location relative to its parent. @returnAa rectangle indicating this component's bounds;null
if this object is not on the screen.
Class MenuComponent.AccessibleAWTMenuComponent, Font getFont()GetGets theCursor
of this object. @return theCursorCurso
if supported of the object; otherwisenull
Class MenuComponent.AccessibleAWTMenuComponent, FontMetrics getFontMetrics(Font)GetGets theFont
of this object. @return theFont
if supported for the object; otherwisenull
Class MenuComponent.AccessibleAWTMenuComponent, Color getForeground()GetGets theFontMetrics
of this object. @param f theFont
@return the FontMetrics if supported the object; otherwisenull
@see #getFont
Class MenuComponent.AccessibleAWTMenuComponent, Locale getLocale()GetGets the foreground color of this object. @return the foreground color if supported of the object; otherwisenull
Class MenuComponent.AccessibleAWTMenuComponent, Point getLocation()ReturnReturns the locale of this object. @return the locale of this object
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. @returnClass MenuComponent.AccessibleAWTMenuComponent, Point getLocationOnScreen()Anan instance ofPoint
representing the top-left corner of the object's bounds in the coordinate space of the screen;null
if this object or its parent are not on the screen
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 MenuComponent.AccessibleAWTMenuComponent, Dimension getSize()Returns the size of this object in the form of aClass MenuComponent.AccessibleAWTMenuComponent, boolean isAccessibleChildSelected(int)Dimension
object. The height field of theDimension
object contains this object's height and the width field of theDimension
object contains this object's width. @returnAaDimension
object that indicates the size of this component;null
if this object is not on the screen
Determines if the current child of this object is selected. @return true if the current child of this object is selected; else falseClass MenuComponent.AccessibleAWTMenuComponent, boolean isEnabled().@param i the zero-based index of the child in thisAccessible
object.@see AccessibleContext#getAccessibleChild
Class MenuComponent.AccessibleAWTMenuComponent, boolean isShowing()DetermineDetermines if the object is enabled. @return true if object is enabled; otherwise false
Class MenuComponent.AccessibleAWTMenuComponent, boolean isVisible()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 MenuComponent.AccessibleAWTMenuComponent, void setBackground(Color)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 useisShowing
. @return true if object is visible; otherwise false()
Class MenuComponent.AccessibleAWTMenuComponent, void setBounds(Rectangle)SetSets the background color of this object. (For transparency seeisOpaque
.) @param c the newColor
for the background @see Component#isOpaque
Sets the bounds of this object in the form of aClass MenuComponent.AccessibleAWTMenuComponent, void setCursor(Cursor)Rectangle
object. The bounds specify this object's width height and location relative to its parent. @paramAa rectangle indicating this component's bounds
Class MenuComponent.AccessibleAWTMenuComponent, void setEnabled(boolean)SetSets theCursor
of this object. @param c the newCursor
for the object
Class MenuComponent.AccessibleAWTMenuComponent, void setFont(Font)SetSets the enabled state of the object. @param b if true enables this object; otherwise disables it
Class MenuComponent.AccessibleAWTMenuComponent, void setForeground(Color)SetSets theFont
of this object. @param f the newFont
for the object
Class MenuComponent.AccessibleAWTMenuComponent, void setSize(Dimension)SetSets the foreground color of this object. @param c the newColor
for the foreground
Resizes this object.Class MenuComponent.AccessibleAWTMenuComponent, void setVisible(boolean).@param d -ThethedimensionDimension
specifying the new size of the object.
SetSets the visible state of the object. @param b if true shows this object; otherwise hides it
Class MenuComponent, AccessibleContext getAccessibleContext()Constructor forCreates aMenuComponent
. @exception HeadlessException ifGraphicsEnvironment.isHeadless
returnstrue
@see java.awt.GraphicsEnvironment#isHeadless
Class MenuComponent, Font getFont()GetGets theAccessibleContext
associated with thisMenuComponent
. The method implemented by this base class returnsnull
. Classes that extendMenuComponent
should implement this method to return theAccessibleContext
associated with the subclass. @return theAccessibleContext
of thisMenuComponent
Gets the font used for this menu component. @return the font used in this menu component if there is one;Class MenuComponent, String getName()null
otherwise.@see java.awt.MenuComponent#setFont
Gets the name of the menu component. @return the name of the menu componentClass MenuComponent, MenuContainer getParent().@see java.awt.MenuComponent#setName(java.lang.String) @since JDK1.1
Returns the parent container for this menu component. @return the menu component containing this menu component orClass MenuComponent, Object getTreeLock()null
if this menu component is the outermost component the menu bar itself.
Gets this component's locking object (the object that owns the thread sychronization monitor) for AWT component-tree and layout operations. @returnClass MenuComponent, String paramString()Thisthis component's locking object.
ReturnsClass MenuComponent, void processEvent(AWTEvent)the parametera string representing the state of thismenu componentMenuComponent
. Thisstringmethod isusefulintended 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 benull
. @return the parameter string of this menu component.
Processes events occurring on this menu component.Class MenuComponent, void setFont(Font)Note that if the event parameter is
null
the behavior is unspecified and may result in an exception. @param e the event @since JDK1.1
Sets the font to be used for this menu component to the specified font. This font is also used by all subcomponents of this menu component unless those subcomponents specify a different font.Class MenuComponent, void setName(String)Some look and feels may not support setting the font of a menu component; in this case calling
setFont
will have no effect. @param f the font to be set.@see java.awt.MenuComponent#getFont
Sets the name of the component to the specified string. @param name the name of the menu componentClass MenuComponent, String toString().@see java.awt.MenuComponent#getName @since JDK1.1
Returns a representation of this menu component as a string. @return a string representation of this menu component.
The super class of all menu related containers. @version 1.12 0213 12/0203/0001 @author Arthur van Hoff
All items in a menu must belong to the classClass MenuItem, constructor MenuItem()MenuItem
or one of its subclasses.The default
MenuItem
object embodies a simple labeled menu item.This picture of a menu bar shows five menu items:
![]()
The first two items are simple menu items labeled"Basic"
and"Simple"
. Following these two items is a separator which is itself a menu item created with the label"-"
. Next is an instance ofCheckboxMenuItem
labeled"Check"
. The final menu item is a submenu labeled"More Examples"
and this submenu is an instance ofMenu
.When a menu item is selected AWT sends an action event to the menu item. Since the event is an instance of
ActionEvent
theprocessEvent
method examines the event and passes it along toprocessActionEvent
. The latter method redirects the event to anyActionListener
objects that have registered an interest in action events generated by this menu item.Note that the subclass
Menu
overrides this behavior and does not send any event to the frame until one of its subitems is selected. @version 1.68 0479 12/0603/0001 @author Sami Shaio
Constructs a new MenuItem with an empty label and no keyboard shortcut. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless @since JDK1.1Class MenuItem, constructor MenuItem(String)
Constructs a new MenuItem with the specified label and no keyboard shortcut. Note that use of "-" in a label is reserved to indicate a separator between menu items. By default all menu items except for separators are enabled. @param label the label for this menu item. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless @since JDK1.0Class MenuItem, constructor MenuItem(String, MenuShortcut)
Create a menu item with an associated keyboard shortcut. Note that use of "-" in a label is reserved to indicate a separator between menu items. By default all menu items except for separators are enabled. @param label the label for this menu item. @param s the instance of MenuShortcut
associated with this menu item. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless @since JDK1.1
Class MenuItem, void addActionListener(ActionListener)Adds the specified action listener to receive action events from this menu item. If l is null no exception is thrown and no action is performed. @param l the action listener. @seeClass MenuItem, void disableEvents(long)java.awt.event.ActionEvent#removeActionListener @see #getActionListeners @see java.awt.event.ActionListenerActionEvent @see java.awt.MenuItem#removeActionListenerevent.ActionListener @since JDK1.1
Disables event delivery to this menu item for events defined by the specified event mask parameter. @param eventsToDisable the event mask defining the event typesClass MenuItem, void enableEvents(long).@see java.awt.MenuItem#processEvent @see java.awt.MenuItem#enableEvents @see java.awt.Component#disableEvents @since JDK1.1
Enables event delivery to this menu item for events to be defined by the specified event mask parameterClass MenuItem, EventListener[] getListeners(Class)Since event types are automatically enabled when a listener for that type is added to the menu item this method only needs to be invoked by subclasses of
MenuItem
which desire to have the specified event types delivered toprocessEvent
regardless of whether a listener is registered. @param eventsToEnable the event mask defining the event types.@see java.awt.MenuItem#processEvent @see java.awt.MenuItem#disableEvents @see java.awt.Component#enableEvents @since JDK1.1
Class MenuItem, String paramString()ReturnReturns an array of all thelistenersobjectsthat were addedcurrently registered astoFooListener
sthe MenuItemupon thiswithMenuItem
.addXXXListener()FooListener
swhere XXX isare registered using thenameaddFooListener
ofmethod. You can specify thelistenerType
argument.For example to get all ofwith a class literal such astheFooListener.class
.ActionListener(s)Forforexampletheyou cangivenquery aMenuItem
m
onefor its actionwouldlisteners with thewritefollowing code:If no suchActionListener[] als = (ActionListener[])(m.getListeners(ActionListener.class));listenerlisteners existlist exists thenthis method returns an empty arrayis returned. @param listenerTypeTypethe type of listeners requested;@returnthisall of theparameter should specifylistenersan interface that descends fromjava.util.EventListener
@return an array ofthe specified typeall objects registeredsupportedasFooListener
sbyon this menu item or an empty array if no such listeners have been added @exception ClassCastException iflistenerType
doesn't specify a class or interface that implementsjava.util.EventListener
@see #getActionListeners @since 1.3
ReturnsClass MenuItem, void processActionEvent(ActionEvent)the parametera string representing the state of thismenu itemMenuItem
. Thisstringmethod isusefulintended 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 benull
. @return the parameter string of this menu item. @since JDK1.0
Processes action events occurring on this menu item by dispatching them to any registeredClass MenuItem, void processEvent(AWTEvent)ActionListener
objects. This method is not called unless action events are enabled for this component. Action events are enabled when one of the following occurs:
- An
ActionListener
object is registered viaaddActionListener
.- Action events are enabled via
enableEvents
.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.ActionEvent @see java.awt.event.ActionListener @see java.awt.MenuItem#enableEvents @since JDK1.1
Processes events on this menu item. If the event is an instance ofClass MenuItem, void removeActionListener(ActionListener)ActionEvent
it invokesprocessActionEvent
another method defined byMenuItem
.Currently menu items only support action 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.MenuItem#processActionEvent @since JDK1.1
Removes the specified action listener so it no longer receives action events from this menu item. If l is null no exception is thrown and no action is performed. @param l the action listener. @seejava.awt.event.ActionEvent#addActionListener @see #getActionListeners @see java.awt.event.ActionListenerActionEvent @see java.awt.MenuItem#addActionListenerevent.ActionListener @since JDK1.1
Class MenuShortcut, constructor MenuShortcut(int)ATheMenuShortcut
classwhichrepresents a keyboard accelerator for a MenuItem.Menu shortcuts are created using virtual keycodes not characters. For example a menu shortcut for Ctrl-a would be created with code like the following:
MenuShortcut ms = new MenuShortcut(KeyEvent.VK_A false);
@author Thomas Ball @version 1.
18 0221 12/0203/0001 @author ThomassinceBallJDK1.1
Constructs a new MenuShortcut for the specifiedClass MenuShortcut, constructor MenuShortcut(int, boolean)keyvirtual keycode. @param key the raw keycode for this MenuShortcut as would be returned in the keyCode field of a KeyEvent if this key were pressed. @see java.awt.event.KeyEvent
Constructs a new MenuShortcut for the specifiedClass MenuShortcut, boolean equals(MenuShortcut)keyvirtual keycode. @param key the raw keycode for this MenuShortcut as would be returned in the keyCode field of a KeyEvent if this key were pressed. @param useShiftModifier indicates whether this MenuShortcut is invoked with the SHIFT key down. @see java.awt.event.KeyEvent
Returns whether this MenuShortcut is the same as another: equality is defined to mean that both MenuShortcuts use the same key and both either use or don't use the SHIFT key. @param s the MenuShortcut to compare with this. @returnClass MenuShortcut, boolean equals(Object)true
if this MenuShortcut is the same as anotherfalse
otherwise. @since JDK1.1
Returns whether this MenuShortcut is the same as another: equality is defined to mean that both MenuShortcuts use the same key and both either use or don't use the SHIFT key. @param obj the Object to compare with this. @returnClass MenuShortcut, int getKey()true
if this MenuShortcut is the same as anotherfalse
otherwise. @since 1.2
Class MenuShortcut, int hashCode()ReturnReturns the raw keycode of this MenuShortcut. @return the raw keycode of this MenuShortcut. @see java.awt.event.KeyEvent @since JDK1.1
Returns the hashcode for this MenuShortcut. @return the hashcode for this MenuShortcut. @since 1.2Class MenuShortcut, String toString()
Returns an internationalized description of the MenuShortcut. @return a string representation of this MenuShortcut. @since JDK1.1Class MenuShortcut, boolean usesShiftModifier()
ReturnReturns whether this MenuShortcut must be invoked using the SHIFT key. @returntrue
if this MenuShortcut must be invoked using the SHIFT keyfalse
otherwise. @since JDK1.1
A set of attributes which control the output of a printed page.Instances of this class control the color state paper size (media type) orientation logical origin print quality and resolution of every page which uses the instance. Attribute names are compliant with the Internet Printing Protocol (IPP) 1.1 where possible. Attribute values are partially compliant where possible.
To use a method which takes an inner class type pass a reference to one of the constant fields of the inner class. Client code cannot create new instances of the inner class types because none of those classes has a public constructor. For example to set the color state to monochrome use the following code:
import java.awt.PageAttributes; public class MonochromeExample { public void setMonochrome(PageAttributes pageAttributes) { pageAttributes.setColor(PageAttributes.ColorType.MONOCHROME); } }Every IPP attribute which supports an attributeName-default value has a corresponding
setattributeNameToDefault
method. Default value fields are not provided. @version 1.4 025 12/0203/0001 @author David Mendenhall
ThisClass Paint, PaintContext createContext(ColorModel, Rectangle, Rectangle2D, AffineTransform, RenderingHints)Paint
interface defines how color patterns can be generated for Graphics2D operations. A class implementing thePaint
interface is added to theGraphics2D
context in order to define the color pattern used by thedraw
andfill
methods.Instances of classes implementing
Paint
must be read-only because theGraphics2D
does not clone these objects when they are set as an attribute with thesetPaint
method or when theGraphics2D
object is itself cloned. @see PaintContext @see Color @see GradientPaint @see TexturePaint @see Graphics2D#setPaint @version 1.23 0225 12/0203/0001
Creates and returns a PaintContext used to generate the color pattern. Since the ColorModel argument to createContext is only a hint implementations of Paint should accept a null argument for ColorModel. Note that if the application does not prefer a specific ColorModel the null ColorModel argument will give the Paint implementation full leeway in using the most efficient ColorModel it prefers for its raster processing.Since the API documentation was not specific about this in releases before 1.4 there may be implementations of
@param cm the ColorModel that receives thePaint
that do not accept a nullColorModel
argument. If a developer is writing code which passes a nullColorModel
argument to thecreateContext
method ofPaint
objects from arbitrary sources it would be wise to code defensively by manufacturing a non-nullColorModel
for those objects which throw aNullPointerException
.Paint
data. This is used only as a hint. @param deviceBounds the device space bounding box of the graphics primitive being rendered @param userBounds the user space bounding box of the graphics primitive being rendered @param xform the AffineTransform from user space into device space @param hints the hint that the context object uses to choose between rendering alternatives @return thePaintContext
for generating color patterns @see PaintContext
Panel
is the simplest container class. A panel provides space in which an application can attach any other component including other panels.The default layout manager for a panel is the
FlowLayout
layout manager. @version 1.300412/0603/0001 @author Sami Shaio @see java.awt.FlowLayout @since JDK1.0
A point representing a location in (x y) coordinate space specified in integer precision. @version 1.Class Point, constructor Point(Point)28 0234 12/0903/01 @author Sami Shaio @since JDK1.0
Constructs and initializes a point with the same location as the specifiedClass Point, constructor Point(int, int)Point
object. @param p a point.@since JDK1.1
Constructs and initializes a point at the specified (x y) location in the coordinate space. @param x the x coordinateClass Point, boolean equals(Object).@param y the y coordinate.
Determines whether an instance ofClass Point, Point getLocation()Point2D
is equal to this point. Two instances ofPoint2D
are equal if the values of theirx
andy
member fields representing their position in the coordinate space are the same. @param obj an object to be compared with this point.@returntrue
if the object to be compared is an instance ofand has the same values;
Point2DPointfalse
otherwise.
Returns the location of this point. This method is included for completeness to parallel theClass Point, double getX()getLocation
method ofComponent
. @return a copy of this point at the same location.@see java.awt.Component#getLocation @see java.awt.Point#setLocation(java.awt.Point) @see java.awt.Point#setLocation(int int) @since JDK1.1
Returns the X coordinate of the point in double precision. @return the X coordinate of the point in double precisionClass Point, double getY()
Returns the Y coordinate of the point in double precision. @return the Y coordinate of the point in double precisionClass Point, void move(int, int)
Moves this point to theClass Point, void setLocation(Point)specificedspecified location in the (x y) coordinate plane. This method is identical withsetLocation(int int)
. @param x the x coordinate of the new location.@param y the y coordinate of the new location.@see java.awt.Component#setLocation(int int)
Sets the location of the point to theClass Point, void setLocation(double, double)specificedspecified location. This method is included for completeness to parallel thesetLocation
method ofComponent
. @param p a point the new location for this point.@see java.awt.Component#setLocation(java.awt.Point) @see java.awt.Point#getLocation @since JDK1.1
Sets the location of this point to the specified float coordinates. The float values will be rounded to integer values. Any number smaller thanClass Point, void setLocation(int, int)Integer.MIN_VALUE
will be reset toMIN_VALUE
and any number larger thanInteger.MAX_VALUE
will be reset toMAX_VALUE
. @param x the x coordinate of the new location @param y the y coordinate of the new location @see #getLocation
Changes the point to have theClass Point, String toString()specificedspecified location.This method is included for completeness to parallel the
setLocation
method ofComponent
. Its behavior is identical withmove(int int)
. @param x the x coordinate of the new location.@param y the y coordinate of the new location.@see java.awt.Component#setLocation(int int) @see java.awt.Point#getLocation @see java.awt.Point#move(int int) @since JDK1.1
Returns a string representation of this point and its location in the (x y) coordinate space. 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 beClass Point, void translate(int, int)null
. @return a string representation of this point.
Translates this point at location (x y) byClass Point, int xdx
along the x axis anddy
along the y axis so that it now represents the point (x
+
dx
y
+
dy
). @paramxdx the distance to move this point along the x axis.@paramydy the distance to move this point along the y axis.
The x coordinate. If no x coordinate is set it will default toClass Point, int y'0'. @serial @see #getLocation() @see #move(int int)
The y coordinate. If no y coordinate is set it will default to'0'. @serial @see #getLocation() @see #move(int int)
TheClass Polygon, boolean contains(double, double)Polygon
class encapsulates a description of a closed two-dimensional region within a coordinate space. This region is bounded by an arbitrary number of line segments each of which is one side of the polygon. Internally a polygon comprises of a list of (x y) coordinate pairs where each pair defines a vertex of the polygon and two successive pairs are the endpoints of a line that is a side of the polygon. The first and final pairs of (x y) points are joined by a line segment that closes the polygon. ThisPolygon
is defined with an even-odd winding rule. See WIND_EVEN_ODD for a definition of the even-odd winding rule. This class's hit-testing methods which include thecontains
intersects
andinside
methods use the insideness definition described in the Shape class comments. @version 1.26 07/24/98 @author Sami Shaio @see Shape @author Herb Jellinek @see Shape @since JDK1.0
DeterminesClass Polygon, int npointswhetherif the specified coordinates are inside thisPolygon
. For the definition of insideness see the class comments of Shape @param x y the specified coordinates @returntrue
ifthisthePolygon
contains the specified coordinates;false
otherwise.
The total number of points. The value ofClass Polygon, int[] xpointsnpoints
represents the number of valid points in thisPolygon
and might be less than the number of elements in xpoints or ypoints This value can be NULL. @serial @see #addPoint(int int)
The array of x coordinates. The number of elements in this array might be more than the number of x coordinates in thisClass Polygon, int[] ypointsPolygon
. The extra elements allow new points to be added to thisPolygon
without re-creating this array. The value of npoints is equal to the number of valid points in thisPolygon
. @serial @see #addPoint(int int)
The array of y coordinates. The number of elements in this array might be more than the number of y coordinates in thisPolygon
. The extra elements allow new points to be added to thisPolygon
without re-creating this array. The value ofnpoints
is equal to the number of valid points in thisPolygon
. @serial @see #addPoint(int int)
A class that implements a menu which can be dynamically popped up at a specified position within a component.As the inheritance hierarchy implies a
PopupMenu
can be used anywhere aMenu
can be used. However if you use aPopupMenu
like aMenu
(e.g. you add it to aMenuBar
) then you cannot callshow
on thatPopupMenu
. @version 1.24 0426 12/0603/0001 @author Amy Fowler
Inner class of PopupMenu used to provide default support for accessibility. This class is not meant to be used directly by application developers but is instead meant only to be subclassed by menu component developers.
This class implements accessibility support for the PopupMenuThe class. Itprovides anusedimplementation ofto obtain theJava AccessibilityaccessibleAPIroleappropriate to popup menuforuser-interfacethiselementsobject.
Creates a new popup menu with an empty name. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadlessClass PopupMenu, constructor PopupMenu(String)
Creates a new popup menu with the specified name. @param label a non-null
string specifying the popup menu's label @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless
Class PopupMenu, AccessibleContext getAccessibleContext()Gets theClass PopupMenu, void show(Component, int, int)AccessibleContext
associated with thisPopupMenu
.For popup menus the AccessibleContext takes the form of an AccessibleAWTPopupMenu. A new AccessibleAWTPopupMenu instance is created if necessary.@returnan AccessibleAWTPopupMenu that serves astheAccessibleContext
of thisPopupMenu
Shows the popup menu at the x y position relative to an origin component. The origin component must be contained within the component hierarchy of the popup menu's parent. Both the origin and the parent must be showing on the screen for this method to be valid.If this
PopupMenu
is being used as aMenu
(i.e. it has a non-Component
parent) then you cannot call this method on thePopupMenu
. @param origin the component which defines the coordinate space @param x the x coordinate position to popup the menu @param y the y coordinate position to popup the menu @exception NullPointerException if the parent isnull
@exception IllegalArgumentException if thisPopupMenu
has a non-Component
parent @exception IllegalArgumentException if the origin is not in the parent's heirarchy @exception RuntimeException if the parent is not showing on screen
An abstract class which provides a print graphics context for a page. @version 1.9 0210 12/0203/0001 @author Amy Fowler
An abstract class which initiates and executes a print job. It provides access to a print graphics object which renders to an appropriate print device. @see Toolkit#getPrintJob @version 1.10 0211 12/0203/0001 @author Amy Fowler
AClass Rectangle, constructor Rectangle(Rectangle)Rectangle
specifies an area in a coordinate space that is enclosed by theRectangle
object's top-left point (x y) in the coordinate space its width and its height.A
Rectangle
object'swidth
andheight
arepublic
fields. The constructors that create aRectangle
and the methods that can modify one do not prevent setting a negative value for width or height.A
Rectangle
whose width or height is negative is considered empty. If theRectangle
is empty then theisEmpty
method returnstrue
. No point can be contained by or inside an emptyRectangle
. The values ofwidth
andheight
however are still valid. An emptyRectangle
still has a location in the coordinate space and methods that change its size or location remain valid. The behavior of methods that operate on more than oneRectangle
is undefined if any of the participatingRectangle
objects has a negativewidth
orheight
. These methods includeintersects
intersection
andunion
. @version 1.53 0563 12/2903/01 @author Sami Shaio @since JDK1.0
Constructs a newClass Rectangle, boolean contains(int, int, int, int)Rectangle
initialized to match the values of thespecificedspecifiedRectangle
. @param r theRectangle
from which to copy initial values to a newly constructedRectangle
@since JDK1.1
Checks whether thisClass Rectangle, Rectangle getBounds()Rectangle
entirely contains theRectangle
at the specified location (X Y) with the specified dimensions (W H). @paramxXyY the specified coordinates @param W the width of theRectangle
@param H the height of theRectangle
@returntrue
if theRectangle
specified by (X Y W H) is entirely enclosed inside thisRectangle
;false
otherwise. @since JDK1.1
Gets the boundingClass Rectangle, Point getLocation()Rectangle
of thisRectangle
.This method is included for completeness to parallel the
getBounds
method of Component @return a newRectangle
equal to the boundingRectangle
for thisRectangle
. @see java.awt.Component#getBounds @see #setBounds(Rectangle) @see #setBounds(int int int int) @since JDK1.1
Returns the location of thisClass Rectangle, Dimension getSize()Rectangle
.This method is included for completeness to parallel the
getLocation
method ofComponent
. @return thePoint
that is the top-left corner of thisRectangle
. @see java.awt.Component#getLocation @see #setLocation(Point) @see #setLocation(int int) @since JDK1.1
Gets the size of thisClass Rectangle, boolean inside(int, int)Rectangle
represented by the returnedDimension
.This method is included for completeness to parallel the
getSize
method ofComponent
. @return aDimension
representing the size of thisRectangle
. @see java.awt.Component#getSize @see #setSize(Dimension) @see #setSize(int int) @since JDK1.1
Checks whether or not thisClass Rectangle, Rectangle intersection(Rectangle)Rectangle
contains the point at the specified location (X Y). @param X Y the specified coordinates @returntrue
if the point (X Y) is inside thisRectangle
;false
otherwise. @deprecated As of JDK version 1.1 replaced bycontains(int int)
.
Computes the intersection of thisClass Rectangle, boolean intersects(Rectangle)Rectangle
with the specifiedRectangle
. Returns a newRectangle
that represents the intersection of the two rectangles. If the two rectangles do not intersect the result will be an empty rectangle. @param r the specifiedRectangle
@return the largestRectangle
contained in both the specifiedRectangle
and in thisRectangle
; or if the rectangles do not intersect an empty rectangle.
Determines whether or not thisClass Rectangle, void move(int, int)Rectangle
and the specifiedRectangle
intersect. Two rectangles intersect if their intersection is nonempty. @param r the specifiedRectangle
@returntrue
if the specifiedRectangle
and thisRectangle
insersectintersect;false
otherwise.
Moves thisClass Rectangle, void reshape(int, int, int, int)Rectangle
to the specified location.@param x y the coordinates of the new location
@deprecated As of JDK version 1.1 replaced bysetLocation(int int)
.
Sets the boundingClass Rectangle, void resize(int, int)Rectangle
of thisRectangle
to the specifiedx
y
width
andheight
.@param x y the new coordinates for the top-left corner of this
@deprecated As of JDK version 1.1 replaced byRectangle
@param width the new width for thisRectangle
@param height the new height for thisRectangle
setBounds(int int int int)
.
Sets the size of thisClass Rectangle, void setBounds(Rectangle)Rectangle
to the specified width and height.@param width the new width for this
@deprecated As of JDK version 1.1 replaced byRectangle
@param height the new height for thisRectangle
setSize(int int)
.
Sets the boundingClass Rectangle, void setBounds(int, int, int, int)Rectangle
of thisRectangle
to match the specifiedRectangle
.This method is included for completeness to parallel the
setBounds
method ofComponent
. @param r the specifiedRectangle
@see #getBounds @see java.awt.Component#setBounds(java.awt.Rectangle) @since JDK1.1
Sets the boundingClass Rectangle, void setLocation(Point)Rectangle
of thisRectangle
to the specifiedx
y
width
andheight
.This method is included for completeness to parallel the
setBounds
method ofComponent
. @param x y the new coordinates for the top-left corner of thisRectangle
@param width the new width for thisRectangle
@param height the new height for thisRectangle
@see #getBounds @see java.awt.Component#setBounds(int int int int) @since JDK1.1
Moves thisClass Rectangle, void setLocation(int, int)Rectangle
to the specified location.This method is included for completeness to parallel the
setLocation
method ofComponent
. @param p thePoint
specifying the new location for thisRectangle
@see java.awt.Component#setLocation(java.awt.Point) @see #getLocation @since JDK1.1
Moves thisClass Rectangle, void setRect(double, double, double, double)Rectangle
to the specified location.This method is included for completeness to parallel the
setLocation
method ofComponent
. @param x y the coordinates of the new location @see #getLocation @see java.awt.Component#setLocation(int int) @since JDK1.1
Sets the bounds of thisClass Rectangle, void setSize(Dimension)Rectangle
to the specifiedx
y
width
andheight
. This method is included for completeness to parallel thesetBounds
method ofComponent
. @param x y the coordinates of the upper-left corner of the specified rectangle @param width the new width for theDimension
object @param height the new height for theDimension
object
Sets the size of thisClass Rectangle, void setSize(int, int)Rectangle
to match the specifiedDimension
.This method is included for completeness to parallel the
setSize
method ofComponent
. @param d the new size for theDimension
object @see java.awt.Component#setSize(java.awt.Dimension) @see #getSize @since JDK1.1
Sets the size of thisClass Rectangle, void translate(int, int)Rectangle
to the specified width and height.This method is included for completeness to parallel the
setSize
method ofComponent
. @param width the new width for thisRectangle
@param height the new height for thisRectangle
@see java.awt.Component#setSize(int int) @see #getSize @since JDK1.1
Translates thisRectangle
the indicated distance to the right along the x coordinate axis and downward along the y coordinate axis. @paramdxx the distance to move thisRectangle
along the x axis @paramdyy the distance to move thisRectangle
along the y axis @see java.awt.Rectangle#setLocation(int int) @see java.awt.Rectangle#setLocation(java.awt.Point)
Construct a key using the indicated private key. Each subclass of Key maintains its own unique domain of integer keys. No two objects with the same integer key and of the same specific subclass can be constructed. An exception will be thrown if an attempt is made to construct another object of a given class with the same integer key as a pre-existing instance of that subclass of Key. @param privatekey the specified keyClass RenderingHints.Key, int intKey()
Returns the private integer key that the subclass instantiated this Key with. @return the private integer key that the subclass instantiated this Key with.Class RenderingHints.Key, boolean isCompatibleValue(Object)
Returns true if the specified object is a valid value for this Key. @param val theObject
to test for validity @returntrue
ifval
is valid;false
otherwise.
Copies all of the mappings from the specifiedClass RenderingHints, Key KEY_ALPHA_INTERPOLATIONMap
to thisRenderingHints
. These mappings replace any mappings that thisRenderingHints
had for any of the keys currently in the specifiedMap
. @paramtmmappings to be stored inthethisspecified
RenderingHintsMap.@exceptionClassCastException
class of a key or value in the specifiedMap
prevents it from being stored in thisRenderingHints
. @exceptionIllegalArgumentException
some aspect of a key or value in the specifiedMap
prevents it from being stored in thisRenderingHints
.
Alpha interpolation hint key.Class RenderingHints, Key KEY_ANTIALIASING
Antialiasing hint key.Class RenderingHints, Key KEY_COLOR_RENDERING
Color rendering hint key.Class RenderingHints, Key KEY_DITHERING
Dithering hint key.Class RenderingHints, Key KEY_FRACTIONALMETRICS
Font fractional metrics hint key.Class RenderingHints, Key KEY_INTERPOLATION
Interpolation hint key.Class RenderingHints, Key KEY_RENDERING
Rendering hint key.Class RenderingHints, Key KEY_STROKE_CONTROL
Stroke normalization control hint key.Class RenderingHints, Key KEY_TEXT_ANTIALIASING
Text antialiasing hint key.Class RenderingHints, Object VALUE_ALPHA_INTERPOLATION_DEFAULT
Alpha interpolation hint value -- ALPHA_INTERPOLATION_DEFAULT.Class RenderingHints, Object VALUE_ALPHA_INTERPOLATION_QUALITY
Alpha interpolation hint value -- ALPHA_INTERPOLATION_QUALITY.Class RenderingHints, Object VALUE_ALPHA_INTERPOLATION_SPEED
Alpha interpolation hint value -- ALPHA_INTERPOLATION_SPEED.Class RenderingHints, Object VALUE_ANTIALIAS_OFF
Antialiasing hint values -- rendering is done without antialiasing.Class RenderingHints, Object VALUE_ANTIALIAS_ON
Antialiasing hint values -- rendering is done with antialiasing.Class RenderingHints, Object VALUE_COLOR_RENDER_DEFAULT
Color rendering hint value -- COLOR_RENDER_DEFAULT.Class RenderingHints, Object VALUE_COLOR_RENDER_QUALITY
Color rendering hint value -- COLOR_RENDER_QUALITY.Class RenderingHints, Object VALUE_COLOR_RENDER_SPEED
Color rendering hint value -- COLOR_RENDER_SPEED.Class RenderingHints, Object VALUE_DITHER_DEFAULT
Dithering hint values -- use the platform default for dithering.Class RenderingHints, Object VALUE_DITHER_DISABLE
Dithering hint values -- do not dither when rendering.Class RenderingHints, Object VALUE_DITHER_ENABLE
Dithering hint values -- dither when rendering if needed.Class RenderingHints, Object VALUE_FRACTIONALMETRICS_DEFAULT
Font fractional metrics hint values -- use the platform default for fractional metrics.Class RenderingHints, Object VALUE_FRACTIONALMETRICS_OFF
Font fractional metrics hint values -- fractional metrics disabled.Class RenderingHints, Object VALUE_FRACTIONALMETRICS_ON
Font fractional metrics hint values -- fractional metrics enabled.Class RenderingHints, Object VALUE_INTERPOLATION_BICUBIC
Interpolation hint value -- INTERPOLATION_BICUBIC.Class RenderingHints, Object VALUE_INTERPOLATION_BILINEAR
Interpolation hint value -- INTERPOLATION_BILINEAR.Class RenderingHints, Object VALUE_INTERPOLATION_NEAREST_NEIGHBOR
Interpolation hint value -- INTERPOLATION_NEAREST_NEIGHBOR.Class RenderingHints, Object VALUE_STROKE_DEFAULT
Stroke normalization control hint value -- STROKE_DEFAULT.Class RenderingHints, Object VALUE_STROKE_NORMALIZE
Stroke normalization control hint value -- STROKE_NORMALIZE.Class RenderingHints, Object VALUE_STROKE_PURE
Stroke normalization control hint value -- STROKE_PURE.Class RenderingHints, Object VALUE_TEXT_ANTIALIAS_OFF
Text antialiasing hint value -- text rendering is done without antialiasing.Class RenderingHints, Object VALUE_TEXT_ANTIALIAS_ON
Text antialiasing hint value -- text rendering is done with antialiasing.
This class is used to generate native system input events for the purposes of test automation self-running demos and other applications where control of the mouse and keyboard is needed. The primary purpose of Robot is to facilitate automated testing of Java platform implementations.Class Robot, constructor Robot()Using the class to generate input events differs from posting events to the AWT event queue or AWT components in that the events are generated in the platform's native input queue. For example
Robot.mouseMove
will actually move the mouse cursor instead of just generating mouse move events.Note that some platforms require special privileges or extensions to access low-level input control. If the current platform configuration does not allow input control an
AWTException
will be thrown when trying to construct Robot objects. For example X-Window systems will throw the exception if the XTEST 2.2 standard extension is not supported (or not enabled) by the X server.Applications that use Robot for purposes other than self-testing should handle these error conditions gracefully. @version 1.
13 0220 12/0203/0001 @author Robi Khan @since 1.3
Constructs a Robot object in the coordinate system of the primary screen.Class Robot, constructor Robot(GraphicsDevice)@throws AWTException if the platform configuration does not allow low-level input control. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true @throws SecurityException if
createRobot
permission is not granted @see java.awt.GraphicsEnvironment#isHeadless @see SecurityManager#checkPermission @see AWTPermission
Creates a Robot for the given screen device. Coordinates passed to Robot method calls like mouseMove and createScreenCapture will be interpreted as being in the same coordinate system as the specified screen. Note that depending on the platform configuration multiple screens may either:Class Robot, void delay(int)This constructor is meant for the latter case.
- share the same coordinate system to form a combined virtual screen
- use different coordinate systems to act as independent screens
If screen devices are reconfigured such that the coordinate system is affected the behavior of existing Robot objects is undefined. @param screen A screen GraphicsDevice indicating the coordinate system the Robot will operate in. @throws AWTException if the platform configuration does not allow low-level input control. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true. @throws IllegalArgumentException if
screen
is not a screen GraphicsDevice. @throws SecurityException ifcreateRobot
permission is not granted @see java.awt.GraphicsEnvironment#isHeadless @see GraphicsDevice @see SecurityManager#checkPermission @see AWTPermission
Sleeps for the specified time. To catch anyClass Robot, void keyPress(int)InterruptedException
s that occurThread.sleep()
may be used instead. @param msTimetime to sleep in milliseconds @throws IllegalArgumentExceptionIfifms
is not between 0 and 60 000 milliseconds inclusive @see java.lang.Thread#sleep()
Presses a given key.Class Robot, void keyRelease(int)Key codes that have more than one physical key associated with them (e.g.
KeyEvent.VK_SHIFT
could mean either the left or right shift key) will map to the left key. @param keyCode Key to press (e.g.KeyEvent.VK_A
) @throws IllegalArgumentException ifkeycode
is not a valid key @see java.awt.event.KeyEvent
Releases a given key.Class Robot, void mousePress(int)Key codes that have more than one physical key associated with them (e.g.
KeyEvent.VK_SHIFT
could mean either the left or right shift key) will map to the left key. @param keyCode Key to release (e.g.KeyEvent.VK_A
) @throws IllegalArgumentException ifkeycode
is not a valid key @see java.awt.event.KeyEvent
Presses one or more mouse buttons. @param buttons the Button mask; aClass Robot, void mouseRelease(int)(combination of one or more of these flags:
InputEvent.BUTTON1
/2/3_MASK)InputEvent.BUTTON2_MASK
@throws IllegalArgumentException if the button mask is not a valid combination InputEvent.BUTTON3_MASK
Releases one or more mouse buttons. @param buttons the Button mask; a(combination of one or more of these flags:
InputEvent.BUTTON1
/2/3_MASK)InputEvent.BUTTON2_MASK
@throws IllegalArgumentException if the button mask is not a valid combination InputEvent.BUTTON3_MASK
A container class which implements automatic horizontal and/or vertical scrolling for a single child component. The display policy for the scrollbars can be set to:Class ScrollPane, constructor ScrollPane()
- as needed: scrollbars created and shown only when needed by scrollpane
- always: scrollbars created and always shown by the scrollpane
- never: scrollbars never created or shown by the scrollpane
The state of the horizontal and vertical scrollbars is represented by two
ScrollPaneAdjustable
objects (one for each dimension) which implement theAdjustable
interface. The API provides methods to access those objects such that the attributes on the Adjustable object (such as unitIncrement value etc.) can be manipulated.Certain adjustable properties (minimum maximum blockIncrement and visibleAmount) are set internally by the scrollpane in accordance with the geometry of the scrollpane and its child and these should not be set by programs using the scrollpane.
If the scrollbar display policy is defined as "never" then the scrollpane can still be programmatically scrolled using the setScrollPosition() method and the scrollpane will move and clip the child's contents appropriately. This policy is useful if the program needs to create and manage its own adjustable controls.
The placement of the scrollbars is controlled by platform-specific properties set by the user outside of the program.
The initial size of this container is set to 100x100 but can be reset using setSize().
Scrolling with the wheel on a wheel-equipped mouse is enabled by default. This can be disabled using setWheelScrollingEnabled(). Wheel scrolling can be customized by setting the block and unit increment of the horizontal and vertical Adjustables.
Insets are used to define any space used by scrollbars and any borders created by the scroll pane. getInsets() can be used to get the current value for the insets. If the value of scrollbarsAlwaysVisible is false then the value of the insets will change dynamically depending on whether the scrollbars are currently visible or not. @version 1.
75 0488 12/0603/0001 @author Tom Ball @author Amy Fowler @author Tim Prinzing
Create a new scrollpane container with a scrollbar display policy of "as needed". @throws HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadlessClass ScrollPane, constructor ScrollPane(int)
Create a new scrollpane container. @param scrollbarDisplayPolicy policy for when scrollbars should be shown @throws IllegalArgumentException if the specified scrollbar display policy is invalid @throws HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadlessClass ScrollPane, Adjustable getHAdjustable()
Returns theClass ScrollPane, Point getScrollPosition()AdjustableScrollPaneAdjustable
object which represents the state of the horizontal scrollbar. The declared return type of this method isAdjustable
to maintain backward compatibility. @see java.awt.ScrollPaneAdjustable
Returns the current x y position within the child which is displayed at the 0 0 location of the scrolled panel's view port. This is a convenience method which interfaces with the adjustable objects which represent the state of the scrollbars. @return the coordinate position for the current scroll position @throws NullPointerException if the scrollpane does not contain a childClass ScrollPane, Adjustable getVAdjustable()
Returns theClass ScrollPane, void setScrollPosition(int, int)AdjustableScrollPaneAdjustable
object which represents the state of the vertical scrollbar. The declared return type of this method isAdjustable
to maintain backward compatibility. @see java.awt.ScrollPaneAdjustable
Scrolls to the specified position within the child component. A call to this method is only valid if the scroll pane contains a child. Specifying a position outside of the legal scrolling bounds of the child will scroll to the closest legal position. Legal bounds are defined to be the rectangle: x = 0 y = 0 width = (child width - view port width) height = (child height - view port height). This is a convenience method which interfaces with the Adjustable objects which represent the state of the scrollbars. @param x the x position to scroll to @param y the y position to scroll to @throws NullPointerException if the scrollpane does not contain a child
TheScrollbar
class embodies a scroll bar a familiar user-interface object. A scroll bar provides a convenient means for allowing a user to select from a range of values. The following three vertical scroll bars could be used as slider controls to pick the red green and blue components of a color:
![]()
Each scroll bar in this example could be created with code similar to the following:
redSlider=new Scrollbar(Scrollbar.VERTICAL 0 1 0 255); add(redSlider);
Alternatively a scroll bar can represent a range of values. For example if a scroll bar is used for scrolling through text the width of the "bubble" or "thumb" can represent the amount of text that is visible. Here is an example of a scroll bar that represents a range:
![]()
The value range represented by the bubble is the visible range of the scroll bar. The horizontal scroll bar in this example could be created with code like the following:
ranger = new Scrollbar(Scrollbar.HORIZONTAL 0 60 0 300); add(ranger);
Note that the actual maximum value of the scroll bar is the
maximum
minus thevisible
. In the previous example because themaximum
is 300 and thevisible
is 60 the actual maximum value is 240. The range of the scrollbar track is 0 - 300. The left side of the bubble indicates the value of the scroll bar.Normally the user changes the value of the scroll bar by making a gesture with the mouse. For example the user can drag the scroll bar's bubble up and down or click in the scroll bar's unit increment or block increment areas. Keyboard gestures can also be mapped to the scroll bar. By convention the Page Up and Page Down keys are equivalent to clicking in the scroll bar's block increment and block decrement areas.
When the user changes the value of the scroll bar the scroll bar receives an instance of
AdjustmentEvent
. The scroll bar processes this event passing it along to any registered listeners.Any object that wishes to be notified of changes to the scroll bar's value should implement
AdjustmentListener
an interface defined in the packagejava.awt.event
. Listeners can be added and removed dynamically by calling the methodsaddAdjustmentListener
andremoveAdjustmentListener
.The
AdjustmentEvent
class defines five types of adjustment event listed here:
AdjustmentEvent.TRACK
is sent out when the user drags the scroll bar's bubble.AdjustmentEvent.UNIT_INCREMENT
is sent out when the user clicks in the left arrow of a horizontal scroll bar or the top arrow of a vertical scroll bar or makes the equivalent gesture from the keyboard.AdjustmentEvent.UNIT_DECREMENT
is sent out when the user clicks in the right arrow of a horizontal scroll bar or the bottom arrow of a vertical scroll bar or makes the equivalent gesture from the keyboard.AdjustmentEvent.BLOCK_INCREMENT
is sent out when the user clicks in the track to the left of the bubble on a horizontal scroll bar or above the bubble on a vertical scroll bar. By convention the Page Up key is equivalent if the user is using a keyboard that defines a Page Up key.AdjustmentEvent.BLOCK_DECREMENT
is sent out when the user clicks in the track to the right of the bubble on a horizontal scroll bar or below the bubble on a vertical scroll bar. By convention the Page Down key is equivalent if the user is using a keyboard that defines a Page Down key.The JDK 1.0 event system is supported for backwards compatibility but its use with newer versions of the platform is discouraged. The
fivesfive types of adjustment event introduced with JDK 1.1 correspond to the five event types that are associated with scroll bars in previous platform versions. The following list gives the adjustment event type and the corresponding JDK 1.0 event type it replaces.
AdjustmentEvent.TRACK
replacesEvent.SCROLL_ABSOLUTE
AdjustmentEvent.UNIT_INCREMENT
replacesEvent.SCROLL_LINE_UP
AdjustmentEvent.UNIT_DECREMENT
replacesEvent.SCROLL_LINE_DOWN
AdjustmentEvent.BLOCK_INCREMENT
replacesEvent.SCROLL_PAGE_UP
AdjustmentEvent.BLOCK_DECREMENT
replacesEvent.SCROLL_PAGE_DOWN
@version 1.
77930412/0603/0001 @author Sami Shaio @see java.awt.event.AdjustmentEvent @see java.awt.event.AdjustmentListener @since JDK1.0
Get the role of this object. @return an instance of AccessibleRole
describing the role of the object
Class Scrollbar.AccessibleAWTScrollBar, AccessibleStateSet getAccessibleStateSet()Get the state set of this object. @return an instance of AccessibleState
containing the current state of the object @see AccessibleState
Class Scrollbar.AccessibleAWTScrollBar, AccessibleValue getAccessibleValue()Get theAccessibleValue
associated with this object. In the implementation of the Java Accessibility API for this class return this object which is responsible for implementing theAccessibleValue
interface on behalf of itself. @return this object
Constructs a new vertical scroll bar. The default properties of the scroll bar are listed in the following table:Class Scrollbar, constructor Scrollbar(int)
@exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless
Property Description Default Value orientation indicates if the scroll bar is vertical or horizontal Scrollbar.VERTICAL
value value which controls the location
of the scroll bar bubble0 minimum minimum value of the scroll bar 0 maximum maximum value of the scroll bar 100 unit increment amount the value changes when the
Line Up or Line Down key is pressed
or when the end arrows of the scrollbar
are clicked1 block increment amount the value changes when the
Page Up or Page Down key is pressed
or when the scrollbar track is clicked
on either side of the bubble10
Constructs a new scroll bar with the specified orientation.Class Scrollbar, constructor Scrollbar(int, int, int, int, int)The
orientation
argument must take one of the two valuesScrollbar.HORIZONTAL
orScrollbar.VERTICAL
indicating a horizontal or vertical scroll bar respectively. @param orientation indicates the orientation of the scroll bar.@exception IllegalArgumentException when an illegal value for theorientation
argument is supplied @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless
Constructs a new scroll bar with the specified orientation initial valueClass Scrollbar, void addAdjustmentListener(AdjustmentListener)page sizevisible amount and minimum and maximum values.The
orientation
argument must take one of the two valuesScrollbar.HORIZONTAL
orScrollbar.VERTICAL
indicating a horizontal or vertical scroll bar respectively.
If the specified maximum value is less than the minimum value itTheis changedparameters supplied tobe the same as the minimum value. If the initial value is lower than the minimum valuethisit is changedconstructor are subject tobe the minimum value; if it is greater thanthemaximum value it is changedconstraintsto bedescribed intheinmaximumintvalueint)}. @param orientation indicates the orientation of the scroll bar. @param value the initial value of the scroll bar.@param visible the size of the scroll bar's bubble representing the visible portion; the scroll bar uses this value when paging up or down by a page. @param minimum the minimum value of the scroll bar.@param maximum the maximum value of the scroll bar @exception IllegalArgumentException when an illegal value for theorientation
argument is supplied @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see #setValues @see java.awt.GraphicsEnvironment#isHeadless
Adds the specified adjustment listener to receive instances ofClass Scrollbar, void addNotify()AdjustmentEvent
from this scroll bar. If l isnull
no exception is thrown and no action is performed. @param l the adjustment listener.@seejava.awt.event.AdjustmentEvent#removeAdjustmentListener @see #getAdjustmentListeners @see java.awt.event.AdjustmentListenerAdjustmentEvent @see java.awt.Scrollbar#removeAdjustmentListenerevent.AdjustmentListener @since JDK1.1
Creates theClass Scrollbar, AccessibleContext getAccessibleContext()Scrollbar
's peer. The peer allows you to modify the appearance of theScrollbar
without changing any of its functionality.
Gets theClass Scrollbar, int getBlockIncrement()AccessibleContext
associated with thisScrollbar
. For scrollbars theAccessibleContext
takes the form of anAccessibleAWTScrollBar
. A newAccessibleAWTScrollBar
instance is created if necessary. @return anAccessibleAWTScrollBar
that serves as theAccessibleContext
of thisScrollBar
Gets the block increment of this scroll bar.Class Scrollbar, EventListener[] getListeners(Class)The block increment is the value that is added (subtracted) when the user activates the block increment area of the scroll bar generally through a mouse or keyboard gesture that the scroll bar receives as an adjustment event. @return the block increment of this scroll bar
.@see java.awt.Scrollbar#setBlockIncrement @since JDK1.1
Class Scrollbar, int getMaximum()ReturnReturns an array of all thelistenersobjectsthat were addedcurrently registered astoFooListener
sthe Scrollbarupon thiswithScrollbar
.addXXXListener()FooListener
swhere XXX isare registered using thenameaddFooListener
ofmethod.You can specify
thelistenerType
argument with a class literal such asFooListener.class
. For exampleto get all ofyou can query atheScrollbar
AdjustmentListener(s)c
forthe given Scrollbarits mouse listenersswithone would writethe following code:If no suchAdjustmentListenerMouseListener[]alsmls = (AdjustmentListenerMouseListener[])(sc.getListeners(AdjustmentListenerMouseListener.class));listenerlisteners existlist exists thenthis method returns an empty arrayis returned. @param listenerTypeTypethe type of listeners requested; this parameter should specify an interface that descends fromjava.util.EventListener
@returnallan array oftheall objects registered asFooListener
s on this component or an empty array if no such listenersof the specifiedhave been addedtype@exceptionsupported byClassCastException ifthislistenerType
doesn't specify a class orscrollbarinterface that implementsjava.util.EventListener
@since 1.3
Gets the maximum value of this scroll bar. @return the maximum value of this scroll barClass Scrollbar, int getMinimum().@see java.awt.Scrollbar#getValue @see java.awt.Scrollbar#getMinimum
Gets the minimum value of this scroll bar. @return the minimum value of this scroll barClass Scrollbar, int getOrientation().@see java.awt.Scrollbar#getValue @see java.awt.Scrollbar#getMaximum
Class Scrollbar, int getUnitIncrement()DeterminesReturns the orientation of this scroll bar. @return the orientation of this scroll bar eitherScrollbar.HORIZONTAL
orScrollbar.VERTICAL
.@see java.awt.Scrollbar#setOrientation
Gets the unit increment for this scrollbar.Class Scrollbar, int getValue()The unit increment is the value that is added (subtracted) when the user activates the unit increment area of the scroll bar generally through a mouse or keyboard gesture that the scroll bar receives as an adjustment event. @return the unit increment of this scroll bar
.@see java.awt.Scrollbar#setUnitIncrement @since JDK1.1
Gets the current value of this scroll bar. @return the current value of this scroll barClass Scrollbar, int getVisibleAmount().@see java.awt.Scrollbar#getMinimum @see java.awt.Scrollbar#getMaximum
Gets the visible amount of this scroll bar.Class Scrollbar, String paramString()The visible amount of a scroll bar is the range of values represented by the width of the scroll bar's bubble.
It is used to determine the scroll bar's block increment.@return the visible amount of this scroll bar.@see java.awt.Scrollbar#setVisibleAmount @since JDK1.1
ReturnsClass Scrollbar, void processAdjustmentEvent(AdjustmentEvent)the parametera string representing the state of thisscroll barScrollbar
. Thisstringmethod isusefulintended 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 benull
. @return the parameter string of this scroll bar.
Processes adjustment events occurring on this scrollbar by dispatching them to any registeredClass Scrollbar, void processEvent(AWTEvent)AdjustmentListener
objects.This method is not called unless adjustment events are enabled for this component. Adjustment events are enabled when one of the following occurs:
- An
AdjustmentListener
object is registered viaaddAdjustmentListener
.- Adjustment events are enabled via
enableEvents
.
Note that if the event parameter is
null
the behavior is unspecified and may result in an exception. @param e the adjustment event.@see java.awt.event.AdjustmentEvent @see java.awt.event.AdjustmentListener @see java.awt.Scrollbar#addAdjustmentListener @see java.awt.Component#enableEvents @since JDK1.1
Processes events on this scroll bar. If the event is an instance ofClass Scrollbar, void removeAdjustmentListener(AdjustmentListener)AdjustmentEvent
it invokes theprocessAdjustmentEvent
method. Otherwise it invokes its superclass'sprocessEvent
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.AdjustmentEvent @see java.awt.Scrollbar#processAdjustmentEvent @since JDK1.1
Removes the specified adjustment listener so that it no longer receives instances ofClass Scrollbar, void setBlockIncrement(int)AdjustmentEvent
from this scroll bar. If l isnull
no exception is thrown and no action is performed. @param l the adjustment listener.@seejava.awt.event.AdjustmentEvent#addAdjustmentListener @see #getAdjustmentListeners @see java.awt.event.AdjustmentListenerAdjustmentEvent @see java.awt.Scrollbar#addAdjustmentListenerevent.AdjustmentListener @since JDK1.1
Sets the block increment for this scroll bar.Class Scrollbar, void setMaximum(int)The block increment is the value that is added (subtracted) when the user activates the block increment area of the scroll bar generally through a mouse or keyboard gesture that the scroll bar receives as an adjustment event. @param v the amount by which to increment or decrement the scroll bar's value
.@see java.awt.Scrollbar#getBlockIncrement @since JDK1.1
Sets the maximum value of this scroll bar.Class Scrollbar, void setMinimum(int)When
setMaximum
is called the limiting argument takes precedence over the existing scrollbar value.Normally a program should change a scroll bar's maximum value only by calling
setValues
. ThesetValues
method simultaneously and synchronously sets the minimum maximum visible amount and value properties of a scroll bar so that they are mutually consistent. @param newMaximum the new maximum value for this scroll bar.@see java.awt.Scrollbar#setValues @see java.awt.Scrollbar#setMinimum @since JDK1.1
Sets the minimum value of this scroll bar.Class Scrollbar, void setOrientation(int)When
setMinimum
is called the limiting argument takes precedence over the existing scrollbar value.Normally a program should change a scroll bar's minimum value only by calling
setValues
. ThesetValues
method simultaneously and synchronously sets the minimum maximum visible amount and value properties of a scroll bar so that they are mutually consistent. @param newMinimum the new minimum value for this scroll bar.@see java.awt.Scrollbar#setValues @see java.awt.Scrollbar#setMaximum @since JDK1.1
Sets the orientation for this scroll bar. @param the orientation of this scroll bar eitherClass Scrollbar, void setUnitIncrement(int)Scrollbar.HORIZONTAL
orScrollbar.VERTICAL
.@see java.awt.Scrollbar#getOrientation @exception IllegalArgumentException if the value supplied fororientation
is not a legal value.@since JDK1.1
Sets the unit increment for this scroll bar.Class Scrollbar, void setValue(int)The unit increment is the value that is added (subtracted) when the user activates the unit increment area of the scroll bar generally through a mouse or keyboard gesture that the scroll bar receives as an adjustment event. @param v the amount by which to increment or decrement the scroll bar's value
.@see java.awt.Scrollbar#getUnitIncrement @since JDK1.1
Sets the value of this scroll bar to the specified value.Class Scrollbar, void setValues(int, int, int, int)If the value supplied is less than the current
minimum
or greater than the currentmaximum
-visibleAmount
then one of those values is substituted as appropriate.Normally a program should change a scroll bar's value only by calling
setValues
. ThesetValues
method simultaneously and synchronously sets the minimum maximum visible amount and value properties of a scroll bar so that they are mutually consistent. @param newValue the new value of the scroll bar.@see java.awt.Scrollbar#setValues @see java.awt.Scrollbar#getValue @see java.awt.Scrollbar#getMinimum @see java.awt.Scrollbar#getMaximum
Sets the values of four properties for this scroll bar:Class Scrollbar, void setVisibleAmount(int)value
visibleAmount
minimum
andmaximum
. If the values supplied for these properties are inconsistent or incorrect they will be changed to ensure consistency.This method simultaneously and synchronously sets the values of four scroll bar properties assuring that the values of these properties are mutually consistent. It enforces the
constraintsfollowingthatconstraints:maximum
cannotmust belessgreater thanminimum
andvisibleAmount
thatmust be positivevisibleAmount
must not be greater thanmaximum
-minimum
value
mustcannotnot be less thantheminimum
orandvalue
must not be greater thanthemaximum
-.visibleAmount
@param value is the position in the current window.@param visible is the amount visible per page.@param minimum is the minimum value of the scroll bar.@param maximum is the maximum value of the scroll bar.@see #setMinimum @see #setMaximum @see #setVisibleAmount @see #setValue
Sets the visible amount of this scroll bar.The visible amount of a scroll bar is the range of values represented by the width of the scroll bar's bubble.
It is used to determine the scroll bar's block increment.Normally a program should change a scroll bar's value only by calling
setValues
. ThesetValues
method simultaneously and synchronously sets the minimum maximum visible amount and value properties of a scroll bar so that they are mutually consistent. @param newAmount the amount visible per page.@see java.awt.Scrollbar#getVisibleAmount @see java.awt.Scrollbar#setValues @since JDK1.1
TheShape
interface provides definitions for objects that represent some form of geometric shape. TheShape
is described by a PathIterator object which can express the outline of theShape
as well as a rule for determining how the outline divides the 2D plane into interior and exterior points. EachShape
object provides callbacks to get the bounding box of the geometry determine whether points or rectangles lie partly or entirely within the interior of theShape
and retrieve aPathIterator
object that describes the trajectory path of theShape
outline.Definition of insideness: A point is considered to lie inside a
Shape
if and only if:
- it lies completely inside the
Shape
boundary or- it lies exactly on the
Shape
boundary and the space immediately adjacent to the point in the increasingX
direction is entirely inside the boundary or- it lies exactly on a horizontal boundary segment and the space immediately adjacent to the point in the increasing
Y
direction is inside the boundary.The
contains
andintersects
methods consider the interior of aShape
to be the area it encloses as if it were filled. This means that these methods consider unclosed shapes to be implicitly closed for the purpose of determining if a shape contains or intersects a rectangle or if a shape contains a point. @see java.awt.geom.PathIterator @see java.awt.geom.AffineTransform @see java.awt.geom.FlatteningPathIterator @see java.awt.geom.GeneralPath @version 1.19 06/24/98 @author Jim Graham
TheStroke
interface allows a Graphics2D object to obtain a Shape that is the decorated outline or stylistic representation of the outline of the specifiedShape
. Stroking aShape
is like tracing its outline with a marking pen of the appropriate size and shape. The area where the pen would place ink is the area enclosed by the outlineShape
.The methods of the
Graphics2D
interface that use the outlineShape
returned by aStroke
object includedraw
and any other methods that are implemented in terms of that method such asdrawLine
drawRect
drawRoundRect
drawOval
drawArc
drawPolyline
anddrawPolygon
.The objects of the classes implementing
Stroke
must be read-only becauseGraphics2D
does not clone these objects either when they are set as an attribute with thesetStroke
method or when theGraphics2D
object is itself cloned. If aStroke
object is modified after it is set in theGraphics2D
context then the behavior of subsequent rendering would be undefined. @see BasicStroke @see Graphics2D#setStroke @version 1.19 0220 12/0203/0001
A class to encapsulate symbolic colors representing the color of native GUI objects on a system. For systems which support the dynamic update of the system colors (when the user changes the colors) the actual RGB values of these symbolic colors will also change dynamically. In order to compare the "current" RGB value of aClass SystemColor, PaintContext createContext(ColorModel, Rectangle, Rectangle2D, AffineTransform, RenderingHints)SystemColor
object with a non-symbolic Color objectgetRGB
should be used rather than()equals
.()Note that the way in which these system colors are applied to GUI objects may vary slightly from platform to platform since GUI objects may be rendered differently on each platform.
System color values may also be available through the
.Toolkit. @see Toolkit#getDesktopProperty @version 1.getDesktopProperty
method onjava.awt
18 0222 12/0203/0001 @author Carl Quinn @author Amy Fowler
Class SystemColor, String toString()CreateCreates andreturnreturns aPaintContext
used to generate a solid color pattern. This enables a Color object to be used as an argument to any method requiring an object implementing the Paint interface. @see Paint @see PaintContext @see Graphics2D#setPaint
ReturnsClass SystemColor, int ACTIVE_CAPTIONthe Stringa string representation of thisColor
's values. 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 benull
. @return a string representation of thisColor
The array index for theClass SystemColor, int ACTIVE_CAPTION_BORDERactiveactiveCaption
captionsystembackgroundcolor. @see SystemColor#activeCaption
The array index for theClass SystemColor, int ACTIVE_CAPTION_TEXTactiveactiveCaptionBorder
captionsystembordercolor. @see SystemColor#activeCaptionBorder
The array index for theClass SystemColor, int CONTROLactionactiveCaptionText
captionsystemtextcolor. @see SystemColor#activeCaptionText
The array index for theClass SystemColor, int CONTROL_DK_SHADOWcontrol
backgroundsystem color. @see SystemColor#control
The array index for theClass SystemColor, int CONTROL_HIGHLIGHTcontrolcontrolDkShadow
darksystemshadowcolor. @see SystemColor#controlDkShadow
The array index for theClass SystemColor, int CONTROL_LT_HIGHLIGHTcontrolcontrolHighlight
highlightsystem color. @see SystemColor#controlHighlight
The array index for theClass SystemColor, int CONTROL_SHADOWcontrolcontrolLtHighlight
lightsystemhighlightcolor. @see SystemColor#controlLtHighlight
The array index for theClass SystemColor, int CONTROL_TEXTcontrolcontrolShadow
shadowsystem color. @see SystemColor#controlShadow
The array index for theClass SystemColor, int DESKTOPcontrolcontrolText
textsystem color. @see SystemColor#controlText
The array index for theClass SystemColor, int INACTIVE_CAPTIONdesktop
backgroundsystem color. @see SystemColor#desktop
The array index for theClass SystemColor, int INACTIVE_CAPTION_BORDERinactiveinactiveCaption
captionsystembackgroundcolor. @see SystemColor#inactiveCaption
The array index for theClass SystemColor, int INACTIVE_CAPTION_TEXTinactiveinactiveCaptionBorder
captionsystembordercolor. @see SystemColor#inactiveCaptionBorder
The array index for theClass SystemColor, int INFOinactiveinactiveCaptionText
captionsystemtextcolor. @see SystemColor#inactiveCaptionText
The array index for theClass SystemColor, int INFO_TEXTinfo
backgroundsystem color. @see SystemColor#info
The array index for theClass SystemColor, int MENUinfoinfoText
textsystem color. @see SystemColor#infoText
The array index for theClass SystemColor, int MENU_TEXTmenu
backgroundsystem color. @see SystemColor#menu
The array index for theClass SystemColor, int SCROLLBARmenumenuText
textsystem color. @see SystemColor#menuText
The array index for theClass SystemColor, int TEXTscrollbar
backgroundsystem color. @see SystemColor#scrollbar
The array index for theClass SystemColor, int TEXT_HIGHLIGHTtext
backgroundsystem color. @see SystemColor#text
The array index for theClass SystemColor, int TEXT_HIGHLIGHT_TEXTtexttextHighlight
highlightsystem color. @see SystemColor#textHighlight
The array index for theClass SystemColor, int TEXT_INACTIVE_TEXTtexttextHighlightText
highlightsystemtextcolor. @see SystemColor#textHighlightText
The array index for theClass SystemColor, int TEXT_TEXTtexttextInactiveText
inactivesystemtextcolor. @see SystemColor#textInactiveText
The array index for theClass SystemColor, int WINDOWtexttextText
textsystem color. @see SystemColor#textText
The array index for theClass SystemColor, int WINDOW_BORDERwindow
backgroundsystem color. @see SystemColor#window
The array index for theClass SystemColor, int WINDOW_TEXTwindowwindowBorder
bordersystem color. @see SystemColor#windowBorder
The array index for theClass SystemColor, SystemColor activeCaptionwindowwindowText
textsystem color. @see SystemColor#windowText
TheClass SystemColor, SystemColor activeCaptionBorderbackgroundcolorfor captions inrendered for the window-title backgroundbordersof the currently active window.
TheClass SystemColor, SystemColor activeCaptionTextbordercolor rendered forcaptions in windowthe border aroundbordersthe currently active window.
TheClass SystemColor, SystemColor controltextcolorfor captions inrendered for the window-title textbordersof the currently active window.
TheClass SystemColor, SystemColor controlDkShadowbackgroundcolor rendered for the background of control panels and control objects such as pushbuttons.
The color rendered for dark shadowClass SystemColor, SystemColor controlHighlightcolorareasforon 3D control objects such as pushbuttons. This color is typically derived from thecontrol
background color to provide a 3D effect.
TheClass SystemColor, SystemColor controlLtHighlightregular highlightcolor rendered for light areas of 3D control objects such as pushbuttons. This color is typically derived from thecontrol
background color to provide a 3D effect.
TheClass SystemColor, SystemColor controlShadowlightcolor rendered for highlightcolor forareas of 3D control objects such as pushbuttons. This color is typically derived from thecontrol
background color to provide a 3D effect.
TheClass SystemColor, SystemColor controlTextregularcolor rendered for shadowcolor forareas of 3D control objects such as pushbuttons. This color is typically derived from thecontrol
background color to provide a 3D effect.
TheClass SystemColor, SystemColor desktoptextcolor rendered for the text of control panels and control objects such as pushbuttons.
The color rendered for the background of the desktopClass SystemColor, SystemColor inactiveCaptionbackground.
TheClass SystemColor, SystemColor inactiveCaptionBorderbackgroundcolor rendered forinactivethe window-titlecaptions in window bordersbackground of inactive windows.
TheClass SystemColor, SystemColor inactiveCaptionTextbordercolor rendered forinactive captios in window bordersthe border around inactive windows.
TheClass SystemColor, SystemColor infotextcolor rendered forinactivethe window-titlecaptions in window borderstext of inactive windows.
TheClass SystemColor, SystemColor infoTextbackgroundcolor rendered forinfo(help)the backgroundtextof tooltips or spot help.
TheClass SystemColor, SystemColor menutextcolor rendered forinfo(help)the text of tooltips or spot help.
TheClass SystemColor, SystemColor menuTextbackgroundcolor rendered for the background of menus.
TheClass SystemColor, SystemColor scrollbartextcolor rendered for the text of menus.
TheClass SystemColor, SystemColor textbackgroundcolor rendered for the background of scrollbars.
TheClass SystemColor, SystemColor textHighlightbackgroundcolor rendered for the background of textcomponentscontrol objects such as textfields and comboboxes.
TheClass SystemColor, SystemColor textHighlightTextbackgroundcolor rendered forhighlightedthe background of selected items such as in menus comboboxes and text.
TheClass SystemColor, SystemColor textInactiveTexttextcolor rendered forhighlightedthe text of selected items such as in menus comboboxes and text.
TheClass SystemColor, SystemColor textTexttextcolor rendered forinactivethe text of inactive items such as in menus.
TheClass SystemColor, SystemColor windowtextcolor rendered for the text of textcomponentscontrol objects such as textfields and comboboxes.
TheClass SystemColor, SystemColor windowBorderbackgroundcolor rendered for the background of interior regions inside windows.
TheClass SystemColor, SystemColor windowTextbordercolor rendered for the border around interior regions inside windows.
Thetextcolor rendered for text of interior regions inside windows.
AClass TextArea, constructor TextArea()TextArea
object is a multi-line region that displays text. It can be set to allow editing or to be read-only.The following image shows the appearance of a text area:
![]()
This text area could be created by the following line of code:
new TextArea("Hello" 5 40);
@version 1.
57 0470 12/0603/0001 @author Sami Shaio @since JDK1.0
Constructs a new text area with the empty string as text. This text area is created with scrollbar visibility equal to #SCROLLBARS_BOTH so both vertical and horizontal scrollbars will be visible for this text area. @exception HeadlessException if GraphicsEnvironment.isHeadless
returns true @see java.awt.GraphicsEnvironment#isHeadless()
Class TextArea, constructor TextArea(String)Constructs a new text area with the specified text. This text area is created with scrollbar visibility equal to #SCROLLBARS_BOTH so both vertical and horizontal scrollbars will be visible for this text area. @param text the text to be displayed; ifClass TextArea, constructor TextArea(String, int, int)text
isnull
the empty string""
will be displayed @exception HeadlessException ifGraphicsEnvironment.isHeadless
returns true @see java.awt.GraphicsEnvironment#isHeadless()
Constructs a new text area with the specified text and with the specified number of rows and columns. A column is an approximate average character width that is platform-dependent. The text area is created with scrollbar visibility equal to #SCROLLBARS_BOTH so both vertical and horizontal scrollbars will be visible for this text area. @param text the text to be displayedClass TextArea, constructor TextArea(String, int, int, int).; iftext
isnull
the empty string""
will be displayed @param rows the number of rows.@param columns the number of columns @exception HeadlessException ifGraphicsEnvironment
.isHeadless returns true @see java.awt.GraphicsEnvironment#isHeadless()
Constructs a new text area with the specified text and with the rows columns and scroll bar visibility as specified. AllClass TextArea, constructor TextArea(int, int)TextArea
constructors defer to this one.The
TextArea
class defines several constants that can be supplied as values for thescrollbars
argument:Any other value for the
SCROLLBARS_BOTH
SCROLLBARS_VERTICAL_ONLY
SCROLLBARS_HORIZONTAL_ONLY
andSCROLLBARS_NONE
.scrollbars
argument is invalid and will result in this text area being created with scrollbar visibility equal to the default value of #SCROLLBARS_BOTH @param text the text to be displayed. If; iftext
isnull
the empty string""
will be displayed.@param rows the number of rows. If; ifrows
is less than0
rows
is set to0
.@param columns the number of columns. If; ifcolumns
is less than0
columns
is set to0
.@param scrollbars a constant that determines what scrollbars are created to view the text area.@since JDK1.1 @exception HeadlessException ifGraphicsEnvironment.isHeadless
returns true @see java.awt.GraphicsEnvironment#isHeadless()
Constructs a newClass TextArea, void addNotify()emptytext area with the specified number of rows and columns and the empty string as text. A column is an approximate average character width that is platform-dependent. The text area is created with scrollbar visibility equal to #SCROLLBARS_BOTH so both vertical and horizontal scrollbars will be visible for this text area. @param rows the number of rows @param columns the number of columns @exception HeadlessException ifGraphicsEnvironment.isHeadless
returns true @see java.awt.GraphicsEnvironment#isHeadless()
Creates theClass TextArea, void append(String)TextArea
's peer. The peer allows us to modify the appearance of theTextArea
without changing any of its functionality.
Appends the given text to the text area's current text.Class TextArea, AccessibleContext getAccessibleContext()Note that passing
null
or inconsistent parameters is invalid and will result in unspecified behavior. @param str the non-null
text to append.@see java.awt.TextArea#insert @since JDK1.1
Class TextArea, int getColumns()GetsReturns theAccessibleContext
associated with thisTextArea
. For text areas theAccessibleContext
takes the form of anAccessibleAWTTextArea
. A newAccessibleAWTTextArea
instance is created if necessary. @return anAccessibleAWTTextArea
that serves as theAccessibleContext
of thisTextArea
Class TextArea, Dimension getMinimumSize()GetsReturns the number of columns in this text area. @return the number of columns in the text area.@seejava.awt.TextArea#setColumns(int) @seejava.awt.TextArea#getRows()
Determines the minimum size of this text area. @return the preferred dimensions needed for this text areaClass TextArea, Dimension getMinimumSize(int, int).@see java.awt.Component#getPreferredSize @since JDK1.1
Determines the minimum size of a text area with the specified number of rows and columns. @param rows the number of rowsClass TextArea, Dimension getPreferredSize().@param cols the number of columns.@return the minimum dimensions required to display the text area with the specified number of rows and columns.@see java.awt.Component#getMinimumSize @since JDK1.1
Determines the preferred size of this text area. @return the preferred dimensions needed for this text areaClass TextArea, Dimension getPreferredSize(int, int).@see java.awt.Component#getPreferredSize @since JDK1.1
Determines the preferred size of a text area with the specified number of rows and columns. @param rows the number of rowsClass TextArea, int getRows().@param cols the number of columns.@return the preferred dimensions required to display the text area with the specified number of rows and columns.@see java.awt.Component#getPreferredSize @since JDK1.1
Class TextArea, int getScrollbarVisibility()GetsReturns the number of rows in the text area. @return the number of rows in the text area.@seejava.awt.TextArea#setRows(int) @seejava.awt.TextArea#getColumns() @since JDK1
Class TextArea, void insert(String, int)GetsReturns an enumerated value that indicates which scroll bars the text area uses.The
TextArea
class defines four integer constants that are used to specify which scroll bars are available.TextArea
has one constructor that gives the application discretion over scroll bars. @return an integer that indicates which scroll bars are used.@see java.awt.TextArea#SCROLLBARS_BOTH @see java.awt.TextArea#SCROLLBARS_VERTICAL_ONLY @see java.awt.TextArea#SCROLLBARS_HORIZONTAL_ONLY @see java.awt.TextArea#SCROLLBARS_NONE @see java.awt.TextArea#TextArea(java.lang.String int int int) @since JDK1.1
Inserts the specified text at the specified position in this text area.Class TextArea, String paramString()Note that passing
null
or inconsistent parameters is invalid and will result in unspecified behavior. @param str the non-null
text to insert.@param pos the position at which to insert.@see java.awt.TextComponent#setText @see java.awt.TextArea#replaceRange @see java.awt.TextArea#append @since JDK1.1
ReturnsClass TextArea, void replaceRange(String, int, int)the parametera string representing the state of thistext areaTextArea
. Thisstringmethod isusefulintended 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 benull
. @return the parameter string of this text area.
Replaces text between the indicated start and end positions with the specified replacement text. The text at the end position will not be replaced. The text at the start position will be replaced (unless the start position is the same as the end position). The text position is zero-based. The inserted substring may be of a different length than the text it replaces.Class TextArea, void setColumns(int)Note that passing
@param str the non-null
or inconsistent parameters is invalid and will result in unspecified behavior.null
text to use as the replacement.@param start the start position.@param end the end position.@see java.awt.TextArea#insert @since JDK1.1
Sets the number of columns for this text area. @param columns the number of columnsClass TextArea, void setRows(int).@seejava.awt.TextArea#getColumns() @seejava.awt.TextArea#setRows(int) @exception IllegalArgumentException if the value supplied forcolumns
is less than0
.@since JDK1.1
Sets the number of rows for this text area. @param rows the number of rows.@seejava.awt.TextArea#getRows() @seejava.awt.TextArea#setColumns(int) @exception IllegalArgumentException if the value supplied forrows
is less than0
.@since JDK1.1
TheClass TextComponent, void addTextListener(TextListener)TextComponent
class is the superclass of any component that allows the editing of some text.A text component embodies a string of text. The
TextComponent
class defines a set of methods that determine whether or not this text is editable. If the component is editable it defines another set of methods that supports a text insertion caret.In addition the class defines methods that are used to maintain a current selection from the text. The text selection a substring of the component's text is the target of editing operations. It is also referred to as the selected text. @version 1.
65 0471 12/2103/01 @author Sami Shaio @author Arthur van Hoff @since JDK1.0
Adds the specified text event listener to receive text events from this text component. IfClass TextComponent, int getCaretPosition()l
isnull
no exception is thrown and no action is performed. @param l the text event listener @see #removeTextListener @see #getTextListeners @see java.awt.event.TextListener
Gets the position of the text insertion caret for this text component. @return the position of the text insertion caretClass TextComponent, EventListener[] getListeners(Class).@since JDK1.1
Class TextComponent, String getSelectedText()ReturnReturns an array of all thelistenersobjectsthat were addedcurrently registered astoFooListener
sthe TextComponentupon thiswithTextComponent
.addXXXListener()FooListener
swhere XXX isare registered using thenameaddFooListener
method.
ofYou can specify thelistenerType
argument.For example to get all ofwith a class literal such astheFooListener.class
.TextListeners forFor exampletheyou can querygivenaTextComponent
t
onefor its text listeners with thewould writefollowing code:If no suchTextListener[] tls = (TextListener[])(t.getListeners(TextListener.class));listenerlisteners existlist exists thenthis method returns an empty arrayis returned. @param listenerTypeTypethe type of listeners requested;@returnthisall of theparameter should specifylistenersan interface that descends fromjava.util.EventListener
@return an array ofthe specified type supportedall objects registered asbyFooListener
s on this text component or an empty array if no such listeners have been added @exception ClassCastException iflistenerType
doesn't specify a class or interface that implementsjava.util.EventListener
@see #getTextListeners @since 1.3
Class TextComponent, int getSelectionEnd()GetsReturns the selected text from the text that is presented by this text component. @return the selected text of this text component.@see java.awt.TextComponent#select
Gets the end position of the selected text in this text component. @return the end position of the selected textClass TextComponent, int getSelectionStart().@see java.awt.TextComponent#setSelectionEnd @see java.awt.TextComponent#getSelectionStart
Gets the start position of the selected text in this text component. @return the start position of the selected textClass TextComponent, String getText().@see java.awt.TextComponent#setSelectionStart @see java.awt.TextComponent#getSelectionEnd
Class TextComponent, String paramString()GetsReturns the text that is presented by this text component. @see java.awt.TextComponent#setText
ReturnsClass TextComponent, void processEvent(AWTEvent)the parametera string representing the state of thistext componentTextComponent
. Thisstringmethod isusefulintended 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 benull
. @return the parameter string of this text component.
Processes events on this text component. If the event is aClass TextComponent, void processTextEvent(TextEvent)TextEvent
it invokes theprocessTextEvent
method else it invokes its superclass'sprocessEvent
.Note that if the event parameter is
null
the behavior is unspecified and may result in an exception. @param e the event
Processes text events occurring on this text component by dispatching them to any registeredClass TextComponent, void removeNotify()TextListener
objects.NOTE: This method will not be called unless text events are enabled for this component. This happens when one of the following occurs:
a)
- A
TextListener
object is registered viaaddTextListener
() b)- Text events are enabled via
enableEvents
()@seeComponent#enableEventsNote that if the event parameter is
null
the behavior is unspecified and may result in an exception. @param e the text event @see Component#enableEvents
Removes theClass TextComponent, void removeTextListener(TextListener)TextComponent
's peer. The peer allows us to modify the appearance of theTextComponent
without changing its functionality.
Removes the specified text event listener so that it no longer receives text events from this text component IfClass TextComponent, void select(int, int)l
isnull
no exception is thrown and no action is performed. @param l the text listener.@seejava.awt.event.TextListener#addTextListener @see #getTextListeners @see java.awt.TextComponent#addTextListenerevent.TextListener @since JDK1.1
Selects the text between the specified start and end positions.Class TextComponent, void setCaretPosition(int)This method sets the start and end positions of the selected text enforcing the restriction that the start position must be greater than or equal to zero. The end position must be greater than or equal to the start position and less than or equal to the length of the text component's text. The character positions are indexed starting with zero. The length of the selection is
endPosition
-startPosition so the character at
endPosition
is not selected. If the start and end positions of the selected text are equal all text is deselected.If the caller supplies values that are inconsistent or out of bounds the method enforces these constraints silently and without failure. Specifically if the start position or end position is greater than the length of the text it is reset to equal the text length. If the start position is less than zero it is reset to zero and if the end position is less than the start position it is reset to the start position. @param selectionStart the zero-based index of the first character to be selected
.@param selectionEnd the zero-based end position of the text to be selected. The; the character atselectionEnd
is not selected.@see java.awt.TextComponent#setSelectionStart @see java.awt.TextComponent#setSelectionEnd @see java.awt.TextComponent#selectAll
Sets the position of the text insertion caret for this text component. The caret position is constrained to be at or before the current selection end. If the caller supplies a value forClass TextComponent, void setSelectionEnd(int)position
that is greater than the end of the component's text the caret position is set to the end of the component's text. This happens silently and without failure. The caret position also cannot be set to less than zero the beginning of the component's text. If the caller supplies a value forposition
that is less than zero anIllegalArgumentException
is thrown. @param position the position of the text insertion caret.@exception IllegalArgumentException if the value supplied forposition
is less than zero.@since JDK1.1
Sets the selection end for this text component to the specified position. The new end point is constrained to be at or after the current selection start. It also cannot be set beyond the end of the component's text. If the caller supplies a value forClass TextComponent, void setSelectionStart(int)selectionEnd
that is out of bounds the method enforces these constraints silently and without failure. @param selectionEnd the end position of the selected text.@see java.awt.TextComponent#getSelectionEnd @see java.awt.TextComponent#setSelectionStart @since JDK1.1
Sets the selection start for this text component to the specified position. The new start point is constrained to be at or before the current selection end. It also cannot be set to less than zero the beginning of the component's text. If the caller supplies a value forClass TextComponent, void setText(String)selectionStart
that is out of bounds the method enforces these constraints silently and without failure. @param selectionStart the start position of the selected text.@see java.awt.TextComponent#getSelectionStart @see java.awt.TextComponent#setSelectionEnd @since JDK1.1
Sets the text that is presented by this text component to be the specified text. @param t the new text. If; if this parameter isnull
then the text is set to the empty string "".@see java.awt.TextComponent#getText
AClass TextField, constructor TextField()TextField
object is a text component that allows for the editing of a single line of text.For example the following image depicts a frame with four text fields of varying widths. Two of these text fields display the predefined text
"Hello"
.
![]()
Here is the code that produces these four text fields:
TextField tf1 tf2 tf3 tf4; // a blank text field tf1 = new TextField(); // blank field of 20 columns tf2 = new TextField("" 20); // predefined text displayed tf3 = new TextField("Hello "); // predefined text in 30 columns tf4 = new TextField("Hello" 30);
Every time the user types a key in the text field one or more key events are sent to the text field. A
KeyEvent
may be one of three types: keyPressed keyReleased or keyTyped. The properties of a key event indicate which of these types it is as well as additional information about the event such as what modifiers are applied to the key event and the time at which the event occurred.The key event is passed to every
KeyListener
orKeyAdapter
object which registered to receive such events using the component'saddKeyListener
method. (KeyAdapter
objects implement theKeyListener
interface.)It is also possible to fire an
ActionEvent
. If action events are enabled for the text field they may be fired by pressing theReturn
key.The
TextField
class'sprocessEvent
method examines the action event and passes it along toprocessActionEvent
. The latter method redirects the event to anyActionListener
objects that have registered to receive action events generated by this text field. @version 1.63 0471 12/0603/0001 @author Sami Shaio @see java.awt.event.KeyEvent @see java.awt.event.KeyAdapter @see java.awt.event.KeyListener @see java.awt.event.ActionEvent @see java.awt.Component#addKeyListener @see java.awt.TextField#processEvent @see java.awt.TextField#processActionEvent @see java.awt.TextField#addActionListener @since JDK1.0
Constructs a new text field. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadlessClass TextField, constructor TextField(String)
Constructs a new text field initialized with the specified text. @param text the text to be displayed. IfClass TextField, constructor TextField(String, int)text
isnull
the empty string""
will be displayed. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless
Constructs a new text field initialized with the specified text to be displayed and wide enough to hold the specified number of columns. A column is an approximate average character width that is platform-dependent. @param text the text to be displayed. IfClass TextField, constructor TextField(int)text
isnull
the empty string""
will be displayed. @param columns the number of columns. Ifcolumns
is less than0
columns
is set to0
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless
Constructs a new empty text field with the specified number of columns. A column is an approximate average character width that is platform-dependent. @param columns the number of columns. IfClass TextField, void addActionListener(ActionListener)columns
is less than0
columns
is set to0
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless
Adds the specified action listener to receive action events from this text field. If l is null no exception is thrown and no action is performed. @param l the action listener. @seeClass TextField, EventListener[] getListeners(Class)java.awt.event#ActionListenerremoveActionListener @see #getActionListeners @see java.awt.TextField#removeActionListenerevent.ActionListener @since JDK1.1
Class TextField, String paramString()ReturnReturns an array of all thelistenersobjectsthat were addedcurrently registered astoFooListener
sthe TextFieldupon thiswithTextField
.addXXXListener()FooListener
swhere XXX isare registered using thenameaddFooListener
ofmethod.You can specify
thelistenerType
argument.For example to get all ofwith a class literal such astheFooListener.class
.ActionListener(s)Forforexampletheyou cangivenquery aTextField
t
onefor its action listeners with thewould writefollowing code:If no suchActionListener[] als = (ActionListener[])(t.getListeners(ActionListener.class));listenerlisteners existlist exists thenthis method returns an empty arrayis returned. @param listenerTypeTypethe type of listeners requested; this parameter should specify an interface that descends fromjava.util.EventListener
@returnallan array oftheall objects registered asFooListener
s on this textfield or an empty array if no such listenersof the specifiedhave been addedtype@exceptionsupported byClassCastException ifthislistenerType
doesn't specify a class or interfacetextthat implementsjava.util.EventListener
@seefield#getActionListeners @since 1.3
ReturnsClass TextField, void processActionEvent(ActionEvent)the parametera string representing the state of thistext fieldTextField
. Thisstringmethod isusefulintended 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 benull
. @return the parameter string of this text field.
Processes action events occurring on this text field by dispatching them to any registeredClass TextField, void processEvent(AWTEvent)ActionListener
objects.This method is not called unless action events are enabled for this component. Action events are enabled when one of the following occurs:
- An
ActionListener
object is registered viaaddActionListener
.- Action events are enabled via
enableEvents
.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.TextField#addActionListener @see java.awt.Component#enableEvents @since JDK1.1
Processes events on this text field. If the event is an instance ofClass TextField, void removeActionListener(ActionListener)ActionEvent
it invokes theprocessActionEvent
method. Otherwise it invokesprocessEvent
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.TextField#processActionEvent @since JDK1.1
Removes the specified action listener so that it no longer receives action events from this text field. If l is null no exception is thrown and no action is performed. @param l the action listener. @seejava.awt.event#ActionListeneraddActionListener @see #getActionListeners @see java.awt.TextField#addActionListenerevent.ActionListener @since JDK1.1
TheTexturePaint
class provides a way to fill a Shape with a texture that is specified as a BufferedImage The size of theBufferedImage
object should be small because theBufferedImage
data is copied by theTexturePaint
object. At construction time the texture is anchored to the upper left corner of a Rectangle2D that is specified in user space. Texture is computed for locations in the device space by conceptually replicating the specifiedRectangle2D
infinitely in all directions in user space and mapping theBufferedImage
to each replicatedRectangle2D
. @see Paint @see Graphics2D#setPaint @version 1.36 0237 12/0203/0001
This class is the abstract superclass of all actual implementations of the Abstract Window Toolkit. Subclasses ofClass Toolkit, void addAWTEventListener(AWTEventListener, long)Toolkit
are used to bind the various components to particular native toolkit implementations.Most applications should not call any of the methods in this class directly. The methods defined by
Toolkit
are the "glue" that joins the platform-independent classes in thejava.awt
package with their counterparts injava.awt.peer
. Some methods defined byToolkit
query the native operating system directly. @version 1.156 02181 12/0903/01 @author Sami Shaio @author Arthur van Hoff @author Fred Ecks @since JDK1.0
Adds an AWTEventListener to receive all AWTEvents dispatched system-wide that conform to the givenClass Toolkit, void addPropertyChangeListener(String, PropertyChangeListener)eventMask
.First if there is a security manager its
checkPermission
method is called with anAWTPermission("listenToAllAWTEvents")
permission. This may result in a SecurityException.
eventMask
is a bitmask of event types to receive. It is constructed by bitwise OR-ing together the event masks defined inAWTEvent
.Note: event listener use is not recommended for normal application use but are intended solely to support special purpose facilities including support for accessibility event record/playback and diagnostic tracing. If listener is null no exception is thrown and no action is performed. @param listener the event listener. @param eventMask the bitmask of event types to receive @throws SecurityException if a security manager exists and its
checkPermission
method doesn't allow the operation. @seejava.awt.event.AWTEventListener#removeAWTEventListener @see #getAWTEventListeners @see SecurityManager#checkPermission @see java.awt.Toolkit#addAWTEventListenerAWTEvent @see java.awt.AWTEventAWTPermission @seeSecurityManager#checkPermissionjava.awt.event.AWTEventListener @see java.awt.AWTPermissionevent.AWTEventListenerProxy @since 1.2
Class Toolkit, ButtonPeer createButton(Button)addAdds the specified property change listener for the named desktop property. If pcl is null no exception is thrown and no action is performed. @param name The name of the property to listen for @param pcl The property change listener @since 1.2
Creates this toolkit's implementation ofClass Toolkit, CheckboxPeer createCheckbox(Checkbox)Button
using the specified peer interface. @param target the button to be implemented. @return this toolkit's implementation ofButton
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.Button @see java.awt.peer.ButtonPeer
Creates this toolkit's implementation ofClass Toolkit, CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem)Checkbox
using the specified peer interface. @param target the check box to be implemented. @return this toolkit's implementation ofCheckbox
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.Checkbox @see java.awt.peer.CheckboxPeer
Creates this toolkit's implementation ofClass Toolkit, ChoicePeer createChoice(Choice)CheckboxMenuItem
using the specified peer interface. @param target the checkbox menu item to be implemented. @return this toolkit's implementation ofCheckboxMenuItem
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.CheckboxMenuItem @see java.awt.peer.CheckboxMenuItemPeer
Creates this toolkit's implementation ofClass Toolkit, Cursor createCustomCursor(Image, Point, String)Choice
using the specified peer interface. @param target the choice to be implemented. @return this toolkit's implementation ofChoice
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.Choice @see java.awt.peer.ChoicePeer
Creates a new custom cursor object. If the image to display is invalid the cursor will be hidden (made completely transparent) and the hotspot will be set to (0 0). @param image the image to display when the cursor is active. @param hotSpot the X and Y of the large cursor's hot spot. The hotSpot values must be less than the Dimension returned by getBestCursorSize(). @param name a localized description of the cursor for Java Accessibility use. @exception IndexOutOfBoundsException if the hotSpot values are outside the bounds of the cursor. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @since 1.2Class Toolkit, DialogPeer createDialog(Dialog)
Creates this toolkit's implementation ofClass Toolkit, DragGestureRecognizer createDragGestureRecognizer(Class, DragSource, Component, int, DragGestureListener)Dialog
using the specified peer interface. @param target the dialog to be implemented. @return this toolkit's implementation ofDialog
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.Dialog @see java.awt.peer.DialogPeer
Class Toolkit, DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent)createCreates a concrete platform dependent subclass of the abstract DragGestureRecognizer class requested andassociateassociates it with the DragSource Component and DragGestureListener specified. subclasses should override this to provide their own implementation @param abstractRecognizerClass The abstract class of the required recognizer @param ds The DragSource @param c The Component target for the DragGestureRecognizer @param srcActions The actions permitted for the gesture @param dgl The DragGestureListener @Return the new object or null. Always returns null if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless
Class Toolkit, FileDialogPeer createFileDialog(FileDialog)createCreates the peer for a DragSourceContext. Always throws InvalidDndOperationException if GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless
Creates this toolkit's implementation ofClass Toolkit, FramePeer createFrame(Frame)FileDialog
using the specified peer interface. @param target the file dialog to be implemented. @return this toolkit's implementation ofFileDialog
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.FileDialog @see java.awt.peer.FileDialogPeer
Creates this toolkit's implementation ofClass Toolkit, LabelPeer createLabel(Label)Frame
using the specified peer interface. @param target the frame to be implemented. @return this toolkit's implementation ofFrame
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.Frame @see java.awt.peer.FramePeer
Creates this toolkit's implementation ofClass Toolkit, ListPeer createList(List)Label
using the specified peer interface. @param target the label to be implemented. @return this toolkit's implementation ofLabel
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.Label @see java.awt.peer.LabelPeer
Creates this toolkit's implementation ofClass Toolkit, MenuPeer createMenu(Menu)List
using the specified peer interface. @param target the list to be implemented. @return this toolkit's implementation ofList
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.List @see java.awt.peer.ListPeer
Creates this toolkit's implementation ofClass Toolkit, MenuBarPeer createMenuBar(MenuBar)Menu
using the specified peer interface. @param target the menu to be implemented. @return this toolkit's implementation ofMenu
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.Menu @see java.awt.peer.MenuPeer
Creates this toolkit's implementation ofClass Toolkit, MenuItemPeer createMenuItem(MenuItem)MenuBar
using the specified peer interface. @param target the menu bar to be implemented. @return this toolkit's implementation ofMenuBar
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.MenuBar @see java.awt.peer.MenuBarPeer
Creates this toolkit's implementation ofClass Toolkit, PopupMenuPeer createPopupMenu(PopupMenu)MenuItem
using the specified peer interface. @param target the menu item to be implemented. @return this toolkit's implementation ofMenuItem
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.MenuItem @see java.awt.peer.MenuItemPeer
Creates this toolkit's implementation ofClass Toolkit, ScrollPanePeer createScrollPane(ScrollPane)PopupMenu
using the specified peer interface. @param target the popup menu to be implemented. @return this toolkit's implementation ofPopupMenu
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.PopupMenu @see java.awt.peer.PopupMenuPeer @since JDK1.1
Creates this toolkit's implementation ofClass Toolkit, ScrollbarPeer createScrollbar(Scrollbar)ScrollPane
using the specified peer interface. @param target the scroll pane to be implemented. @return this toolkit's implementation ofScrollPane
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.ScrollPane @see java.awt.peer.ScrollPanePeer @since JDK1.1
Creates this toolkit's implementation ofClass Toolkit, TextAreaPeer createTextArea(TextArea)Scrollbar
using the specified peer interface. @param target the scroll bar to be implemented. @return this toolkit's implementation ofScrollbar
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.Scrollbar @see java.awt.peer.ScrollbarPeer
Creates this toolkit's implementation ofClass Toolkit, TextFieldPeer createTextField(TextField)TextArea
using the specified peer interface. @param target the text area to be implemented. @return this toolkit's implementation ofTextArea
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.TextArea @see java.awt.peer.TextAreaPeer
Creates this toolkit's implementation ofClass Toolkit, WindowPeer createWindow(Window)TextField
using the specified peer interface. @param target the text field to be implemented. @return this toolkit's implementation ofTextField
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.TextField @see java.awt.peer.TextFieldPeer
Creates this toolkit's implementation ofClass Toolkit, Dimension getBestCursorSize(int, int)Window
using the specified peer interface. @param target the window to be implemented. @return this toolkit's implementation ofWindow
. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.Window @see java.awt.peer.WindowPeer
Returns the supported cursor dimension which is closest to the desired sizes. Systems which only support a single cursor size will return that size regardless of the desired sizes. Systems which don't support custom cursors will return a dimension of 0 0.Class Toolkit, ColorModel getColorModel()Note: if an image is used whose dimensions don't match a supported size (as returned by this method) the Toolkit implementation will attempt to resize the image to a supported size. Since converting low-resolution images is difficult no guarantees are made as to the quality of a cursor image which isn't a supported size. It is therefore recommended that this method be called and an appropriate image used so no image conversion is made. @param desiredWidth the preferred cursor width the component would like to use. @param desiredHeight the preferred cursor height the component would like to use. @return the closest matching supported cursor size or a dimension of 0 0 if the Toolkit implementation doesn't support custom cursors. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @since 1.2
Determines the color model of this toolkit's screen.Class Toolkit, Object getDesktopProperty(String)
ColorModel
is an abstract class that encapsulates the ability to translate between the pixel values of an image and its red green blue and alpha components.This toolkit method is called by the
getColorModel
method of theComponent
class. @return the color model of this toolkit's screen. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.image.ColorModel @see java.awt.Component#getColorModel
Class Toolkit, FontMetrics getFontMetrics(Font)obtainObtains a value for the specified desktop property. A desktop property is a uniquely named value for a resource that is Toolkit global in nature. Usually it also is an abstract representation for an underlying platform dependent desktop setting.
Gets the screen device metrics for rendering of the font. @param font a fontClass Toolkit, FontPeer getFontPeer(String, int).@return the screen metrics of the specified font in this toolkit.@deprecatedThis returns integer metricsAs of JDK versionfor1.2 replaced by thedefaultFont
methodscreengetLineMetrics
. @see java.awt.font.LineMetrics @see java.awt.Font#getLineMetrics @see java.awt.GraphicsEnvironment#getScreenDevices
Creates this toolkit's implementation ofClass Toolkit, Image getImage(String)Font
using the specified peer interface. @paramtargetname the font to be implemented.@param style the style of the font such asPLAIN
BOLD
ITALIC
or a combination @return this toolkit's implementation ofFont
.@see java.awt.Font @see java.awt.peer.FontPeer @see java.awt.GraphicsEnvironment#getAllFonts @deprecated see java.awt.GraphicsEnvironment#getAllFonts
Returns an image which gets pixel data from the specified file whose format can be either GIF JPEG or PNG. The underlying toolkit attempts to resolve multiple requests with the same filename to the same returned Image. Since the mechanism required to facilitate this sharing of Image objects may continue to hold onto images that are no longer of use for anClass Toolkit, Image getImage(URL)indefinateindefinite period of time developers are encouraged to implement their own caching of images by using the createImage variant wherever available. @param filename the name of a file containing pixel data in a recognized file format. @return an image which gets its pixel data from the specified file. @see #createImage(java.lang.String)
Returns an image which gets pixel data from the specified URL. The pixel data referenced by the specified URL must be in one of the following formats: GIF JPEG or PNG. The underlying toolkit attempts to resolve multiple requests with the same URL to the same returned Image. Since the mechanism required to facilitate this sharing of Image objects may continue to hold onto images that are no longer of use for anClass Toolkit, boolean getLockingKeyState(int)indefinateindefinite period of time developers are encouraged to implement their own caching of images by using the createImage variant wherever available. @param url the URL to use in fetching the pixel data. @return an image which gets its pixel data from the specified URL. @see #createImage(java.net.URL)
Returns whether the given locking key on the keyboard is currently in its "on" state. Valid key codes are VK_CAPS_LOCK VK_NUM_LOCK VK_SCROLL_LOCK and VK_KANA_LOCK @exception java.lang.IllegalArgumentException if keyCode
is not one of the valid key codes @exception java.lang.UnsupportedOperationException if the host system doesn't allow getting the state of this key programmatically or if the keyboard doesn't have this key @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @since 1.3
Class Toolkit, int getMaximumCursorColors()Returns the maximum number of colors the Toolkit supports in a custom cursor palette.Class Toolkit, int getMenuShortcutKeyMask()Note: if an image is used which has more colors in its palette than the supported maximum the Toolkit implementation will attempt to flatten the palette to the maximum. Since converting low-resolution images is difficult no guarantees are made as to the quality of a cursor image which has more colors than the system supports. It is therefore recommended that this method be called and an appropriate image used so no image conversion is made. @return the maximum number of colors or zero if custom cursors are not supported by this Toolkit implementation. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @since 1.2
Determines which modifier key is the appropriate accelerator key for menu shortcuts.Class Toolkit, PrintJob getPrintJob(Frame, String, JobAttributes, PageAttributes)Menu shortcuts which are embodied in the
MenuShortcut
class are handled by theMenuBar
class.By default this method returns
Event.CTRL_MASK
. Toolkit implementations should override this method if the Control key isn't the correct key for accelerators. @return the modifier mask on theEvent
class that is used for menu shortcuts on this toolkit. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.MenuBar @see java.awt.MenuShortcut @since JDK1.1
Gets aClass Toolkit, PrintJob getPrintJob(Frame, String, Properties)PrintJob
object which is the result of initiating a print operation on the toolkit's platform.Each actual implementation of this method should first check if there is a security manager installed. If there is the method should call the security manager's
checkPrintJobAccess
method to ensure initiation of a print operation is allowed. If the default implementation ofcheckPrintJobAccess
is used (that is that method is not overriden) then this results in a call to the security manager'scheckPermission
method with aRuntimePermission("queuePrintJob")
permission. @param frame the parent of the print dialog. May be null if and only if jobAttributes is not null and jobAttributes.getDialog() returns JobAttributes.DialogType.NONE or JobAttributes.DialogType.COMMON. @param jobtitle the title of the PrintJob. A null title is equivalent to "". @param jobAttributes a set of job attributes which will control the PrintJob. The attributes will be updated to reflect the user's choices as outlined in the JobAttributes documentation. May be null. @param pageAttributes a set of page attributes which will control the PrintJob. The attributes will be applied to every page in the job. The attributes will be updated to reflect the user's choices as outlined in the PageAttributes documentation. May be null. @return aPrintJob
object ornull
if the user cancelled the print job. @throws NullPointerException if frame is null and either jobAttributes is null or jobAttributes.getDialog() returns JobAttributes.DialogType.NATIVE. @throws IllegalArgumentException if pageAttributes specifies differing cross feed and feed resolutions. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true. @throws SecurityException if this thread is not allowed to initiate a print job request or if jobAttributes specifies print to file and this thread is not allowed to access the file system @see java.awt.PrintJob @see java.awt.GraphicsEnvironment#isHeadless @see java.lang.RuntimePermission @see java.awt.JobAttributes @see java.awt.PageAttributes @since 1.3
Gets aClass Toolkit, int getScreenResolution()PrintJob
object which is the result of initiating a print operation on the toolkit's platform.Each actual implementation of this method should first check if there is a security manager installed. If there is the method should call the security manager's
checkPrintJobAccess
method to ensure initiation of a print operation is allowed. If the default implementation ofcheckPrintJobAccess
is used (that is that method is not overriden) then this results in a call to the security manager'scheckPermission
method with aRuntimePermission("queuePrintJob")
permission. @param frame the parent of the print dialog. May not be null. @param jobtitle the title of the PrintJob. A null title is equivalent to "". @param props a Properties object containing zero or more properties. Properties are not standardized and are not consistent across implementations. Because of this PrintJobs which require job and page control should use the version of this function which takes JobAttributes and PageAttributes objects. This object may be updated to reflect the user's job choices on exit. May be null. @return aPrintJob
object ornull
if the user cancelled the print job. @throws NullPointerException if frame is null. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true. @throws SecurityException if this thread is not allowed to initiate a print job request @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.PrintJob @see java.lang.RuntimePermission @since JDK1.1
Returns the screen resolution in dots-per-inch. @return this toolkit's screen resolution in dots-per-inch. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadlessClass Toolkit, Dimension getScreenSize()
Gets the size of the screen. On systems with multiple displays the primary display is used. Multi-screen aware display dimensions are available fromClass Toolkit, Clipboard getSystemClipboard()GraphicsConfiguration
andGraphicsDevice
. @return the size of this toolkit's screen in pixels. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsConfiguration#getBounds @see java.awt.GraphicsEnvironment#getDisplayMode @see java.awt.GraphicsEnvironment#isHeadless
Gets the singleton instance of the system Clipboard which interfaces with clipboard facilities provided by the native platform. This clipboard enables data transfer between Java programs and native applications which use native clipboard facilities.Class Toolkit, void loadSystemColors(int[])In addition to any and all formats specified in the flavormap.properties file or other file specified by the
AWT.DnD.flavorMapFileURL
Toolkit property text returned by the system Clipboard'sgetTransferData()
method is available in the following flavors:As with
- DataFlavor.stringFlavor
- DataFlavor.plainTextFlavor (deprecated)
java.awt.datatransfer.StringSelection
if the requested flavor isDataFlavor.plainTextFlavor
or an equivalent flavor a Reader is returned. Note: The behavior of the system Clipboard'sgetTransferData()
method forDataFlavor.plainTextFlavor
and equivalent DataFlavors is inconsistent with the definition ofDataFlavor.plainTextFlavor
. Because of this support forDataFlavor.plainTextFlavor
and equivalent flavors is deprecated.Each actual implementation of this method should first check if there is a security manager installed. If there is the method should call the security manager's
checkSystemClipboardAccess
method to ensure it's ok to to access the system clipboard. If the default implementation ofcheckSystemClipboardAccess
is used (that is that method is not overriden) then this results in a call to the security manager'scheckPermission
method with anAWTPermission("accessClipboard")
permission. @return the system Clipboard @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.awt.datatransfer.Clipboard @see java.awt.datatransfer.StringSelection @see java.awt.datatransfer.DataFlavor.stringFlavor @see java.awt.datatransfer.DataFlavor.plainTextFlavor @see java.io.Reader @see java.awt.AWTPermission @since JDK1.1
Fills in the integer array that is supplied as an argument with the current system color values. @param an integer array. @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @since JDK1.1Class Toolkit, Map mapInputMethodHighlight(InputMethodHighlight)
Returns a map of visual attributes for the abstract level description of the given input method highlight or null if no mapping is found. The style field of the input method highlight is ignored. The map returned is unmodifiable. @param highlight input method highlight @return style attribute map orClass Toolkit, void removeAWTEventListener(AWTEventListener)null
@exception HeadlessException ifGraphicsEnvironment.isHeadless
returns true @see java.awt.GraphicsEnvironment#isHeadless @since 1.3
Removes an AWTEventListener from receiving dispatched AWTEvents.Class Toolkit, void removePropertyChangeListener(String, PropertyChangeListener)First if there is a security manager its
checkPermission
method is called with anAWTPermission("listenToAllAWTEvents")
permission. This may result in a SecurityException.Note: event listener use is not recommended for normal application use but are intended solely to support special purpose facilities including support for accessibility event record/playback and diagnostic tracing. If listener is null no exception is thrown and no action is performed. @param listener the event listener. @throws SecurityException if a security manager exists and its
checkPermission
method doesn't allow the operation. @seejava.awt.event.AWTEventListener#addAWTEventListener @see #getAWTEventListeners @see SecurityManager#checkPermission @see java.awt.Toolkit#addAWTEventListenerAWTEvent @see java.awt.AWTEventAWTPermission @seeSecurityManager#checkPermissionjava.awt.event.AWTEventListener @see java.awt.AWTPermissionevent.AWTEventListenerProxy @since 1.2
Class Toolkit, void setDesktopProperty(String, Object)removeRemoves the specified property change listener for the named desktop property. If pcl is null no exception is thrown and no action is performed. @param name The name of the property to remove @param pcl The property change listener @since 1.2
Class Toolkit, void setLockingKeyState(int, boolean)setSets the named desktop property to the specified value andfirefires a property change event to notify any listeners that the value has changed.
Sets the state of the given locking key on the keyboard. Valid key codes are VK_CAPS_LOCK VK_NUM_LOCK VK_SCROLL_LOCK and VK_KANA_LOCKDepending on the platform setting the state of a locking key may involve event processing and therefore may not be immediately observable through getLockingKeyState. @exception java.lang.IllegalArgumentException if
keyCode
is not one of the valid key codes @exception java.lang.UnsupportedOperationException if the host system doesn't allow setting the state of this key programmatically or if the keyboard doesn't have this key @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true @see java.awt.GraphicsEnvironment#isHeadless @since 1.3
TheTransparency
interface defines the common transparency modes for implementing classes. @version 1.17 0218 12/0203/0001
AWindow
object is a top-level window with no borders and no menubar. The default layout for a window isBorderLayout
.A window must have either a frame dialog or another window defined as its owner when it's constructed.
In a multi-screen environment you can create a
Window
on a different screen device by constructing theWindow
with GraphicsConfiguration) TheGraphicsConfiguration
object is one of theGraphicsConfiguration
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 device 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.
![]()
In such an environment when calling
setLocation
you must pass a virtual coordinate to this method. Similarly callinggetLocationOnScreen
on aWindow
returns virtual device coordinates. Call thegetBounds
method of aGraphicsConfiguration
to find its origin in the virtual coordinate system.The following code sets the location of a
Window
at (10 10) relative to the origin of the physical screen of the correspondingGraphicsConfiguration
. If the bounds of theGraphicsConfiguration
is not taken into account theWindow
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 specifiedGraphicsConfiguration
.Window w = new Window(Window owner GraphicsConfiguration gc); Rectangle bounds = gc.getBounds(); w.setLocation(10 + bounds.x 10 + bounds.y);Windows are capable of generating the following
window eventsWindowEvents: WindowOpened WindowClosed WindowGainedFocus WindowLostFocus. @version 1.138 06169 12/1503/01 @author Sami Shaio @author Arthur van Hoff @see WindowEvent @see #addWindowListener @see java.awt.BorderLayout @since JDK1.0
Get the role of this object. @return an instance of AccessibleRole describing the role of the object @see javax.accessibility.AccessibleRoleClass Window.AccessibleAWTWindow, AccessibleStateSet getAccessibleStateSet()
Get the state of this object. @return an instance of AccessibleStateSet containing the current state set of the object @see javax.accessibility.AccessibleState
Constructs a new invisible window with the specifiedClass Window, constructor Window(Window)Frame
as its owner. The Window will not be focusable unless its owner is showing on the screen.If there is a security manager this method first calls the security manager's
checkTopLevelWindow
method withthis
as its argument to determine whether or not the window must be displayed with a warning banner. @param owner theFrame
to act as owner @exception IllegalArgumentException if theowner
'sis not from a screen device
gcGraphicsConfiguration.@exception java.lang.IllegalArgumentException ifowner
isnull
; this exception is always thrown whenGraphicsEnvironment.isHeadless
returns true @see java.awt.GraphicsEnvironment#isHeadless @see java.lang.SecurityManager#checkTopLevelWindow @see #isShowing
Constructs a new invisible window with the specifiedClass Window, constructor Window(Window, GraphicsConfiguration)Window
as its owner. The Window will not be focusable unless its nearest owning Frame or Dialog is showing on the screen.If there is a security manager this method first calls the security manager's
checkTopLevelWindow
method withthis
as its argument to determine whether or not the window must be displayed with a warning banner. @param owner theWindow
to act as owner @exception IllegalArgumentException if theowner
'sGraphicsConfiguration
is not from a screen device @exception java.lang.IllegalArgumentException ifowner
isnull
. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true. @see java.awt.GraphicsEnvironment#isHeadless @see java.lang.SecurityManager#checkTopLevelWindow @see #isShowing @since 1.2
Constructs a new invisible window with the specified window as its owner and aClass Window, void addWindowListener(WindowListener)GraphicsConfiguration
of a screen device. The Window will not be focusable unless its nearest owning Frame or Dialog is showing on the screen.If there is a security manager this method first calls the security manager's
checkTopLevelWindow
method withthis
as its argument to determine whether or not the window must be displayed with a warning banner. @param owner the window to act as owner @param gc theGraphicsConfiguration
of the target screen device. If; ifgc
isnull
the system defaultGraphicsConfiguration
is assumed.@throws IllegalArgumentException ifowner
isnull
.@throws IllegalArgumentException ifgc
is not from a screen device; this exception is always thrown whenGraphicsEnvironment
.isHeadless returnstrue
@see java.langawt.SecurityManagerGraphicsEnvironment#checkTopLevelWindowisHeadless @see java.awtlang.SecurityManager#checkTopLevelWindow @see GraphicsConfiguration#getBounds @see #isShowing @since 1.3
Adds the specified window listener to receive window events from this window. If l is null no exception is thrown and no action is performed. @param l the window listener @see #removeWindowListener @see #getWindowListenersClass Window, void applyResourceBundle(ResourceBundle)
Class Window, void applyResourceBundle(String)ApplyApplies thesettings in the given ResourceBundle to this Window. Currently this applies theResourceBundle's ComponentOrientation to this Window and all components contained within it. @seejava.awt.ComponentOrientation @since 1.2 @deprecated As of J2SE 1.4 replaced by Component.applyComponentOrientation
Class Window, void dispose()LoadLoads the ResourceBundle with the given name using the default locale andapply its settings to this window. Currently thisappliesthe ResourceBundle'sits ComponentOrientation to this Window and all components contained within it. @seejava.awt.ComponentOrientation @since 1.2 @deprecated As of J2SE 1.4 replaced by Component.applyComponentOrientation
Releases all of the native screen resources used by this Window its subcomponents and all of its owned children. That is the resources for these Components will be destroyed any memory they consume will be returned to the OS and they will be marked as undisplayable.Class Window, Component getFocusOwner()The Window and its subcomponents can be made displayable again by rebuilding the native resources with a subsequent call to
@see Component#isDisplayable @seepack
orshow
. The states of the recreated Window and its subcomponents will be identical to the states of these objects at the point where the Window was disposed (not accounting for additional modifcations between those actions).Window#pack @seeWindow#show
Returns the childClass Window, EventListener[] getListeners(Class)componentComponent of this Windowwhichthat has focus ifand only ifthis Window isactivefocused; returns null otherwise. @return thecomponentchild Component with focus or null ifnothis Windowchildren have focusis not focusedassigned@seeto#getMostRecentFocusOwnerthem.@see #isFocused
Class Window, Toolkit getToolkit()ReturnReturns an array of all thelistenersobjectsthat were addedcurrently registered astoFooListener
sthe Windowupon thiswithWindow
.addXXXListener()FooListener
swhere XXX isare registered using thenameaddFooListener
ofmethod.You can specify
thelistenerType
argument.For example to get all ofwith a class literal such astheFooListener.class
.WindowListener(s)Forforexampletheyou cangivenquery aWindow
w
onefor its window listeners with thewould writefollowing code:If no suchWindowListener[] wls = (WindowListener[])(w.getListeners(WindowListener.class));listenerlisteners existlist exists thenthis method returns an empty arrayis returned. @param listenerTypeTypethe type of listeners requested; this parameter should specify an interface that descends fromjava.util.EventListener
@returnallan array oftheall objects registered asFooListener
s on this window or an empty array if no such listenersof the specifiedhave been addedtype@exceptionsupported byClassCastException ifthislistenerType
doesn't specify a class or interface that implementsjava.util.EventListener
text@seefield#getWindowListeners @since 1.3
Returns the toolkit of this frame. @return the toolkit of this window. @seeClass Window, void hide()java.awt.Toolkit @seejava.awt.Toolkit#getDefaultToolkit()@seejava.awt.Component#getToolkit()
Hide this Window its subcomponents and all of its owned children. The Window and its subcomponents can be made visible again with a call toClass Window, boolean isShowing()show
. @seeWindow#show @seeWindow#dispose
Checks if this Window is showing on screen. @seeClass Window, void processEvent(AWTEvent)java.awt.Component#setVisible(boolean)
Processes events on this window. If the event is anClass Window, void processWindowEvent(WindowEvent)WindowEvent
it invokes theprocessWindowEvent
method else it invokes its superclass'sprocessEvent
.Note that if the event parameter is
null
the behavior is unspecified and may result in an exception. @param e the event
Processes window events occurring on this window by dispatching them to any registered WindowListener objects. NOTE: This method will not be called unless window events are enabled for this component; this happens when one of the following occurs:Class Window, void removeWindowListener(WindowListener)a)
- A WindowListener object is registered via
addWindowListener
()b)- Window events are enabled via
enableEvents
()@seeComponent#enableEventsNote that if the event parameter is
null
the behavior is unspecified and may result in an exception. @param e the window event @see Component#enableEvents
Removes the specified window listener so that it no longer receives window events from this window. If l is null no exception is thrown and no action is performed. @param l the window listener @see #addWindowListener @see #getWindowListenersClass Window, void setCursor(Cursor)
Set the cursor image to a specified cursor. @paramClass Window, void show()cursor
One of the constants defined by theCursor
class. If this parameter is null then the cursor for this window will be set to the type Cursor.DEFAULT_CURSOR. @seejava.awt.Component#getCursor @seejava.awt.Cursor @since JDK1.1
Makes the Window visible. If the Window and/or its owner are not yet displayable both are made displayable. The Window will be validated prior to being made visible. If the Window is already visible this will bring the Window to the front. @seeClass Window, void toBack()java.awt.Component#isDisplayable @seejava.awt.Window#toFront @seejava.awt.Component#setVisible
Class Window, void toFront()SendsIf thiswindowWindow is visible sends this Window to the back and may cause it to lose focus or activation if it is the focused or active Window.Places this
windowWindow at the bottom of the stacking order andmakes theshowscorresponding adjustment toit behind any other Windows in this VM. No action will take place is this Window is not visible. Some platforms do not allow Windows which are owned by other Windows to appear below their owners. Every attempt will be made to move this Window as low as possible in the stacking order; however developers should not assume that this method will move this Window below all other windows in every situation.@seeBecause of variations in native windowing
javasystems no guarantees about changes to the focused and active Windows can be made. Developers must never assume that this Window is no longer the focused or active Window until this Window receives a WINDOW_LOST_FOCUS or WINDOW_DEACTIVATED event.awtOn platforms where the top-most window is the focused window this method will probably cause this Window to lose focus. In that case the next highest focusable Window in this VM will receive focus. On platforms where the stacking order does not typically affect the focused window this method will probably leave the focused and active Windows unchanged. @see #toFront
BringsIf thiswindowWindow is visible brings this Window to the front and may make it the focused Window.Places this
windowWindow at the top of the stacking order and shows it in front of any other Windows in this VM. No action will take place is this Window is not visible. Some platforms do not allow Windows which own other Windows to appear on top of those owned Windows. Some platforms may not permit this VM to place its Windows above windows of native applications or Windows of other VMs. This permission may depend on whether a Window in this VM is already focused. Every attempt will be made to move this Window as high as possible in the stacking order; however developers should not assume that this method will move this Window above all other windows in every situation.@seeBecause of variations in native windowing systems no guarantees about changes to
javathe focused and active Windows can be made. Developers must never assume that this Window is the focused or active Window until this Window receives a WINDOW_GAINED_FOCUS or WINDOW_ACTIVATED event. On platforms where the top-most window is the focused window this method will probably focus this Window if it is not already focused. On platforms where the stacking order does not typically affect the focused window this method will probably leave the focused and active Windows unchanged.awtIf this method causes this Window to be focused and this Window is a Frame or a Dialog it will also become activated
. If this Window is focused but it is not a Frame or a Dialog then the first Frame or Dialog that is an owner of this Window will be activated. @see #toBack