java.awt
Class Component

java.lang.Object
  extended by java.awt.Component
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
Button, Canvas, Checkbox, Choice, Container, 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  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 center 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
protected 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, ImageObserver observer)
          Returns the status of the loading of the specified image.
 int checkImage(Image image, int width, int height, 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(ImageProducer producer)
          Creates an image from the specified producer.
 Image createImage(int width, int height)
          Creates an image with the specified width and height for use in double buffering.
 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.
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.
 void firePropertyChange(String propertyName, long oldValue, long 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, 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<AWTKeyStroke> 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.
<T extends EventListener>
T[]
getListeners(Class<T> listenerType)
          Returns all registered EventListeners of the given listenerType.
 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 isFocusable()
          Tests if this component can receive focus.
 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 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, ImageObserver observer)
          Prepares the specified image for rendering on this component.
 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
 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(Dimension d)
          Deprecated. use setSize(Dimension) instead
 void resize(int width, int height)
          Deprecated. use setSize(int, int) 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 setFocusable(boolean focusable)
          Specify whether this component can receive focus.
 void setFocusTraversalKeys(int id, Set<? extends 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 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(Dimension d)
          Sets the size of this component to the specified value.
 void setSize(int width, int height)
          Sets the size of this component to the specified width and height.
 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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

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.

See Also:
getAlignmentY(), Constant Field Values

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 center relative to other components.

See Also:
getAlignmentX(), getAlignmentY(), Constant Field Values

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.

See Also:
getAlignmentY(), Constant Field Values

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.

See Also:
getAlignmentX(), Constant Field Values

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.

See Also:
getAlignmentX(), Constant Field Values
Constructor Detail

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 Detail

getName

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

Returns:
the name of this component
Since:
1.1
See Also:
setName(String)

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()

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

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()

getDropTarget

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

Returns:
the drop target

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

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

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

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
See Also:
validate(), invalidate()

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
See Also:
Container.add(Component), Container.remove(Component), Window.pack(), Window.show(), Window.dispose()

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
See Also:
setVisible(boolean)

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
See Also:
setVisible(boolean)

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
See Also:
setEnabled(boolean)

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
See Also:
isEnabled(), isLightweight()

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

disable

public void disable()
Deprecated. use setEnabled(boolean) instead

Disables this component.


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

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
See Also:
processKeyEvent(KeyEvent)

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

hide

public void hide()
Deprecated. use setVisible(boolean) instead

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


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
See Also:
setForeground(Color)

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
See Also:
getForeground()

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

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
See Also:
setBackground(Color)

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
See Also:
getBackground()

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

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)

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()

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

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
See Also:
setLocale(Locale)

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

getColorModel

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

Returns:
this object's color model
See Also:
Toolkit.getColorModel()

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
See Also:
setLocation(int, int), getLocationOnScreen()

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

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

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
See Also:
getLocation(), setBounds(int, int, int, int)

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

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
See Also:
getLocation(), setBounds(int, int, int, int)

getSize

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

Returns:
the size of this object
Since:
1.1
See Also:
setSize(int, int)

size

public Dimension size()
Deprecated. use getSize() instead

Returns the size of this object.

Returns:
the size of this object

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
See Also:
getSize(), setBounds(int, int, int, int)

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

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
See Also:
setSize(int, int), setBounds(int, int, int, int)

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

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
See Also:
setBounds(int, int, int, int), getLocation(), getSize()

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

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
See Also:
getBounds(), setLocation(int, int), setLocation(Point), setSize(int, int), setSize(Dimension)

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

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
See Also:
getBounds(), setLocation(Point), setSize(Dimension)

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

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

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

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

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

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

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
See Also:
isLightweight()

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
See Also:
isDisplayable()

getPreferredSize

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

Returns:
the component's preferred size
See Also:
getMinimumSize(), setPreferredSize(Dimension), LayoutManager

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
See Also:
getPreferredSize()

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

preferredSize

public Dimension preferredSize()
Deprecated. use getPreferredSize() instead

Returns the component's preferred size.

Returns:
the component's preferred size

getMinimumSize

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

Returns:
the component's minimum size
See Also:
getPreferredSize(), setMinimumSize(Dimension), LayoutManager

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
See Also:
getMinimumSize()

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

minimumSize

public Dimension minimumSize()
Deprecated. use getMinimumSize() instead

Returns the component's minimum size.

Returns:
the component's minimum size

getMaximumSize

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

Returns:
the component's maximum size
See Also:
getMinimumSize(), setMaximumSize(Dimension), getPreferredSize(), LayoutManager

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
See Also:
getMaximumSize()

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

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

doLayout

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

See Also:
validate(), LayoutManager

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.


validate

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

See Also:
invalidate(), doLayout(), LayoutManager, Container.validate()

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.


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
See Also:
paint(Graphics)

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
See Also:
getFont(), Toolkit.getFontMetrics(Font)

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
See Also:
isEnabled(), isShowing(), getCursor(), contains(int, int), Toolkit.createCustomCursor(Image, Point, String)

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

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

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
See Also:
update(Graphics)

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
See Also:
paint(Graphics), repaint()

paintAll

public void paintAll(Graphics g)
Paints this entire component, including any sub-components.

Parameters:
g - the graphics context for this paint job
See Also:
paint(Graphics)

repaint

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

See Also:
update(Graphics), repaint(long, int, int, int, int)

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
See Also:
paint(Graphics), repaint(long, int, int, int, int)

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
See Also:
update(Graphics), repaint(long, int, int, int, int)

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
See Also:
update(Graphics)

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
See Also:
paint(Graphics)

printAll

public void printAll(Graphics g)
Prints this component, including all sub-components.

Parameters:
g - the graphics context of the print device
See Also:
paintAll(Graphics)

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.
See Also:
ImageObserver, Graphics.drawImage(Image, int, int, Color, ImageObserver), Graphics.drawImage(Image, int, int, ImageObserver), Graphics.drawImage(Image, int, int, int, int, Color, ImageObserver), Graphics.drawImage(Image, int, int, int, int, ImageObserver), ImageObserver.imageUpdate(Image, int, int, int, int, int)

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

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

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

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

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

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
See Also:
prepareImage(Image, int, int, ImageObserver), Toolkit.checkImage(Image, int, int, ImageObserver)

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
See Also:
prepareImage(Image, int, int, ImageObserver), Toolkit.checkImage(Image, int, int, ImageObserver)

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
See Also:
getIgnoreRepaint(), BufferStrategy, GraphicsDevice.setFullScreenWindow(Window)

getIgnoreRepaint

public boolean getIgnoreRepaint()
Test whether paint events from the operating system are ignored.

Returns:
the status of ignoring paint events
Since:
1.4
See Also:
setIgnoreRepaint(boolean)

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
See Also:
getComponentAt(int, int)

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

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
See Also:
getComponentAt(Point)

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
See Also:
contains(int, int)

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

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
See Also:
contains(Point)

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(java.awt.Event).

Parameters:
e - the event to deliver

dispatchEvent

public final void dispatchEvent(AWTEvent e)
Forwards AWT events to processEvent() if:

Parameters:
e - the event to dispatch

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

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
See Also:
ComponentEvent, removeComponentListener(ComponentListener), getComponentListeners()

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
See Also:
ComponentEvent, addComponentListener(ComponentListener), getComponentListeners()

getComponentListeners

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

Returns:
an array of listeners
Since:
1.4
See Also:
addComponentListener(ComponentListener), removeComponentListener(ComponentListener)

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
See Also:
FocusEvent, removeFocusListener(FocusListener), getFocusListeners()

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
See Also:
FocusEvent, addFocusListener(FocusListener), getFocusListeners()

getFocusListeners

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

Returns:
an array of listeners
Since:
1.4
See Also:
addFocusListener(FocusListener), removeFocusListener(FocusListener)

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
See Also:
HierarchyEvent, removeHierarchyListener(HierarchyListener), getHierarchyListeners()

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
See Also:
HierarchyEvent, addHierarchyListener(HierarchyListener), getHierarchyListeners()

getHierarchyListeners

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

Returns:
an array of listeners
Since:
1.4
See Also:
addHierarchyListener(HierarchyListener), removeHierarchyListener(HierarchyListener)

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
See Also:
HierarchyEvent, removeHierarchyBoundsListener(HierarchyBoundsListener), getHierarchyBoundsListeners()

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
See Also:
HierarchyEvent, addHierarchyBoundsListener(HierarchyBoundsListener), getHierarchyBoundsListeners()

getHierarchyBoundsListeners

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

Returns:
an array of listeners
Since:
1.4
See Also:
addHierarchyBoundsListener(HierarchyBoundsListener), removeHierarchyBoundsListener(HierarchyBoundsListener)

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
See Also:
KeyEvent, removeKeyListener(KeyListener), getKeyListeners()

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
See Also:
KeyEvent, addKeyListener(KeyListener), getKeyListeners()

getKeyListeners

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

Returns:
an array of listeners
Since:
1.4
See Also:
addKeyListener(KeyListener), removeKeyListener(KeyListener)

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
See Also:
MouseEvent, removeMouseListener(MouseListener), getMouseListeners()

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
See Also:
MouseEvent, addMouseListener(MouseListener), getMouseListeners()

getMouseListeners

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

Returns:
an array of listeners
Since:
1.4
See Also:
addMouseListener(MouseListener), removeMouseListener(MouseListener)

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
See Also:
MouseEvent, removeMouseMotionListener(MouseMotionListener), getMouseMotionListeners()

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
See Also:
MouseEvent, addMouseMotionListener(MouseMotionListener), getMouseMotionListeners()

getMouseMotionListeners

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

Returns:
an array of listeners
Since:
1.4
See Also:
addMouseMotionListener(MouseMotionListener), removeMouseMotionListener(MouseMotionListener)

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
See Also:
MouseEvent, MouseWheelEvent, removeMouseWheelListener(MouseWheelListener), getMouseWheelListeners()

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
See Also:
MouseEvent, MouseWheelEvent, addMouseWheelListener(MouseWheelListener), getMouseWheelListeners()

getMouseWheelListeners

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

Returns:
an array of listeners
Since:
1.4
See Also:
addMouseWheelListener(MouseWheelListener), removeMouseWheelListener(MouseWheelListener)

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
See Also:
InputMethodEvent, removeInputMethodListener(InputMethodListener), getInputMethodListeners(), getInputMethodRequests()

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
See Also:
InputMethodEvent, addInputMethodListener(InputMethodListener), getInputMethodRequests()

getInputMethodListeners

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

Returns:
an array of listeners
Since:
1.4
See Also:
addInputMethodListener(InputMethodListener), removeInputMethodListener(InputMethodListener)

getListeners

public <T extends EventListener> T[] getListeners(Class<T> 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
See Also:
getComponentListeners(), getFocusListeners(), getHierarchyListeners(), getHierarchyBoundsListeners(), getKeyListeners(), getMouseListeners(), getMouseMotionListeners(), getMouseWheelListeners(), getInputMethodListeners(), getPropertyChangeListeners()

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

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

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
See Also:
processEvent(AWTEvent), disableEvents(long), AWTEvent

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
See Also:
enableEvents(long)

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

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
See Also:
processComponentEvent(ComponentEvent), processFocusEvent(FocusEvent), processKeyEvent(KeyEvent), processMouseEvent(MouseEvent), processMouseMotionEvent(MouseEvent), processInputMethodEvent(InputMethodEvent), processHierarchyEvent(HierarchyEvent), processMouseWheelEvent(MouseWheelEvent)

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
See Also:
ComponentListener, addComponentListener(ComponentListener), enableEvents(long)

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
See Also:
FocusListener, addFocusListener(FocusListener), enableEvents(long)

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
See Also:
KeyListener, addKeyListener(KeyListener), enableEvents(long)

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
See Also:
MouseListener, addMouseListener(MouseListener), enableEvents(long)

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
See Also:
MouseMotionListener, addMouseMotionListener(MouseMotionListener), enableEvents(long)

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
See Also:
MouseWheelListener, addMouseWheelListener(MouseWheelListener), enableEvents(long)

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
See Also:
InputMethodListener, addInputMethodListener(InputMethodListener), enableEvents(long)

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
See Also:
HierarchyListener, addHierarchyListener(HierarchyListener), enableEvents(long)

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
See Also:
HierarchyBoundsListener, addHierarchyBoundsListener(HierarchyBoundsListener), enableEvents(long)

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

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

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

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

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

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

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

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.

See Also:
isDisplayable(), removeNotify()

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.

See Also:
isDisplayable(), addNotify()

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

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

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
See Also:
setFocusable(boolean)

isFocusable

public boolean isFocusable()
Tests if this component can receive focus.

Returns:
true if this component can receive focus
Since:
1.4

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

setFocusTraversalKeys

public void setFocusTraversalKeys(int id,
                                  Set<? extends 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_KEYS Normal forward traversal TAB on KEY_PRESSED, Ctrl-TAB on KEY_PRESSED
KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS Normal backward traversal Shift-TAB on KEY_PRESSED, Ctrl-Shift-TAB on KEY_PRESSED
KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS Go 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
See Also:
getFocusTraversalKeys(int), KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS

getFocusTraversalKeys

public Set<AWTKeyStroke> 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
See Also:
(int, Set), KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS

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
See Also:
(int), KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS

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)

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
See Also:
(boolean), (int, Set), (int)

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), (), (), ()

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
See Also:
requestFocus()

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

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

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.


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
See Also:
requestFocus(), isFocusCycleRoot(Container)

hasFocus

public boolean hasFocus()
Tests if this component is the focus owner. Use () instead.

Returns:
true if this component owns focus
Since:
1.2

isFocusOwner

public boolean isFocusOwner()
Tests if this component is the focus owner.

Returns:
true if this component owns focus
Since:
1.4

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
See Also:
remove(MenuComponent)

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
See Also:
add(PopupMenu)

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

toString

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

Overrides:
toString in class Object
Returns:
a string representation of this component
See Also:
Object.getClass(), Object.hashCode(), Class.getName(), Integer.toHexString(int)

list

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

See Also:
list(PrintStream)

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

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:

Parameters:
listener - the new listener to add
Since:
1.1
See Also:
removePropertyChangeListener(PropertyChangeListener), getPropertyChangeListeners(), addPropertyChangeListener(String, PropertyChangeListener)

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
See Also:
addPropertyChangeListener(PropertyChangeListener), getPropertyChangeListeners(), removePropertyChangeListener(String, PropertyChangeListener)

getPropertyChangeListeners

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

Returns:
an array of listeners
Since:
1.4
See Also:
addPropertyChangeListener(PropertyChangeListener), removePropertyChangeListener(PropertyChangeListener), getPropertyChangeListeners(String)

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:

Parameters:
propertyName - the property name to filter on
listener - the new listener to add
Since:
1.1
See Also:
removePropertyChangeListener(String, PropertyChangeListener), getPropertyChangeListeners(String), addPropertyChangeListener(PropertyChangeListener)

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
See Also:
addPropertyChangeListener(String, PropertyChangeListener), getPropertyChangeListeners(String), removePropertyChangeListener(PropertyChangeListener)

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
See Also:
addPropertyChangeListener(String, PropertyChangeListener), removePropertyChangeListener(String, PropertyChangeListener), getPropertyChangeListeners()

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

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

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

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,
                               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

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,
                               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

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

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)
See Also:
getComponentOrientation()

getComponentOrientation

public ComponentOrientation getComponentOrientation()
Determines the text layout orientation used by this component.

Returns:
the component orientation (this can be null)
See Also:
setComponentOrientation(ComponentOrientation)

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
See Also:
getComponentOrientation()

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

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