java.awt

Class Component

Implemented Interfaces:
ImageObserver, MenuContainer, Serializable
Known Direct Subclasses:
Button, Canvas, Checkbox, Choice, Container, ImageViewer, Label, List, Scrollbar, TextComponent

public abstract class Component
extends Object
implements ImageObserver, MenuContainer, Serializable

The root of all evil. All graphical representations are subclasses of this giant class, which is designed for screen display and user interaction. This class can be extended directly to build a lightweight component (one not associated with a native window); lightweight components must reside inside a heavyweight window.

This class is Serializable, which has some big implications. A user can save the state of all graphical components in one VM, and reload them in another. Note that this class will only save Serializable listeners, and ignore the rest, without causing any serialization exceptions. However, by making a listener serializable, and adding it to another element, you link in that entire element to the state of this component. To get around this, use the idiom shown in the example below - make listeners non-serializable in inner classes, rather than using this object itself as the listener, if external objects do not need to save the state of this object.

 import java.awt.*;
 import java.awt.event.*;
 import java.io.Serializable;
 class MyApp implements Serializable
 {
   BigObjectThatShouldNotBeSerializedWithAButton bigOne;
   // Serializing aButton will not suck in an instance of MyApp, with its
   // accompanying field bigOne.
   Button aButton = new Button();
   class MyActionListener implements ActionListener
   {
     public void actionPerformed(ActionEvent e)
     {
       System.out.println("Hello There");
     }
   }
   MyApp()
   {
     aButton.addActionListener(new MyActionListener());
   }
 }
 

Status: Incomplete. The event dispatch mechanism is implemented. All other methods defined in the J2SE 1.3 API javadoc exist, but are mostly incomplete or only stubs; except for methods relating to the Drag and Drop, Input Method, and Accessibility frameworks: These methods are present but commented out.

Since:
1.0
See Also:
Serialized Form

Nested Class Summary

protected abstract class
Component.AccessibleAWTComponent
This class provides accessibility support for subclasses of container.
protected class
Component.BltBufferStrategy
This class provides support for blitting offscreen surfaces to a component.
protected class
Component.FlipBufferStrategy
This class provides support for flipping component buffers.

Field Summary

static float
BOTTOM_ALIGNMENT
Constant returned by the getAlignmentY method to indicate that the component wishes to be aligned to the bottom relative to other components.
static float
CENTER_ALIGNMENT
Constant returned by the getAlignmentY and getAlignmentX methods to indicate that the component wishes to be aligned to the centdisper relative to other components.
static float
LEFT_ALIGNMENT
Constant returned by the getAlignmentX method to indicate that the component wishes to be aligned to the left relative to other components.
static float
RIGHT_ALIGNMENT
Constant returned by the getAlignmentX method to indicate that the component wishes to be aligned to the right relative to other components.
static float
TOP_ALIGNMENT
Constant returned by the getAlignmentY method to indicate that the component wishes to be aligned to the top relative to other components.

Fields inherited from interface java.awt.image.ImageObserver

ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH

Constructor Summary

Component()
Default constructor for subclasses.

Method Summary

boolean
action(Event evt, Object what)
Deprecated. in classes which support actions, use processActionEvent(ActionEvent) instead
void
add(PopupMenu popup)
Adds the specified popup menu to this component.
void
addComponentListener(ComponentListener listener)
Adds the specified listener to this component.
void
addFocusListener(FocusListener listener)
Adds the specified listener to this component.
void
addHierarchyBoundsListener(HierarchyBoundsListener listener)
Adds the specified listener to this component.
void
addHierarchyListener(HierarchyListener listener)
Adds the specified listener to this component.
void
addInputMethodListener(InputMethodListener listener)
Adds the specified listener to this component.
void
addKeyListener(KeyListener listener)
Adds the specified listener to this component.
void
addMouseListener(MouseListener listener)
Adds the specified listener to this component.
void
addMouseMotionListener(MouseMotionListener listener)
Adds the specified listener to this component.
void
addMouseWheelListener(MouseWheelListener listener)
Adds the specified listener to this component.
void
addNotify()
Called when the parent of this Component is made visible or when the Component is added to an already visible Container and needs to be shown.
void
addPropertyChangeListener(PropertyChangeListener listener)
Adds the specified property listener to this component.
void
addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
Adds the specified property listener to this component.
void
applyComponentOrientation(ComponentOrientation o)
Sets the text layout orientation of this component.
boolean
areFocusTraversalKeysSet(int id)
Tests whether the focus traversal keys for a given action are explicitly set or inherited.
Rectangle
bounds()
Deprecated. use getBounds() instead
int
checkImage(Image image, int width, int height, ImageObserver observer)
Returns the status of the loading of the specified image.
int
checkImage(Image image, ImageObserver observer)
Returns the status of the loading of the specified image.
protected AWTEvent
coalesceEvents(AWTEvent existingEvent, AWTEvent newEvent)
This is called by the EventQueue if two events with the same event id and owner component are queued.
boolean
contains(int x, int y)
Tests whether or not the specified point is contained within this component.
boolean
contains(Point p)
Tests whether or not the specified point is contained within this component.
Image
createImage(int width, int height)
Creates an image with the specified width and height for use in double buffering.
Image
createImage(ImageProducer producer)
Creates an image from the specified producer.
VolatileImage
createVolatileImage(int width, int height)
Creates an image with the specified width and height for use in double buffering.
VolatileImage
createVolatileImage(int width, int height, ImageCapabilities caps)
Creates an image with the specified width and height for use in double buffering.
void
deliverEvent(Event e)
Deprecated. use (AWTEvent) instead
void
disable()
Deprecated. use setEnabled(boolean) instead
protected void
disableEvents(long eventsToDisable)
Disables the specified events.
void
dispatchEvent(AWTEvent e)
Forwards AWT events to processEvent() if:
  • Events have been enabled for this type of event via enableEvents()
  • There is at least one registered listener for this type of event
void
doLayout()
Calls the layout manager to re-layout the component.
void
enable()
Deprecated. use setEnabled(boolean) instead
void
enable(boolean enabled)
Deprecated. use setEnabled(boolean) instead
protected void
enableEvents(long eventsToEnable)
Enables the specified events.
void
enableInputMethods(boolean enable)
Enables or disables input method support for this component.
extends EventListener> T[] getListeners(Class listenerType)
Returns all registered EventListeners of the given listenerType.
protected void
firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
Report a change in a bound property to any registered property listeners.
void
firePropertyChange(String propertyName, byte oldValue, byte newValue)
Report a change in a bound property to any registered property listeners.
void
firePropertyChange(String propertyName, char oldValue, char newValue)
Report a change in a bound property to any registered property listeners.
void
firePropertyChange(String propertyName, double oldValue, double newValue)
Report a change in a bound property to any registered property listeners.
void
firePropertyChange(String propertyName, float oldValue, float newValue)
Report a change in a bound property to any registered property listeners.
protected void
firePropertyChange(String propertyName, int oldValue, int newValue)
Report a change in a bound property to any registered property listeners.
protected void
firePropertyChange(String propertyName, Object oldValue, Object newValue)
Report a change in a bound property to any registered property listeners.
void
firePropertyChange(String propertyName, long oldValue, long newValue)
Report a change in a bound property to any registered property listeners.
void
firePropertyChange(String propertyName, short oldValue, short newValue)
Report a change in a bound property to any registered property listeners.
AccessibleContext
getAccessibleContext()
Returns the accessibility framework context of this class.
float
getAlignmentX()
Returns the preferred horizontal alignment of this component.
float
getAlignmentY()
Returns the preferred vertical alignment of this component.
Color
getBackground()
Returns this component's background color.
Rectangle
getBounds()
Returns a bounding rectangle for this component.
Rectangle
getBounds(Rectangle r)
Returns the bounds of this component.
ColorModel
getColorModel()
Returns the color model of the device this componet is displayed on.
Component
getComponentAt(int x, int y)
Returns the component occupying the position (x,y).
Component
getComponentAt(Point p)
Returns the component occupying the position (x,y).
ComponentListener[]
getComponentListeners()
Returns an array of all specified listeners registered on this component.
ComponentOrientation
getComponentOrientation()
Determines the text layout orientation used by this component.
Cursor
getCursor()
Returns the cursor for this component.
DropTarget
getDropTarget()
Gets the associated drag-and-drop target, if there is one.
Container
getFocusCycleRootAncestor()
Returns the root container that owns the focus cycle where this component resides.
FocusListener[]
getFocusListeners()
Returns an array of all specified listeners registered on this component.
Set
getFocusTraversalKeys(int id)
Returns the set of keys for a given focus traversal action, as defined in setFocusTraversalKeys.
boolean
getFocusTraversalKeysEnabled()
Check whether or not focus traversal keys are enabled on this Component.
Font
getFont()
Returns the font in use for this component.
FontMetrics
getFontMetrics(Font font)
Returns the font metrics for the specified font in this component.
Color
getForeground()
Returns this component's foreground color.
Graphics
getGraphics()
Returns a graphics object for this component.
GraphicsConfiguration
getGraphicsConfiguration()
Returns the graphics configuration of this component, if there is one.
int
getHeight()
Gets the height of the component.
HierarchyBoundsListener[]
getHierarchyBoundsListeners()
Returns an array of all specified listeners registered on this component.
HierarchyListener[]
getHierarchyListeners()
Returns an array of all specified listeners registered on this component.
boolean
getIgnoreRepaint()
Test whether paint events from the operating system are ignored.
InputContext
getInputContext()
Gets the input context of this component, which is inherited from the parent unless this is overridden.
InputMethodListener[]
getInputMethodListeners()
Returns an array of all specified listeners registered on this component.
InputMethodRequests
getInputMethodRequests()
Returns the input method request handler, for subclasses which support on-the-spot text input.
KeyListener[]
getKeyListeners()
Returns an array of all specified listeners registered on this component.
Locale
getLocale()
Returns the locale for this component.
Point
getLocation()
Returns the location of this component's top left corner relative to its parent component.
Point
getLocation(Point p)
Returns the location of this component.
Point
getLocationOnScreen()
Returns the location of this component's top left corner in screen coordinates.
Dimension
getMaximumSize()
Returns the component's maximum size.
Dimension
getMinimumSize()
Returns the component's minimum size.
MouseListener[]
getMouseListeners()
Returns an array of all specified listeners registered on this component.
MouseMotionListener[]
getMouseMotionListeners()
Returns an array of all specified listeners registered on this component.
Point
getMousePosition()
Returns the mouse pointer position relative to this Component's top-left corner.
MouseWheelListener[]
getMouseWheelListeners()
Returns an array of all specified listeners registered on this component.
String
getName()
Returns the name of this component.
Container
getParent()
Returns the parent of this component.
ComponentPeer
getPeer()
Deprecated. user programs should not directly manipulate peers; use isDisplayable() instead
Dimension
getPreferredSize()
Returns the component's preferred size.
PropertyChangeListener[]
getPropertyChangeListeners()
Returns an array of all specified listeners registered on this component.
PropertyChangeListener[]
getPropertyChangeListeners(String property)
Returns an array of all specified listeners on the named property that are registered on this component.
Dimension
getSize()
Returns the size of this object.
Dimension
getSize(Dimension d)
Returns the size of this component.
Toolkit
getToolkit()
Returns the toolkit in use for this component.
Object
getTreeLock()
Returns the object used for synchronization locks on this component when performing tree and layout functions.
int
getWidth()
Gets the width of the component.
int
getX()
Gets the x coordinate of the upper left corner.
int
getY()
Gets the y coordinate of the upper left corner.
boolean
gotFocus(Event evt, Object what)
Deprecated. use processFocusEvent(FocusEvent) instead
boolean
handleEvent(Event evt)
Deprecated. use processEvent(AWTEvent) instead
boolean
hasFocus()
Tests if this component is the focus owner.
void
hide()
Deprecated. use setVisible(boolean) instead
boolean
imageUpdate(Image img, int flags, int x, int y, int w, int h)
Called when an image has changed so that this component is repainted.
boolean
inside(int x, int y)
Deprecated. use contains(int,int) instead
void
invalidate()
Invalidates this component and all of its parent components.
boolean
isBackgroundSet()
Tests if the background was explicitly set, or just inherited from the parent.
boolean
isCursorSet()
Tests if the cursor was explicitly set, or just inherited from the parent.
boolean
isDisplayable()
Tests if the component is displayable.
boolean
isDoubleBuffered()
Checks if this image is painted to an offscreen image buffer that is later copied to screen (double buffering reduces flicker).
boolean
isEnabled()
Tests whether or not this component is enabled.
boolean
isFocusCycleRoot(Container c)
Tests if the container is the ancestor of the focus cycle that this component belongs to.
boolean
isFocusOwner()
Tests if this component is the focus owner.
boolean
isFocusTraversable()
Deprecated. use isFocusable() instead
boolean
isFocusable()
Tests if this component can receive focus.
boolean
isFontSet()
Tests if the font was explicitly set, or just inherited from the parent.
boolean
isForegroundSet()
Tests if the foreground was explicitly set, or just inherited from the parent.
boolean
isLightweight()
Return whether the component is lightweight.
boolean
isMaximumSizeSet()
Returns true if the current maximum size is not null and was set by a call to setMaximumSize(Dimension), otherwise returns false.
boolean
isMinimumSizeSet()
Returns true if the current minimum size is not null and was set by a call to setMinimumSize(Dimension), otherwise returns false.
boolean
isOpaque()
Tests if this component is opaque.
boolean
isPreferredSizeSet()
Returns true if the current preferred size is not null and was set by a call to setPreferredSize(Dimension), otherwise returns false.
boolean
isShowing()
Tests whether or not this component is actually being shown on the screen.
boolean
isValid()
Tests whether or not this component is valid.
boolean
isVisible()
Tests whether or not this component is visible.
boolean
keyDown(Event evt, int key)
Deprecated. use processKeyEvent(KeyEvent) instead
boolean
keyUp(Event evt, int key)
Deprecated. use processKeyEvent(KeyEvent) instead
void
layout()
Deprecated. use doLayout() instead
void
list()
Prints a listing of this component to System.out.
void
list(PrintStream out)
Prints a listing of this component to the specified print stream.
void
list(PrintStream out, int indent)
Prints a listing of this component to the specified print stream, starting at the specified indentation point.
void
list(PrintWriter out)
Prints a listing of this component to the specified print writer.
void
list(PrintWriter out, int indent)
Prints a listing of this component to the specified print writer, starting at the specified indentation point.
Component
locate(int x, int y)
Deprecated. use getComponentAt(int,int) instead
Point
location()
Deprecated. use getLocation() instead
boolean
lostFocus(Event evt, Object what)
Deprecated. use processFocusEvent(FocusEvent) instead
Dimension
minimumSize()
Deprecated. use getMinimumSize() instead
boolean
mouseDown(Event evt, int x, int y)
Deprecated. use processMouseEvent(MouseEvent) instead
boolean
mouseDrag(Event evt, int x, int y)
Deprecated. use processMouseMotionEvent(MouseEvent) instead
boolean
mouseEnter(Event evt, int x, int y)
Deprecated. use processMouseEvent(MouseEvent) instead
boolean
mouseExit(Event evt, int x, int y)
Deprecated. use processMouseEvent(MouseEvent) instead
boolean
mouseMove(Event evt, int x, int y)
Deprecated. use processMouseMotionEvent(MouseEvent) instead
boolean
mouseUp(Event evt, int x, int y)
Deprecated. use processMouseEvent(MouseEvent) instead
void
move(int x, int y)
Deprecated. use setLocation(int,int) instead
void
nextFocus()
Deprecated. use () instead
void
paint(Graphics g)
Paints this component on the screen.
void
paintAll(Graphics g)
Paints this entire component, including any sub-components.
protected String
paramString()
Returns a debugging string representing this component.
boolean
postEvent(Event e)
Deprecated. use dispatchEvent(AWTEvent) instead
Dimension
preferredSize()
Deprecated. use getPreferredSize() instead
boolean
prepareImage(Image image, int width, int height, ImageObserver observer)
Prepares the specified image for rendering on this component at the specified scaled width and height
boolean
prepareImage(Image image, ImageObserver observer)
Prepares the specified image for rendering on this component.
void
print(Graphics g)
Prints this component.
void
printAll(Graphics g)
Prints this component, including all sub-components.
protected void
processComponentEvent(ComponentEvent e)
Called when a component event is dispatched and component events are enabled.
protected void
processEvent(AWTEvent e)
Processes the specified event.
protected void
processFocusEvent(FocusEvent e)
Called when a focus event is dispatched and component events are enabled.
protected void
processHierarchyBoundsEvent(HierarchyEvent e)
Called when a hierarchy bounds event is dispatched and component events are enabled.
protected void
processHierarchyEvent(HierarchyEvent e)
Called when a hierarchy change event is dispatched and component events are enabled.
protected void
processInputMethodEvent(InputMethodEvent e)
Called when an input method event is dispatched and component events are enabled.
protected void
processKeyEvent(KeyEvent e)
Called when a key event is dispatched and component events are enabled.
protected void
processMouseEvent(MouseEvent e)
Called when a regular mouse event is dispatched and component events are enabled.
protected void
processMouseMotionEvent(MouseEvent e)
Called when a mouse motion event is dispatched and component events are enabled.
protected void
processMouseWheelEvent(MouseWheelEvent e)
Called when a mouse wheel event is dispatched and component events are enabled.
void
remove(MenuComponent popup)
Removes the specified popup menu from this component.
void
removeComponentListener(ComponentListener listener)
Removes the specified listener from the component.
void
removeFocusListener(FocusListener listener)
Removes the specified listener from the component.
void
removeHierarchyBoundsListener(HierarchyBoundsListener listener)
Removes the specified listener from the component.
void
removeHierarchyListener(HierarchyListener listener)
Removes the specified listener from the component.
void
removeInputMethodListener(InputMethodListener listener)
Removes the specified listener from the component.
void
removeKeyListener(KeyListener listener)
Removes the specified listener from the component.
void
removeMouseListener(MouseListener listener)
Removes the specified listener from the component.
void
removeMouseMotionListener(MouseMotionListener listener)
Removes the specified listener from the component.
void
removeMouseWheelListener(MouseWheelListener listener)
Removes the specified listener from the component.
void
removeNotify()
Called to inform this component is has been removed from its container.
void
removePropertyChangeListener(PropertyChangeListener listener)
Removes the specified property listener from the component.
void
removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
Removes the specified property listener on a particular property from the component.
void
repaint()
Repaint this entire component.
void
repaint(int x, int y, int w, int h)
Repaints the specified rectangular region within this component.
void
repaint(long tm)
Repaint this entire component.
void
repaint(long tm, int x, int y, int width, int height)
Repaints the specified rectangular region within this component.
void
requestFocus()
Request that this Component be given the keyboard input focus and that its top-level ancestor become the focused Window.
protected boolean
requestFocus(boolean temporary)
Request that this Component be given the keyboard input focus and that its top-level ancestor become the focused Window.
boolean
requestFocusInWindow()
Request that this component be given the keyboard input focus, if its top-level ancestor is the currently focused Window.
protected boolean
requestFocusInWindow(boolean temporary)
Request that this component be given the keyboard input focus, if its top-level ancestor is the currently focused Window.
void
reshape(int x, int y, int width, int height)
Deprecated. use setBounds(int,int,int,int) instead
void
resize(int width, int height)
Deprecated. use setSize(int,int) instead
void
resize(Dimension d)
Deprecated. use setSize(Dimension) instead
void
setBackground(Color c)
Sets this component's background color to the specified color.
void
setBounds(int x, int y, int w, int h)
Sets the bounding rectangle for this component to the specified values.
void
setBounds(Rectangle r)
Sets the bounding rectangle for this component to the specified rectangle.
void
setComponentOrientation(ComponentOrientation o)
Sets the text layout orientation of this component.
void
setCursor(Cursor cursor)
Sets the cursor for this component to the specified cursor.
void
setDropTarget(DropTarget dt)
Set the associated drag-and-drop target, which receives events when this is enabled.
void
setEnabled(boolean enabled)
Enables or disables this component.
void
setFocusTraversalKeys(int id, AWTKeyStroke> keystrokes)
Sets the focus traversal keys for one of the three focus traversal directions supported by Components: KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, or KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS.
void
setFocusTraversalKeysEnabled(boolean focusTraversalKeysEnabled)
Enable or disable focus traversal keys on this Component.
void
setFocusable(boolean focusable)
Specify whether this component can receive focus.
void
setFont(Font f)
Sets the font for this component to the specified font.
void
setForeground(Color c)
Sets this component's foreground color to the specified color.
void
setIgnoreRepaint(boolean ignoreRepaint)
Sets whether paint messages delivered by the operating system should be ignored.
void
setLocale(Locale newLocale)
Sets the locale for this component to the specified locale.
void
setLocation(int x, int y)
Moves this component to the specified location, relative to the parent's coordinates.
void
setLocation(Point p)
Moves this component to the specified location, relative to the parent's coordinates.
void
setMaximumSize(Dimension size)
Sets the maximum size that will be returned by getMaximumSize() always, and sends a PropertyChangeEvent (with the property name 'maximumSize') to all registered listeners.
void
setMinimumSize(Dimension size)
Sets the minimum size that will be returned by getMinimumSize() always, and sends a PropertyChangeEvent (with the property name 'minimumSize') to all registered listeners.
void
setName(String name)
Sets the name of this component to the specified name (this is a bound property with the name 'name').
void
setPreferredSize(Dimension size)
Sets the preferred size that will be returned by getPreferredSize() always, and sends a PropertyChangeEvent (with the property name 'preferredSize') to all registered listeners.
void
setSize(int width, int height)
Sets the size of this component to the specified width and height.
void
setSize(Dimension d)
Sets the size of this component to the specified value.
void
setVisible(boolean visible)
Makes this component visible or invisible.
void
show()
Deprecated. use setVisible(boolean) instead
void
show(boolean visible)
Deprecated. use setVisible(boolean) instead
Dimension
size()
Deprecated. use getSize() instead
String
toString()
Returns a string representation of this component.
void
transferFocus()
Transfers focus to the next component in the focus traversal order, as though this were the current focus owner.
void
transferFocusBackward()
Transfers focus to the previous component in the focus traversal order, as though this were the current focus owner.
void
transferFocusUpCycle()
Transfers focus to the focus cycle root of this component.
void
update(Graphics g)
Updates this component.
void
validate()
Called to ensure that the layout for this component is valid.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

BOTTOM_ALIGNMENT

public static final float BOTTOM_ALIGNMENT
Constant returned by the getAlignmentY method to indicate that the component wishes to be aligned to the bottom relative to other components.
Field Value:
1.0f

CENTER_ALIGNMENT

public static final float CENTER_ALIGNMENT
Constant returned by the getAlignmentY and getAlignmentX methods to indicate that the component wishes to be aligned to the centdisper relative to other components.
Field Value:
0.0f

LEFT_ALIGNMENT

public static final float LEFT_ALIGNMENT
Constant returned by the getAlignmentX method to indicate that the component wishes to be aligned to the left relative to other components.
Field Value:
0.0f

RIGHT_ALIGNMENT

public static final float RIGHT_ALIGNMENT
Constant returned by the getAlignmentX method to indicate that the component wishes to be aligned to the right relative to other components.
Field Value:
1.0f

TOP_ALIGNMENT

public static final float TOP_ALIGNMENT
Constant returned by the getAlignmentY method to indicate that the component wishes to be aligned to the top relative to other components.
Field Value:
0.0f

Constructor Details

Component

protected Component()
Default constructor for subclasses. When Component is extended directly, it forms a lightweight component that must be hosted in an opaque native container higher in the tree.

Method Details

action

public boolean action(Event evt,
                      Object what)

Deprecated. in classes which support actions, use processActionEvent(ActionEvent) instead

AWT 1.0 ACTION_EVENT event handler. This method is meant to be overridden by components providing their own action event handler. The default implementation simply returns false.
Parameters:
evt - the event to handle
what - the object acted on, ignored
Returns:
false

add

public void add(PopupMenu popup)
Adds the specified popup menu to this component.
Parameters:
popup - the popup menu to be added
Since:
1.1

addComponentListener

public void addComponentListener(ComponentListener listener)
Adds the specified listener to this component. This is harmless if the listener is null, but if the listener has already been registered, it will now be registered twice.
Parameters:
listener - the new listener to add
Since:
1.1

addFocusListener

public void addFocusListener(FocusListener listener)
Adds the specified listener to this component. This is harmless if the listener is null, but if the listener has already been registered, it will now be registered twice.
Parameters:
listener - the new listener to add
Since:
1.1

addHierarchyBoundsListener

public void addHierarchyBoundsListener(HierarchyBoundsListener listener)
Adds the specified listener to this component. This is harmless if the listener is null, but if the listener has already been registered, it will now be registered twice.
Parameters:
listener - the new listener to add
Since:
1.3

addHierarchyListener

public void addHierarchyListener(HierarchyListener listener)
Adds the specified listener to this component. This is harmless if the listener is null, but if the listener has already been registered, it will now be registered twice.
Parameters:
listener - the new listener to add
Since:
1.3

addInputMethodListener

public void addInputMethodListener(InputMethodListener listener)
Adds the specified listener to this component. This is harmless if the listener is null, but if the listener has already been registered, it will now be registered twice.
Parameters:
listener - the new listener to add
Since:
1.2

addKeyListener

public void addKeyListener(KeyListener listener)
Adds the specified listener to this component. This is harmless if the listener is null, but if the listener has already been registered, it will now be registered twice.
Parameters:
listener - the new listener to add
Since:
1.1

addMouseListener

public void addMouseListener(MouseListener listener)
Adds the specified listener to this component. This is harmless if the listener is null, but if the listener has already been registered, it will now be registered twice.
Parameters:
listener - the new listener to add
Since:
1.1

addMouseMotionListener

public void addMouseMotionListener(MouseMotionListener listener)
Adds the specified listener to this component. This is harmless if the listener is null, but if the listener has already been registered, it will now be registered twice.
Parameters:
listener - the new listener to add
Since:
1.1

addMouseWheelListener

public void addMouseWheelListener(MouseWheelListener listener)
Adds the specified listener to this component. This is harmless if the listener is null, but if the listener has already been registered, it will now be registered twice.
Parameters:
listener - the new listener to add
Since:
1.4

addNotify

public void addNotify()
Called when the parent of this Component is made visible or when the Component is added to an already visible Container and needs to be shown. A native peer - if any - is created at this time. This method is called automatically by the AWT system and should not be called by user level code.

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds the specified property listener to this component. This is harmless if the listener is null, but if the listener has already been registered, it will now be registered twice. The property listener ignores inherited properties. Recognized properties include:
  • the font ("font")
  • the background color ("background")
  • the foreground color ("foreground")
  • the focusability ("focusable")
  • the focus key traversal enabled state ("focusTraversalKeysEnabled")
  • the set of forward traversal keys ("forwardFocusTraversalKeys")
  • the set of backward traversal keys ("backwardFocusTraversalKeys")
  • the set of up-cycle traversal keys ("upCycleFocusTraversalKeys")
Parameters:
listener - the new listener to add
Since:
1.1

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Adds the specified property listener to this component. This is harmless if the listener is null, but if the listener has already been registered, it will now be registered twice. The property listener ignores inherited properties. The listener is keyed to a single property. Recognized properties include:
  • the font ("font")
  • the background color ("background")
  • the foreground color ("foreground")
  • the focusability ("focusable")
  • the focus key traversal enabled state ("focusTraversalKeysEnabled")
  • the set of forward traversal keys ("forwardFocusTraversalKeys")
  • the set of backward traversal keys ("backwardFocusTraversalKeys")
  • the set of up-cycle traversal keys ("upCycleFocusTraversalKeys")
Parameters:
propertyName - the property name to filter on
listener - the new listener to add
Since:
1.1

applyComponentOrientation

public void applyComponentOrientation(ComponentOrientation o)
Sets the text layout orientation of this component. New components default to UNKNOWN (which behaves like LEFT_TO_RIGHT). This method affects the entire hierarchy, while setComponentOrientation(ComponentOrientation) affects only the current component.
Parameters:
o - the new orientation
Throws:
NullPointerException - if o is null
Since:
1.4

areFocusTraversalKeysSet

public boolean areFocusTraversalKeysSet(int id)
Tests whether the focus traversal keys for a given action are explicitly set or inherited.
Parameters:
id - one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS, or UP_CYCLE_TRAVERSAL_KEYS
Returns:
true if that set is explicitly specified
Throws:
IllegalArgumentException - if id is invalid
Since:
1.4

bounds

public Rectangle bounds()

Deprecated. use getBounds() instead

Returns a bounding rectangle for this component. Note that the returned rectange is relative to this component's parent, not to the screen.
Returns:
the bounding rectangle for this component

checkImage

public int checkImage(Image image,
                      int width,
                      int height,
                      ImageObserver observer)
Returns the status of the loading of the specified image. The value returned will be those flags defined in ImageObserver.
Parameters:
image - the image to check on
width - the scaled image width
height - the scaled image height
observer - the observer to notify of image loading progress
Returns:
the image observer flags indicating the status of the load

checkImage

public int checkImage(Image image,
                      ImageObserver observer)
Returns the status of the loading of the specified image. The value returned will be those flags defined in ImageObserver.
Parameters:
image - the image to check on
observer - the observer to notify of image loading progress
Returns:
the image observer flags indicating the status of the load
Throws:
NullPointerException - if image is null

coalesceEvents

protected AWTEvent coalesceEvents(AWTEvent existingEvent,
                                  AWTEvent newEvent)
This is called by the EventQueue if two events with the same event id and owner component are queued. Returns a new combined event, or null if no combining is done. The coelesced events are currently mouse moves (intermediate ones are discarded) and paint events (a merged paint is created in place of the two events).
Parameters:
existingEvent - the event on the queue
newEvent - the new event that might be entered on the queue
Returns:
null if both events are kept, or the replacement coelesced event

contains

public boolean contains(int x,
                        int y)
Tests whether or not the specified point is contained within this component. Coordinates are relative to this component.
Parameters:
x - the X coordinate of the point to test
y - the Y coordinate of the point to test
Returns:
true if the point is within this component

contains

public boolean contains(Point p)
Tests whether or not the specified point is contained within this component. Coordinates are relative to this component.
Parameters:
p - the point to test
Returns:
true if the point is within this component
Throws:
NullPointerException - if p is null
Since:
1.1

createImage

public Image createImage(int width,
                         int height)
Creates an image with the specified width and height for use in double buffering. Headless environments do not support images.
Parameters:
width - the width of the image
height - the height of the image
Returns:
the requested image, or null if it is not supported

createImage

public Image createImage(ImageProducer producer)
Creates an image from the specified producer.
Parameters:
producer - the image procedure to create the image from
Returns:
the resulting image

createVolatileImage

public VolatileImage createVolatileImage(int width,
                                         int height)
Creates an image with the specified width and height for use in double buffering. Headless environments do not support images.
Parameters:
width - the width of the image
height - the height of the image
Returns:
the requested image, or null if it is not supported
Since:
1.4

createVolatileImage

public VolatileImage createVolatileImage(int width,
                                         int height,
                                         ImageCapabilities caps)
            throws AWTException
Creates an image with the specified width and height for use in double buffering. Headless environments do not support images. The image will support the specified capabilities.
Parameters:
width - the width of the image
height - the height of the image
caps - the requested capabilities
Returns:
the requested image, or null if it is not supported
Throws:
AWTException - if a buffer with the capabilities cannot be created
Since:
1.4

deliverEvent

public void deliverEvent(Event e)

Deprecated. use (AWTEvent) instead

AWT 1.0 event delivery. Deliver an AWT 1.0 event to this Component. This method simply calls postEvent(Event).
Parameters:
e - the event to deliver

disable

public void disable()

Deprecated. use setEnabled(boolean) instead

Disables this component.

disableEvents

protected final void disableEvents(long eventsToDisable)
Disables the specified events. The events to disable are specified by OR-ing together the desired masks from AWTEvent.
Parameters:
eventsToDisable - the desired events to disable
Since:
1.1

dispatchEvent

public final void dispatchEvent(AWTEvent e)
Forwards AWT events to processEvent() if:
  • Events have been enabled for this type of event via enableEvents()
  • There is at least one registered listener for this type of event
Parameters:
e - the event to dispatch

doLayout

public void doLayout()
Calls the layout manager to re-layout the component. This is called during validation of a container in most cases.

enable

public void enable()

Deprecated. use setEnabled(boolean) instead

Enables this component.

enable

public void enable(boolean enabled)

Deprecated. use setEnabled(boolean) instead

Enables or disables this component.
Parameters:
enabled - true to enable this component

enableEvents

protected final void enableEvents(long eventsToEnable)
Enables the specified events. The events to enable are specified by OR-ing together the desired masks from AWTEvent.

Events are enabled by default when a listener is attached to the component for that event type. This method can be used by subclasses to ensure the delivery of a specified event regardless of whether or not a listener is attached.

Parameters:
eventsToEnable - the desired events to enable
Since:
1.1

enableInputMethods

public void enableInputMethods(boolean enable)
Enables or disables input method support for this component. By default, components have this enabled. Input methods are given the opportunity to process key events before this component and its listeners.
Parameters:
enable - true to enable input method processing
Since:
1.2

extends EventListener> T[] getListeners

public extends EventListener> T[] getListeners(Class listenerType)
Returns all registered EventListeners of the given listenerType.
Parameters:
listenerType - the class of listeners to filter (null not permitted).
Returns:
An array of registered listeners.
Throws:
ClassCastException - if listenerType does not implement the EventListener interface.
NullPointerException - if listenerType is null.
Since:
1.3

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  boolean oldValue,
                                  boolean newValue)
Report a change in a bound property to any registered property listeners.
Parameters:
propertyName - the property that changed
oldValue - the old property value
newValue - the new property value

firePropertyChange

public void firePropertyChange(String propertyName,
                               byte oldValue,
                               byte newValue)
Report a change in a bound property to any registered property listeners.
Parameters:
propertyName - the property that changed
oldValue - the old property value
newValue - the new property value
Since:
1.5

firePropertyChange

public void firePropertyChange(String propertyName,
                               char oldValue,
                               char newValue)
Report a change in a bound property to any registered property listeners.
Parameters:
propertyName - the property that changed
oldValue - the old property value
newValue - the new property value
Since:
1.5

firePropertyChange

public void firePropertyChange(String propertyName,
                               double oldValue,
                               double newValue)
Report a change in a bound property to any registered property listeners.
Parameters:
propertyName - the property that changed
oldValue - the old property value
newValue - the new property value
Since:
1.5

firePropertyChange

public void firePropertyChange(String propertyName,
                               float oldValue,
                               float newValue)
Report a change in a bound property to any registered property listeners.
Parameters:
propertyName - the property that changed
oldValue - the old property value
newValue - the new property value
Since:
1.5

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  int oldValue,
                                  int newValue)
Report a change in a bound property to any registered property listeners.
Parameters:
propertyName - the property that changed
oldValue - the old property value
newValue - the new property value

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  Object oldValue,
                                  Object newValue)
Report a change in a bound property to any registered property listeners.
Parameters:
propertyName - the property that changed
oldValue - the old property value
newValue - the new property value

firePropertyChange

public void firePropertyChange(String propertyName,
                               long oldValue,
                               long newValue)
Report a change in a bound property to any registered property listeners.
Parameters:
propertyName - the property that changed
oldValue - the old property value
newValue - the new property value
Since:
1.5

firePropertyChange

public void firePropertyChange(String propertyName,
                               short oldValue,
                               short newValue)
Report a change in a bound property to any registered property listeners.
Parameters:
propertyName - the property that changed
oldValue - the old property value
newValue - the new property value
Since:
1.5

getAccessibleContext

public AccessibleContext getAccessibleContext()
Returns the accessibility framework context of this class. Component is not accessible, so the default implementation returns null. Subclasses must override this behavior, and return an appropriate subclass of Component.AccessibleAWTComponent.
Returns:
the accessibility context

getAlignmentX

public float getAlignmentX()
Returns the preferred horizontal alignment of this component. The value returned will be between LEFT_ALIGNMENT and RIGHT_ALIGNMENT, inclusive.
Returns:
the preferred horizontal alignment of this component

getAlignmentY

public float getAlignmentY()
Returns the preferred vertical alignment of this component. The value returned will be between TOP_ALIGNMENT and BOTTOM_ALIGNMENT, inclusive.
Returns:
the preferred vertical alignment of this component

getBackground

public Color getBackground()
Returns this component's background color. If not set, this is inherited from the parent.
Returns:
the background color of the component, or null

getBounds

public Rectangle getBounds()
Returns a bounding rectangle for this component. Note that the returned rectange is relative to this component's parent, not to the screen.
Returns:
the bounding rectangle for this component

getBounds

public Rectangle getBounds(Rectangle r)
Returns the bounds of this component. This allows reuse of an existing rectangle, if r is non-null.
Parameters:
r - the rectangle to use, or null
Returns:
the bounds

getColorModel

public ColorModel getColorModel()
Returns the color model of the device this componet is displayed on.
Returns:
this object's color model

getComponentAt

public Component getComponentAt(int x,
                                int y)
Returns the component occupying the position (x,y). This will either be this component, an immediate child component, or null if neither of the first two occupies the specified location.
Parameters:
x - the X coordinate to search for components at
y - the Y coordinate to search for components at
Returns:
the component at the specified location, or null

getComponentAt

public Component getComponentAt(Point p)
Returns the component occupying the position (x,y). This will either be this component, an immediate child component, or null if neither of the first two occupies the specified location.
Parameters:
p - the point to search for components at
Returns:
the component at the specified location, or null
Throws:
NullPointerException - if p is null
Since:
1.1

getComponentListeners

public ComponentListener[] getComponentListeners()
Returns an array of all specified listeners registered on this component.
Returns:
an array of listeners
Since:
1.4

getComponentOrientation

public ComponentOrientation getComponentOrientation()
Determines the text layout orientation used by this component.
Returns:
the component orientation (this can be null)

getCursor

public Cursor getCursor()
Returns the cursor for this component. If not set, this is inherited from the parent, or from Cursor.getDefaultCursor().
Returns:
the cursor for this component

getDropTarget

public DropTarget getDropTarget()
Gets the associated drag-and-drop target, if there is one.
Returns:
the drop target

getFocusCycleRootAncestor

public Container getFocusCycleRootAncestor()
Returns the root container that owns the focus cycle where this component resides. A focus cycle root is in two cycles, one as the ancestor, and one as the focusable element; this call always returns the ancestor.
Returns:
the ancestor container that owns the focus cycle
Since:
1.4

getFocusListeners

public FocusListener[] getFocusListeners()
Returns an array of all specified listeners registered on this component.
Returns:
an array of listeners
Since:
1.4

getFocusTraversalKeys

public Set getFocusTraversalKeys(int id)
Returns the set of keys for a given focus traversal action, as defined in setFocusTraversalKeys. If not set, this is inherited from the parent component, which may have gotten it from the KeyboardFocusManager.
Parameters:
id - one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS, or UP_CYCLE_TRAVERSAL_KEYS
Returns:
set of traversal keys
Throws:
IllegalArgumentException - if id is invalid
Since:
1.4

getFocusTraversalKeysEnabled

public boolean getFocusTraversalKeysEnabled()
Check whether or not focus traversal keys are enabled on this Component. If they are, then the keyboard focus manager consumes and acts on key press and release events that trigger focus traversal, and discards the corresponding key typed events. If focus traversal keys are disabled, then all key events that would otherwise trigger focus traversal are sent to this Component.
Returns:
true if focus traversal keys are enabled
Since:
1.4

getFont

public Font getFont()
Returns the font in use for this component. If not set, this is inherited from the parent.
Specified by:
getFont in interface MenuContainer
Returns:
the font for this component
See Also:
setFont(Font)

getFontMetrics

public FontMetrics getFontMetrics(Font font)
Returns the font metrics for the specified font in this component.
Parameters:
font - the font to retrieve metrics for
Returns:
the font metrics for the specified font
Throws:
NullPointerException - if font is null

getForeground

public Color getForeground()
Returns this component's foreground color. If not set, this is inherited from the parent.
Returns:
this component's foreground color, or null

getGraphics

public Graphics getGraphics()
Returns a graphics object for this component. Returns null if this component is not currently displayed on the screen.
Returns:
a graphics object for this component

getGraphicsConfiguration

public GraphicsConfiguration getGraphicsConfiguration()
Returns the graphics configuration of this component, if there is one. If it has not been set, it is inherited from the parent.
Returns:
the graphics configuration, or null
Since:
1.3

getHeight

public int getHeight()
Gets the height of the component. This is more efficient than getBounds().height or getSize().height.
Returns:
the current width
Since:
1.2

getHierarchyBoundsListeners

public HierarchyBoundsListener[] getHierarchyBoundsListeners()
Returns an array of all specified listeners registered on this component.
Returns:
an array of listeners
Since:
1.4

getHierarchyListeners

public HierarchyListener[] getHierarchyListeners()
Returns an array of all specified listeners registered on this component.
Returns:
an array of listeners
Since:
1.4

getIgnoreRepaint

public boolean getIgnoreRepaint()
Test whether paint events from the operating system are ignored.
Returns:
the status of ignoring paint events
Since:
1.4

getInputContext

public InputContext getInputContext()
Gets the input context of this component, which is inherited from the parent unless this is overridden.
Returns:
the text input context
Since:
1.2

getInputMethodListeners

public InputMethodListener[] getInputMethodListeners()
Returns an array of all specified listeners registered on this component.
Returns:
an array of listeners
Since:
1.4

getInputMethodRequests

public InputMethodRequests getInputMethodRequests()
Returns the input method request handler, for subclasses which support on-the-spot text input. By default, input methods are handled by AWT, and this returns null.
Returns:
the input method handler, null by default
Since:
1.2

getKeyListeners

public KeyListener[] getKeyListeners()
Returns an array of all specified listeners registered on this component.
Returns:
an array of listeners
Since:
1.4

getLocale

public Locale getLocale()
Returns the locale for this component. If this component does not have a locale, the locale of the parent component is returned.
Returns:
the locale for this component
Throws:
IllegalComponentStateException - if it has no locale or parent
Since:
1.1

getLocation

public Point getLocation()
Returns the location of this component's top left corner relative to its parent component. This may be outdated, so for synchronous behavior, you should use a component listner.
Returns:
the location of this component
Since:
1.1

getLocation

public Point getLocation(Point p)
Returns the location of this component. This allows reuse of an existing point, if p is non-null.
Parameters:
p - the point to use, or null
Returns:
the location

getLocationOnScreen

public Point getLocationOnScreen()
Returns the location of this component's top left corner in screen coordinates.
Returns:
the location of this component in screen coordinates
Throws:
IllegalComponentStateException - if the component is not showing

getMaximumSize

public Dimension getMaximumSize()
Returns the component's maximum size.
Returns:
the component's maximum size

getMinimumSize

public Dimension getMinimumSize()
Returns the component's minimum size.
Returns:
the component's minimum size

getMouseListeners

public MouseListener[] getMouseListeners()
Returns an array of all specified listeners registered on this component.
Returns:
an array of listeners
Since:
1.4

getMouseMotionListeners

public MouseMotionListener[] getMouseMotionListeners()
Returns an array of all specified listeners registered on this component.
Returns:
an array of listeners
Since:
1.4

getMousePosition

public Point getMousePosition()
            throws HeadlessException
Returns the mouse pointer position relative to this Component's top-left corner.
Returns:
relative mouse pointer position
Throws:
HeadlessException - if in a headless environment

getMouseWheelListeners

public MouseWheelListener[] getMouseWheelListeners()
Returns an array of all specified listeners registered on this component.
Returns:
an array of listeners
Since:
1.4

getName

public String getName()
Returns the name of this component.
Returns:
the name of this component
Since:
1.1

getParent

public Container getParent()
Returns the parent of this component.
Returns:
the parent of this component

getPeer

public ComponentPeer getPeer()

Deprecated. user programs should not directly manipulate peers; use isDisplayable() instead

Returns the native windowing system peer for this component. Only the platform specific implementation code should call this method.
Returns:
the peer for this component

getPreferredSize

public Dimension getPreferredSize()
Returns the component's preferred size.
Returns:
the component's preferred size

getPropertyChangeListeners

public PropertyChangeListener[] getPropertyChangeListeners()
Returns an array of all specified listeners registered on this component.
Returns:
an array of listeners
Since:
1.4

getPropertyChangeListeners

public PropertyChangeListener[] getPropertyChangeListeners(String property)
Returns an array of all specified listeners on the named property that are registered on this component.
Returns:
an array of listeners
Since:
1.4

getSize

public Dimension getSize()
Returns the size of this object.
Returns:
the size of this object
Since:
1.1

getSize

public Dimension getSize(Dimension d)
Returns the size of this component. This allows reuse of an existing dimension, if d is non-null.
Parameters:
d - the dimension to use, or null
Returns:
the size

getToolkit

public Toolkit getToolkit()
Returns the toolkit in use for this component. The toolkit is associated with the frame this component belongs to.
Returns:
the toolkit for this component

getTreeLock

public final Object getTreeLock()
Returns the object used for synchronization locks on this component when performing tree and layout functions.
Returns:
the synchronization lock for this component

getWidth

public int getWidth()
Gets the width of the component. This is more efficient than getBounds().width or getSize().width.
Returns:
the current width
Since:
1.2

getX

public int getX()
Gets the x coordinate of the upper left corner. This is more efficient than getBounds().x or getLocation().x.
Returns:
the current x coordinate
Since:
1.2

getY

public int getY()
Gets the y coordinate of the upper left corner. This is more efficient than getBounds().y or getLocation().y.
Returns:
the current y coordinate
Since:
1.2

gotFocus

public boolean gotFocus(Event evt,
                        Object what)

Deprecated. use processFocusEvent(FocusEvent) instead

AWT 1.0 GOT_FOCUS event handler. This method is meant to be overridden by components providing their own GOT_FOCUS handler. The default implementation simply returns false.
Parameters:
evt - the event to handle
what - the Object focused, ignored
Returns:
false

handleEvent

public boolean handleEvent(Event evt)

Deprecated. use processEvent(AWTEvent) instead

AWT 1.0 event handler. This method calls one of the event-specific handler methods. For example for key events, either keyDown(Event,int) or keyUp(Event,int) is called. A derived component can override one of these event-specific methods if it only needs to handle certain event types. Otherwise it can override handleEvent itself and handle any event.
Parameters:
evt - the event to handle
Returns:
true if the event was handled, false otherwise

hasFocus

public boolean hasFocus()
Tests if this component is the focus owner. Use () instead.
Returns:
true if this component owns focus
Since:
1.2

hide

public void hide()

Deprecated. use setVisible(boolean) instead

Hides this component so that it is no longer shown on the screen.

imageUpdate

public boolean imageUpdate(Image img,
                           int flags,
                           int x,
                           int y,
                           int w,
                           int h)
Called when an image has changed so that this component is repainted. This incrementally draws an image as more bits are available, when possible. Incremental drawing is enabled if the system property awt.image.incrementalDraw is not present or is true, in which case the redraw rate is set to 100ms or the value of the system property awt.image.redrawrate.

The coordinate system used depends on the particular flags.

Specified by:
imageUpdate in interface ImageObserver
Parameters:
img - the image that has been updated
flags - tlags as specified in ImageObserver
x - the X coordinate
y - the Y coordinate
w - the width
h - the height
Returns:
false if the image is completely loaded, loading has been aborted, or an error has occurred. true if more updates are required.

inside

public boolean inside(int x,
                      int y)

Deprecated. use contains(int,int) instead

Tests whether or not the specified point is contained within this component. Coordinates are relative to this component.
Parameters:
x - the X coordinate of the point to test
y - the Y coordinate of the point to test
Returns:
true if the point is within this component

invalidate

public void invalidate()
Invalidates this component and all of its parent components. This will cause them to have their layout redone. This is called frequently, so make it fast.

isBackgroundSet

public boolean isBackgroundSet()
Tests if the background was explicitly set, or just inherited from the parent.
Returns:
true if the background has been set
Since:
1.4

isCursorSet

public boolean isCursorSet()
Tests if the cursor was explicitly set, or just inherited from the parent.
Returns:
true if the cursor has been set
Since:
1.4

isDisplayable

public boolean isDisplayable()
Tests if the component is displayable. It must be connected to a native screen resource. This reduces to checking that peer is not null. A containment hierarchy is made displayable when a window is packed or made visible.
Returns:
true if the component is displayable
Since:
1.2

isDoubleBuffered

public boolean isDoubleBuffered()
Checks if this image is painted to an offscreen image buffer that is later copied to screen (double buffering reduces flicker). This version returns false, so subclasses must override it if they provide double buffering.
Returns:
true if this is double buffered; defaults to false

isEnabled

public boolean isEnabled()
Tests whether or not this component is enabled. Components are enabled by default, and must be enabled to receive user input or generate events.
Returns:
true if the component is enabled

isFocusCycleRoot

public boolean isFocusCycleRoot(Container c)
Tests if the container is the ancestor of the focus cycle that this component belongs to.
Parameters:
c - the container to test
Returns:
true if c is the focus cycle root
Since:
1.4

isFocusOwner

public boolean isFocusOwner()
Tests if this component is the focus owner.
Returns:
true if this component owns focus
Since:
1.4

isFocusTraversable

public boolean isFocusTraversable()

Deprecated. use isFocusable() instead

Tests whether or not this component is in the group that can be traversed using the keyboard traversal mechanism (such as the TAB key).
Returns:
true if the component is traversed via the TAB key
Since:
1.1

isFocusable

public boolean isFocusable()
Tests if this component can receive focus.
Returns:
true if this component can receive focus
Since:
1.4

isFontSet

public boolean isFontSet()
Tests if the font was explicitly set, or just inherited from the parent.
Returns:
true if the font has been set
Since:
1.4

isForegroundSet

public boolean isForegroundSet()
Tests if the foreground was explicitly set, or just inherited from the parent.
Returns:
true if the foreground has been set
Since:
1.4

isLightweight

public boolean isLightweight()
Return whether the component is lightweight. That means the component has no native peer, but is displayable. This applies to subclasses of Component not in this package, such as javax.swing.
Returns:
true if the component has a lightweight peer
Since:
1.2

isMaximumSizeSet

public boolean isMaximumSizeSet()
Returns true if the current maximum size is not null and was set by a call to setMaximumSize(Dimension), otherwise returns false.
Returns:
A boolean.
Since:
1.5

isMinimumSizeSet

public boolean isMinimumSizeSet()
Returns true if the current minimum size is not null and was set by a call to setMinimumSize(Dimension), otherwise returns false.
Returns:
A boolean.
Since:
1.5

isOpaque

public boolean isOpaque()
Tests if this component is opaque. All "heavyweight" (natively-drawn) components are opaque. A component is opaque if it draws all pixels in the bounds; a lightweight component is partially transparent if it lets pixels underneath show through. Subclasses that guarantee that all pixels will be drawn should override this.
Returns:
true if this is opaque
Since:
1.2

isPreferredSizeSet

public boolean isPreferredSizeSet()
Returns true if the current preferred size is not null and was set by a call to setPreferredSize(Dimension), otherwise returns false.
Returns:
A boolean.
Since:
1.5

isShowing

public boolean isShowing()
Tests whether or not this component is actually being shown on the screen. This will be true if and only if it this component is visible and its parent components are all visible.
Returns:
true if the component is showing on the screen

isValid

public boolean isValid()
Tests whether or not this component is valid. A invalid component needs to have its layout redone.
Returns:
true if this component is valid

isVisible

public boolean isVisible()
Tests whether or not this component is visible. Except for top-level frames, components are initially visible.
Returns:
true if the component is visible

keyDown

public boolean keyDown(Event evt,
                       int key)

Deprecated. use processKeyEvent(KeyEvent) instead

AWT 1.0 KEY_PRESS and KEY_ACTION event handler. This method is meant to be overridden by components providing their own key press handler. The default implementation simply returns false.
Parameters:
evt - the event to handle
key - the key pressed, ignored
Returns:
false

keyUp

public boolean keyUp(Event evt,
                     int key)

Deprecated. use processKeyEvent(KeyEvent) instead

AWT 1.0 KEY_RELEASE and KEY_ACTION_RELEASE event handler. This method is meant to be overridden by components providing their own key release handler. The default implementation simply returns false.
Parameters:
evt - the event to handle
key - the key pressed, ignored
Returns:
false

layout

public void layout()

Deprecated. use doLayout() instead

Calls the layout manager to re-layout the component. This is called during validation of a container in most cases.

list

public void list()
Prints a listing of this component to System.out.

list

public void list(PrintStream out)
Prints a listing of this component to the specified print stream.
Parameters:
out - the PrintStream to print to

list

public void list(PrintStream out,
                 int indent)
Prints a listing of this component to the specified print stream, starting at the specified indentation point.
Parameters:
out - the PrintStream to print to
indent - the indentation point

list

public void list(PrintWriter out)
Prints a listing of this component to the specified print writer.
Parameters:
out - the PrintWrinter to print to
Since:
1.1

list

public void list(PrintWriter out,
                 int indent)
Prints a listing of this component to the specified print writer, starting at the specified indentation point.
Parameters:
out - the PrintWriter to print to
indent - the indentation point
Since:
1.1

locate

public Component locate(int x,
                        int y)

Deprecated. use getComponentAt(int,int) instead

Returns the component occupying the position (x,y). This will either be this component, an immediate child component, or null if neither of the first two occupies the specified location.
Parameters:
x - the X coordinate to search for components at
y - the Y coordinate to search for components at
Returns:
the component at the specified location, or null

location

public Point location()

Deprecated. use getLocation() instead

Returns the location of this component's top left corner relative to its parent component.
Returns:
the location of this component

lostFocus

public boolean lostFocus(Event evt,
                         Object what)

Deprecated. use processFocusEvent(FocusEvent) instead

AWT 1.0 LOST_FOCUS event handler. This method is meant to be overridden by components providing their own LOST_FOCUS handler. The default implementation simply returns false.
Parameters:
evt - the event to handle
what - the Object focused, ignored
Returns:
false

minimumSize

public Dimension minimumSize()

Deprecated. use getMinimumSize() instead

Returns the component's minimum size.
Returns:
the component's minimum size

mouseDown

public boolean mouseDown(Event evt,
                         int x,
                         int y)

Deprecated. use processMouseEvent(MouseEvent) instead

AWT 1.0 MOUSE_DOWN event handler. This method is meant to be overridden by components providing their own MOUSE_DOWN handler. The default implementation simply returns false.
Parameters:
evt - the event to handle
x - the x coordinate, ignored
y - the y coordinate, ignored
Returns:
false

mouseDrag

public boolean mouseDrag(Event evt,
                         int x,
                         int y)

Deprecated. use processMouseMotionEvent(MouseEvent) instead

AWT 1.0 MOUSE_DRAG event handler. This method is meant to be overridden by components providing their own MOUSE_DRAG handler. The default implementation simply returns false.
Parameters:
evt - the event to handle
x - the x coordinate, ignored
y - the y coordinate, ignored
Returns:
false

mouseEnter

public boolean mouseEnter(Event evt,
                          int x,
                          int y)

Deprecated. use processMouseEvent(MouseEvent) instead

AWT 1.0 MOUSE_ENTER event handler. This method is meant to be overridden by components providing their own MOUSE_ENTER handler. The default implementation simply returns false.
Parameters:
evt - the event to handle
x - the x coordinate, ignored
y - the y coordinate, ignored
Returns:
false

mouseExit

public boolean mouseExit(Event evt,
                         int x,
                         int y)

Deprecated. use processMouseEvent(MouseEvent) instead

AWT 1.0 MOUSE_EXIT event handler. This method is meant to be overridden by components providing their own MOUSE_EXIT handler. The default implementation simply returns false.
Parameters:
evt - the event to handle
x - the x coordinate, ignored
y - the y coordinate, ignored
Returns:
false

mouseMove

public boolean mouseMove(Event evt,
                         int x,
                         int y)

Deprecated. use processMouseMotionEvent(MouseEvent) instead

AWT 1.0 MOUSE_MOVE event handler. This method is meant to be overridden by components providing their own MOUSE_MOVE handler. The default implementation simply returns false.
Parameters:
evt - the event to handle
x - the x coordinate, ignored
y - the y coordinate, ignored
Returns:
false

mouseUp

public boolean mouseUp(Event evt,
                       int x,
                       int y)

Deprecated. use processMouseEvent(MouseEvent) instead

AWT 1.0 MOUSE_UP event handler. This method is meant to be overridden by components providing their own MOUSE_UP handler. The default implementation simply returns false.
Parameters:
evt - the event to handle
x - the x coordinate, ignored
y - the y coordinate, ignored
Returns:
false

move

public void move(int x,
                 int y)

Deprecated. use setLocation(int,int) instead

Moves this component to the specified location, relative to the parent's coordinates. The coordinates are the new upper left corner of this component.
Parameters:
x - the new X coordinate of this component
y - the new Y coordinate of this component

nextFocus

public void nextFocus()

Deprecated. use () instead

AWT 1.0 focus event processor. Transfers focus to the next component in the focus traversal order, as though this were the current focus owner.

paint

public void paint(Graphics g)
Paints this component on the screen. The clipping region in the graphics context will indicate the region that requires painting. This is called whenever the component first shows, or needs to be repaired because something was temporarily drawn on top. It is not necessary for subclasses to call super.paint(g). Components with no area are not painted.
Parameters:
g - the graphics context for this paint job

paintAll

public void paintAll(Graphics g)
Paints this entire component, including any sub-components.
Parameters:
g - the graphics context for this paint job

paramString

protected String paramString()
Returns a debugging string representing this component. The string may be empty but not null.
Returns:
a string representing this component

postEvent

public boolean postEvent(Event e)

Deprecated. use dispatchEvent(AWTEvent) instead

AWT 1.0 event handler. This method simply calls handleEvent and returns the result.
Specified by:
postEvent in interface MenuContainer
Parameters:
e - the event to handle
Returns:
true if the event was handled, false otherwise

preferredSize

public Dimension preferredSize()

Deprecated. use getPreferredSize() instead

Returns the component's preferred size.
Returns:
the component's preferred size

prepareImage

public boolean prepareImage(Image image,
                            int width,
                            int height,
                            ImageObserver observer)
Prepares the specified image for rendering on this component at the specified scaled width and height
Parameters:
image - the image to prepare for rendering
width - the scaled width of the image
height - the scaled height of the image
observer - the observer to notify of image preparation status
Returns:
true if the image is already fully prepared

prepareImage

public boolean prepareImage(Image image,
                            ImageObserver observer)
Prepares the specified image for rendering on this component.
Parameters:
image - the image to prepare for rendering
observer - the observer to notify of image preparation status
Returns:
true if the image is already fully prepared
Throws:
NullPointerException - if image is null

print

public void print(Graphics g)
Prints this component. This method is provided so that printing can be done in a different manner from painting. However, the implementation in this class simply calls the paint() method.
Parameters:
g - the graphics context of the print device

printAll

public void printAll(Graphics g)
Prints this component, including all sub-components.
Parameters:
g - the graphics context of the print device

processComponentEvent

protected void processComponentEvent(ComponentEvent e)
Called when a component event is dispatched and component events are enabled. This method passes the event along to any listeners that are attached.
Parameters:
e - the ComponentEvent to process
Throws:
NullPointerException - if e is null
Since:
1.1

processEvent

protected void processEvent(AWTEvent e)
Processes the specified event. In this class, this method simply calls one of the more specific event handlers.
Parameters:
e - the event to process
Throws:
NullPointerException - if e is null
Since:
1.1

processFocusEvent

protected void processFocusEvent(FocusEvent e)
Called when a focus event is dispatched and component events are enabled. This method passes the event along to any listeners that are attached.
Parameters:
e - the FocusEvent to process
Throws:
NullPointerException - if e is null
Since:
1.1

processHierarchyBoundsEvent

protected void processHierarchyBoundsEvent(HierarchyEvent e)
Called when a hierarchy bounds event is dispatched and component events are enabled. This method passes the event along to any listeners that are attached.
Parameters:
e - the HierarchyEvent to process
Throws:
NullPointerException - if e is null
Since:
1.3

processHierarchyEvent

protected void processHierarchyEvent(HierarchyEvent e)
Called when a hierarchy change event is dispatched and component events are enabled. This method passes the event along to any listeners that are attached.
Parameters:
e - the HierarchyEvent to process
Throws:
NullPointerException - if e is null
Since:
1.3

processInputMethodEvent

protected void processInputMethodEvent(InputMethodEvent e)
Called when an input method event is dispatched and component events are enabled. This method passes the event along to any listeners that are attached.
Parameters:
e - the InputMethodEvent to process
Throws:
NullPointerException - if e is null
Since:
1.2

processKeyEvent

protected void processKeyEvent(KeyEvent e)
Called when a key event is dispatched and component events are enabled. This method passes the event along to any listeners that are attached.
Parameters:
e - the KeyEvent to process
Throws:
NullPointerException - if e is null
Since:
1.1

processMouseEvent

protected void processMouseEvent(MouseEvent e)
Called when a regular mouse event is dispatched and component events are enabled. This method passes the event along to any listeners that are attached.
Parameters:
e - the MouseEvent to process
Throws:
NullPointerException - if e is null
Since:
1.1

processMouseMotionEvent

protected void processMouseMotionEvent(MouseEvent e)
Called when a mouse motion event is dispatched and component events are enabled. This method passes the event along to any listeners that are attached.
Parameters:
e - the MouseMotionEvent to process
Throws:
NullPointerException - if e is null
Since:
1.1

processMouseWheelEvent

protected void processMouseWheelEvent(MouseWheelEvent e)
Called when a mouse wheel event is dispatched and component events are enabled. This method passes the event along to any listeners that are attached.
Parameters:
e - the MouseWheelEvent to process
Throws:
NullPointerException - if e is null
Since:
1.4

remove

public void remove(MenuComponent popup)
Removes the specified popup menu from this component.
Specified by:
remove in interface MenuContainer
Parameters:
popup - the popup menu to remove
Since:
1.1

removeComponentListener

public void removeComponentListener(ComponentListener listener)
Removes the specified listener from the component. This is harmless if the listener was not previously registered.
Parameters:
listener - the listener to remove
Since:
1.1

removeFocusListener

public void removeFocusListener(FocusListener listener)
Removes the specified listener from the component. This is harmless if the listener was not previously registered.
Parameters:
listener - the listener to remove
Since:
1.1

removeHierarchyBoundsListener

public void removeHierarchyBoundsListener(HierarchyBoundsListener listener)
Removes the specified listener from the component. This is harmless if the listener was not previously registered.
Parameters:
listener - the listener to remove
Since:
1.3

removeHierarchyListener

public void removeHierarchyListener(HierarchyListener listener)
Removes the specified listener from the component. This is harmless if the listener was not previously registered.
Parameters:
listener - the listener to remove
Since:
1.3

removeInputMethodListener

public void removeInputMethodListener(InputMethodListener listener)
Removes the specified listener from the component. This is harmless if the listener was not previously registered.
Parameters:
listener - the listener to remove
Since:
1.2

removeKeyListener

public void removeKeyListener(KeyListener listener)
Removes the specified listener from the component. This is harmless if the listener was not previously registered.
Parameters:
listener - the listener to remove
Since:
1.1

removeMouseListener

public void removeMouseListener(MouseListener listener)
Removes the specified listener from the component. This is harmless if the listener was not previously registered.
Parameters:
listener - the listener to remove
Since:
1.1

removeMouseMotionListener

public void removeMouseMotionListener(MouseMotionListener listener)
Removes the specified listener from the component. This is harmless if the listener was not previously registered.
Parameters:
listener - the listener to remove
Since:
1.1

removeMouseWheelListener

public void removeMouseWheelListener(MouseWheelListener listener)
Removes the specified listener from the component. This is harmless if the listener was not previously registered.
Parameters:
listener - the listener to remove
Since:
1.4

removeNotify

public void removeNotify()
Called to inform this component is has been removed from its container. Its native peer - if any - is destroyed at this time. This method is called automatically by the AWT system and should not be called by user level code.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes the specified property listener from the component. This is harmless if the listener was not previously registered.
Parameters:
listener - the listener to remove
Since:
1.1

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Removes the specified property listener on a particular property from the component. This is harmless if the listener was not previously registered.
Parameters:
propertyName - the property name to filter on
listener - the listener to remove
Since:
1.1

repaint

public void repaint()
Repaint this entire component. The update() method on this component will be called as soon as possible.

repaint

public void repaint(int x,
                    int y,
                    int w,
                    int h)
Repaints the specified rectangular region within this component. The update method on this component will be called as soon as possible. The coordinates are relative to this component.
Parameters:
x - the X coordinate of the upper left of the region to repaint
y - the Y coordinate of the upper left of the region to repaint
w - the width of the region to repaint
h - the height of the region to repaint

repaint

public void repaint(long tm)
Repaint this entire component. The update() method on this component will be called in approximate the specified number of milliseconds.
Parameters:
tm - milliseconds before this component should be repainted

repaint

public void repaint(long tm,
                    int x,
                    int y,
                    int width,
                    int height)
Repaints the specified rectangular region within this component. The update method on this component will be called in approximately the specified number of milliseconds. The coordinates are relative to this component.
Parameters:
tm - milliseconds before this component should be repainted
x - the X coordinate of the upper left of the region to repaint
y - the Y coordinate of the upper left of the region to repaint
width - the width of the region to repaint
height - the height of the region to repaint

requestFocus

public void requestFocus()
Request that this Component be given the keyboard input focus and that its top-level ancestor become the focused Window. For the request to be granted, the Component must be focusable, displayable and showing and the top-level Window to which it belongs must be focusable. If the request is initially denied on the basis that the top-level Window is not focusable, the request will be remembered and granted when the Window does become focused. Never assume that this Component is the focus owner until it receives a FOCUS_GAINED event. The behaviour of this method is platform-dependent. requestFocusInWindow() should be used instead.
See Also:
(), FocusEvent, (FocusListener), (), (), ()

requestFocus

protected boolean requestFocus(boolean temporary)
Request that this Component be given the keyboard input focus and that its top-level ancestor become the focused Window. For the request to be granted, the Component must be focusable, displayable and showing and the top-level Window to which it belongs must be focusable. If the request is initially denied on the basis that the top-level Window is not focusable, the request will be remembered and granted when the Window does become focused. Never assume that this Component is the focus owner until it receives a FOCUS_GAINED event. The behaviour of this method is platform-dependent. requestFocusInWindow() should be used instead. If the return value is false, the request is guaranteed to fail. If the return value is true, the request will succeed unless it is vetoed or something in the native windowing system intervenes, preventing this Component's top-level ancestor from becoming focused. This method is meant to be called by derived lightweight Components that want to avoid unnecessary repainting when they know a given focus transfer need only be temporary.
Parameters:
temporary - true if the focus request is temporary
Returns:
true if the request has a chance of success
Since:
1.4
See Also:
(), FocusEvent, (FocusListener), (), (), ()

requestFocusInWindow

public boolean requestFocusInWindow()
Request that this component be given the keyboard input focus, if its top-level ancestor is the currently focused Window. A FOCUS_GAINED event will be fired if and only if this request is successful. To be successful, the component must be displayable, showing, and focusable, and its ancestor top-level Window must be focused. If the return value is false, the request is guaranteed to fail. If the return value is true, the request will succeed unless it is vetoed or something in the native windowing system intervenes, preventing this Component's top-level ancestor from becoming focused.
Returns:
true if the request has a chance of success
Since:
1.4
See Also:
(), FocusEvent, (FocusListener), (), (), ()

requestFocusInWindow

protected boolean requestFocusInWindow(boolean temporary)
Request that this component be given the keyboard input focus, if its top-level ancestor is the currently focused Window. A FOCUS_GAINED event will be fired if and only if this request is successful. To be successful, the component must be displayable, showing, and focusable, and its ancestor top-level Window must be focused. If the return value is false, the request is guaranteed to fail. If the return value is true, the request will succeed unless it is vetoed or something in the native windowing system intervenes, preventing this Component's top-level ancestor from becoming focused. This method is meant to be called by derived lightweight Components that want to avoid unnecessary repainting when they know a given focus transfer need only be temporary.
Parameters:
temporary - true if the focus request is temporary
Returns:
true if the request has a chance of success
Since:
1.4
See Also:
(), FocusEvent, (FocusListener), (), (), ()

reshape

public void reshape(int x,
                    int y,
                    int width,
                    int height)

Deprecated. use setBounds(int,int,int,int) instead

Sets the bounding rectangle for this component to the specified values. Note that these coordinates are relative to the parent, not to the screen.
Parameters:
x - the X coordinate of the upper left corner of the rectangle
y - the Y coordinate of the upper left corner of the rectangle
width - the width of the rectangle
height - the height of the rectangle

resize

public void resize(int width,
                   int height)

Deprecated. use setSize(int,int) instead

Sets the size of this component to the specified value.
Parameters:
width - the new width of the component
height - the new height of the component

resize

public void resize(Dimension d)

Deprecated. use setSize(Dimension) instead

Sets the size of this component to the specified value.
Parameters:
d - the new size of this component
Throws:
NullPointerException - if d is null

setBackground

public void setBackground(Color c)
Sets this component's background color to the specified color. The parts of the component affected by the background color may by system dependent. This is a bound property.
Parameters:
c - the new background color

setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)
Sets the bounding rectangle for this component to the specified values. Note that these coordinates are relative to the parent, not to the screen.
Parameters:
x - the X coordinate of the upper left corner of the rectangle
y - the Y coordinate of the upper left corner of the rectangle
w - the width of the rectangle
h - the height of the rectangle
Since:
1.1

setBounds

public void setBounds(Rectangle r)
Sets the bounding rectangle for this component to the specified rectangle. Note that these coordinates are relative to the parent, not to the screen.
Parameters:
r - the new bounding rectangle
Throws:
NullPointerException - if r is null
Since:
1.1

setComponentOrientation

public void setComponentOrientation(ComponentOrientation o)
Sets the text layout orientation of this component. New components default to UNKNOWN (which behaves like LEFT_TO_RIGHT). This method affects only the current component, while applyComponentOrientation(ComponentOrientation) affects the entire hierarchy.
Parameters:
o - the new orientation (null is accepted)

setCursor

public void setCursor(Cursor cursor)
Sets the cursor for this component to the specified cursor. The cursor is displayed when the point is contained by the component, and the component is visible, displayable, and enabled. This is inherited by subcomponents unless they set their own cursor.
Parameters:
cursor - the new cursor for this component

setDropTarget

public void setDropTarget(DropTarget dt)
Set the associated drag-and-drop target, which receives events when this is enabled.
Parameters:
dt - the new drop target
See Also:
isEnabled()

setEnabled

public void setEnabled(boolean enabled)
Enables or disables this component. The component must be enabled to receive events (except that lightweight components always receive mouse events).
Parameters:
enabled - true to enable this component
Since:
1.1

setFocusTraversalKeys

public void setFocusTraversalKeys(int id,
                                  AWTKeyStroke> keystrokes)
Sets the focus traversal keys for one of the three focus traversal directions supported by Components: KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, or KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS. Normally, the default values should match the operating system's native choices. To disable a given traversal, use Collections.EMPTY_SET. The event dispatcher will consume PRESSED, RELEASED, and TYPED events for the specified key, although focus can only transfer on PRESSED or RELEASED.

The defaults are:

IdentifierMeaningDefault
KeyboardFocusManager.FORWARD_TRAVERSAL_KEYSNormal forward traversalTAB on KEY_PRESSED, Ctrl-TAB on KEY_PRESSED
KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYSNormal backward traversalShift-TAB on KEY_PRESSED, Ctrl-Shift-TAB on KEY_PRESSED
KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYSGo up a traversal cycleNone
If keystrokes is null, this component's focus traversal key set is inherited from one of its ancestors. If none of its ancestors has its own set of focus traversal keys, the focus traversal keys are set to the defaults retrieved from the current KeyboardFocusManager. If not null, the set must contain only AWTKeyStrokes that are not already focus keys and are not KEY_TYPED events.
Parameters:
id - one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS, or UP_CYCLE_TRAVERSAL_KEYS
keystrokes - a set of keys, or null
Throws:
IllegalArgumentException - if id or keystrokes is invalid
Since:
1.4

setFocusTraversalKeysEnabled

public void setFocusTraversalKeysEnabled(boolean focusTraversalKeysEnabled)
Enable or disable focus traversal keys on this Component. If they are, then the keyboard focus manager consumes and acts on key press and release events that trigger focus traversal, and discards the corresponding key typed events. If focus traversal keys are disabled, then all key events that would otherwise trigger focus traversal are sent to this Component.
Parameters:
focusTraversalKeysEnabled - the new value of the flag
Since:
1.4
See Also:
(), (int, Set), (int)

setFocusable

public void setFocusable(boolean focusable)
Specify whether this component can receive focus. This method also sets the isFocusTraversableOverridden field to 1, which appears to be the undocumented way DefaultFocusTraversalPolicy.accept(Component) determines whether to respect the isFocusable() method of the component.
Parameters:
focusable - the new focusable status
Since:
1.4

setFont

public void setFont(Font f)
Sets the font for this component to the specified font. This is a bound property.
Parameters:
f - the new font for this component
See Also:
getFont()

setForeground

public void setForeground(Color c)
Sets this component's foreground color to the specified color. This is a bound property.
Parameters:
c - the new foreground color

setIgnoreRepaint

public void setIgnoreRepaint(boolean ignoreRepaint)
Sets whether paint messages delivered by the operating system should be ignored. This does not affect messages from AWT, except for those triggered by OS messages. Setting this to true can allow faster performance in full-screen mode or page-flipping.
Parameters:
ignoreRepaint - the new setting for ignoring repaint events
Since:
1.4

setLocale

public void setLocale(Locale newLocale)
Sets the locale for this component to the specified locale. This is a bound property.
Parameters:
newLocale - the new locale for this component

setLocation

public void setLocation(int x,
                        int y)
Moves this component to the specified location, relative to the parent's coordinates. The coordinates are the new upper left corner of this component.
Parameters:
x - the new X coordinate of this component
y - the new Y coordinate of this component

setLocation

public void setLocation(Point p)
Moves this component to the specified location, relative to the parent's coordinates. The coordinates are the new upper left corner of this component.
Parameters:
p - new coordinates for this component
Throws:
NullPointerException - if p is null
Since:
1.1

setMaximumSize

public void setMaximumSize(Dimension size)
Sets the maximum size that will be returned by getMaximumSize() always, and sends a PropertyChangeEvent (with the property name 'maximumSize') to all registered listeners.
Parameters:
size - the maximum size (null permitted).
Since:
1.5

setMinimumSize

public void setMinimumSize(Dimension size)
Sets the minimum size that will be returned by getMinimumSize() always, and sends a PropertyChangeEvent (with the property name 'minimumSize') to all registered listeners.
Parameters:
size - the minimum size (null permitted).
Since:
1.5

setName

public void setName(String name)
Sets the name of this component to the specified name (this is a bound property with the name 'name').
Parameters:
name - the new name (null permitted).
Since:
1.1
See Also:
getName()

setPreferredSize

public void setPreferredSize(Dimension size)
Sets the preferred size that will be returned by getPreferredSize() always, and sends a PropertyChangeEvent (with the property name 'preferredSize') to all registered listeners.
Parameters:
size - the preferred size (null permitted).
Since:
1.5

setSize

public void setSize(int width,
                    int height)
Sets the size of this component to the specified width and height.
Parameters:
width - the new width of this component
height - the new height of this component

setSize

public void setSize(Dimension d)
Sets the size of this component to the specified value.
Parameters:
d - the new size of this component
Throws:
NullPointerException - if d is null
Since:
1.1

setVisible

public void setVisible(boolean visible)
Makes this component visible or invisible. Note that it wtill might not show the component, if a parent is invisible.
Parameters:
visible - true to make this component visible
Since:
1.1
See Also:
isVisible()

show

public void show()

Deprecated. use setVisible(boolean) instead

Makes this component visible on the screen.

show

public void show(boolean visible)

Deprecated. use setVisible(boolean) instead

Makes this component visible or invisible.
Parameters:
visible - true to make this component visible

size

public Dimension size()

Deprecated. use getSize() instead

Returns the size of this object.
Returns:
the size of this object

toString

public String toString()
Returns a string representation of this component. This is implemented as getClass().getName() + '[' + paramString() + ']'.
Overrides:
toString in interface Object
Returns:
a string representation of this component

transferFocus

public void transferFocus()
Transfers focus to the next component in the focus traversal order, as though this were the current focus owner.
Since:
1.1

transferFocusBackward

public void transferFocusBackward()
Transfers focus to the previous component in the focus traversal order, as though this were the current focus owner.
Since:
1.4
See Also:
()

transferFocusUpCycle

public void transferFocusUpCycle()
Transfers focus to the focus cycle root of this component. However, if this is a Window, the default focus owner in the window in the current focus cycle is focused instead.
Since:
1.4

update

public void update(Graphics g)
Updates this component. This is called for heavyweight components in response to repaint(). The default implementation simply forwards to paint(Graphics). The coordinates of the graphics are relative to this component. Subclasses should call either super.update(g) or paint(g).
Parameters:
g - the graphics context for this update

validate

public void validate()
Called to ensure that the layout for this component is valid. This is usually called on containers.

Component.java -- a graphics component Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software Foundation This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.