GNU Classpath (0.95) | |
Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.awt.Component
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.
Nested Class Summary | |
protected abstract class |
|
protected class |
|
protected class |
|
Field Summary | |
static float |
|
static float |
|
static float |
|
static float |
|
static float |
|
Fields inherited from interface java.awt.image.ImageObserver | |
ABORT , ALLBITS , ERROR , FRAMEBITS , HEIGHT , PROPERTIES , SOMEBITS , WIDTH |
Constructor Summary | |
|
Method Summary | |
boolean | |
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
boolean |
|
Rectangle |
|
int |
|
int |
|
protected AWTEvent |
|
boolean |
|
boolean | |
Image |
|
Image |
|
VolatileImage |
|
VolatileImage |
|
void |
|
void |
|
protected void |
|
void |
|
void |
|
void |
|
void |
|
protected void |
|
void |
|
|
|
protected void |
|
void |
|
void |
|
void |
|
void |
|
protected void |
|
protected void |
|
void |
|
void |
|
AccessibleContext |
|
float |
|
float |
|
Color |
|
Rectangle |
|
Rectangle | |
ColorModel |
|
Component |
|
Component |
|
ComponentListener[] |
|
ComponentOrientation |
|
Cursor |
|
DropTarget |
|
Container |
|
FocusListener[] |
|
Set |
|
boolean |
|
Font |
|
FontMetrics |
|
Color |
|
Graphics |
|
GraphicsConfiguration |
|
int |
|
HierarchyBoundsListener[] |
|
HierarchyListener[] |
|
boolean |
|
InputContext |
|
InputMethodListener[] |
|
InputMethodRequests |
|
KeyListener[] |
|
Locale |
|
Point |
|
Point |
|
Point |
|
Dimension |
|
Dimension |
|
MouseListener[] |
|
MouseMotionListener[] |
|
MouseWheelListener[] |
|
String |
|
Container |
|
ComponentPeer |
|
Dimension |
|
PropertyChangeListener[] |
|
PropertyChangeListener[] |
|
Dimension |
|
Dimension | |
Toolkit |
|
Object |
|
int |
|
int |
|
int |
|
boolean |
|
boolean |
|
boolean |
|
void |
|
boolean |
|
boolean |
|
void |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
Component |
|
Point |
|
boolean |
|
Dimension |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
void |
|
void | |
void | |
void | |
protected String |
|
boolean |
|
Dimension |
|
boolean |
|
boolean |
|
void | |
void | |
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
protected boolean |
|
boolean |
|
protected boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void |
|
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void |
|
void |
|
void | |
void |
|
void |
|
void |
|
void |
|
void | |
void |
|
void |
|
void | |
void |
|
void |
|
void |
|
Dimension | |
String |
|
void |
|
void |
|
void |
|
void | |
void |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static final float BOTTOM_ALIGNMENT
Constant returned by thegetAlignmentY
method to indicate that the component wishes to be aligned to the bottom relative to other components.
- Field Value:
- 1.0f
- See Also:
getAlignmentY()
public static final float CENTER_ALIGNMENT
Constant returned by thegetAlignmentY
andgetAlignmentX
methods to indicate that the component wishes to be aligned to the center relative to other components.
- Field Value:
- 0.0f
- See Also:
getAlignmentX()
,getAlignmentY()
public static final float LEFT_ALIGNMENT
Constant returned by thegetAlignmentX
method to indicate that the component wishes to be aligned to the left relative to other components.
- Field Value:
- 0.0f
- See Also:
getAlignmentX()
public static final float RIGHT_ALIGNMENT
Constant returned by thegetAlignmentX
method to indicate that the component wishes to be aligned to the right relative to other components.
- Field Value:
- 1.0f
- See Also:
getAlignmentX()
public static final float TOP_ALIGNMENT
Constant returned by thegetAlignmentY
method to indicate that the component wishes to be aligned to the top relative to other components.
- Field Value:
- 0.0f
- See Also:
getAlignmentY()
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.
public boolean action(Event evt, Object what)
Deprecated. in classes which support actions, use
processActionEvent(ActionEvent)
insteadAWT 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 handlewhat
- the object acted on, ignored
- Returns:
- false
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)
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
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
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
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
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
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
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
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
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
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()
public void addPropertyChangeListener(PropertyChangeListener listener)
Adds the specified property listener to this component. This is harmless if the listener is null, but if the listener has already been registered, it will now be registered twice. The property listener ignores inherited properties. Recognized properties include:
- the font (
"font"
)- the background color (
"background"
)- the foreground color (
"foreground"
)- the focusability (
"focusable"
)- the focus key traversal enabled state (
"focusTraversalKeysEnabled"
)- the set of forward traversal keys (
"forwardFocusTraversalKeys"
)- the set of backward traversal keys (
"backwardFocusTraversalKeys"
)- the set of up-cycle traversal keys (
"upCycleFocusTraversalKeys"
)
- Parameters:
listener
- the new listener to add
- Since:
- 1.1
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
Adds the specified property listener to this component. This is harmless if the listener is null, but if the listener has already been registered, it will now be registered twice. The property listener ignores inherited properties. The listener is keyed to a single property. Recognized properties include:
- the font (
"font"
)- the background color (
"background"
)- the foreground color (
"foreground"
)- the focusability (
"focusable"
)- the focus key traversal enabled state (
"focusTraversalKeysEnabled"
)- the set of forward traversal keys (
"forwardFocusTraversalKeys"
)- the set of backward traversal keys (
"backwardFocusTraversalKeys"
)- the set of up-cycle traversal keys (
"upCycleFocusTraversalKeys"
)
- Parameters:
propertyName
- the property name to filter onlistener
- the new listener to add
- Since:
- 1.1
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, whilesetComponentOrientation(ComponentOrientation)
affects only the current component.
- Parameters:
o
- the new orientation
- Throws:
NullPointerException
- if o is null
- Since:
- 1.4
- See Also:
getComponentOrientation()
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
public Rectangle bounds()
Deprecated. use
getBounds()
insteadReturns 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
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 inImageObserver
.
- Parameters:
image
- the image to check onwidth
- the scaled image widthheight
- the scaled image heightobserver
- the observer to notify of image loading progress
- Returns:
- the image observer flags indicating the status of the load
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 inImageObserver
.
- Parameters:
image
- the image to check onobserver
- 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
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 queuenewEvent
- the new event that might be entered on the queue
- Returns:
- null if both events are kept, or the replacement coelesced event
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 testy
- the Y coordinate of the point to test
- Returns:
- true if the point is within this component
- See Also:
getComponentAt(int,int)
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)
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 imageheight
- the height of the image
- Returns:
- the requested image, or null if it is not supported
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
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 imageheight
- the height of the image
- Returns:
- the requested image, or null if it is not supported
- Since:
- 1.4
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 imageheight
- the height of the imagecaps
- 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
public void deliverEvent(Event e)
Deprecated. use
(AWTEvent)
insteadAWT 1.0 event delivery. Deliver an AWT 1.0 event to this Component. This method simply callspostEvent(Event)
.
- Parameters:
e
- the event to deliver
protected final void disableEvents(long eventsToDisable)
Disables the specified events. The events to disable are specified by OR-ing together the desired masks fromAWTEvent
.
- Parameters:
eventsToDisable
- the desired events to disable
- Since:
- 1.1
- See Also:
enableEvents(long)
public final void dispatchEvent(AWTEvent e)
Forwards AWT events to processEvent() if:
- Events have been enabled for this type of event via
enableEvents()
- There is at least one registered listener for this type of event
- Parameters:
e
- the event to dispatch
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
public void enable(boolean enabled)
Deprecated. use
setEnabled(boolean)
insteadEnables or disables this component.
- Parameters:
enabled
- true to enable this component
protected final void enableEvents(long eventsToEnable)
Enables the specified events. The events to enable are specified by OR-ing together the desired masks fromAWTEvent
. 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
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)
publicextends EventListener> T[] getListeners(Class listenerType)
Returns all registeredEventListener
s of the givenlistenerType
.
- Parameters:
listenerType
- the class of listeners to filter (null
not permitted).
- Returns:
- An array of registered listeners.
- Throws:
ClassCastException
- iflistenerType
does not implement theEventListener
interface.NullPointerException
- iflistenerType
isnull
.
- Since:
- 1.3
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 changedoldValue
- the old property valuenewValue
- the new property value
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 changedoldValue
- the old property valuenewValue
- the new property value
- Since:
- 1.5
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 changedoldValue
- the old property valuenewValue
- the new property value
- Since:
- 1.5
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 changedoldValue
- the old property valuenewValue
- the new property value
- Since:
- 1.5
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 changedoldValue
- the old property valuenewValue
- the new property value
- Since:
- 1.5
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 changedoldValue
- the old property valuenewValue
- the new property value
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 changedoldValue
- the old property valuenewValue
- the new property value
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 changedoldValue
- the old property valuenewValue
- the new property value
- Since:
- 1.5
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 changedoldValue
- the old property valuenewValue
- the new property value
- Since:
- 1.5
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 ofComponent.AccessibleAWTComponent
.
- Returns:
- the accessibility context
public float getAlignmentX()
Returns the preferred horizontal alignment of this component. The value returned will be betweenLEFT_ALIGNMENT
andRIGHT_ALIGNMENT
, inclusive.
- Returns:
- the preferred horizontal alignment of this component
public float getAlignmentY()
Returns the preferred vertical alignment of this component. The value returned will be betweenTOP_ALIGNMENT
andBOTTOM_ALIGNMENT
, inclusive.
- Returns:
- the preferred vertical alignment of this component
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)
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()
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
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()
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, ornull
if neither of the first two occupies the specified location.
- Parameters:
x
- the X coordinate to search for components aty
- the Y coordinate to search for components at
- Returns:
- the component at the specified location, or null
- See Also:
contains(int,int)
public Component getComponentAt(Point p)
Returns the component occupying the position (x,y). This will either be this component, an immediate child component, ornull
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)
public ComponentListener[] getComponentListeners()
Returns an array of all specified listeners registered on this component.
- Returns:
- an array of listeners
- Since:
- 1.4
public ComponentOrientation getComponentOrientation()
Determines the text layout orientation used by this component.
- Returns:
- the component orientation (this can be
null
)
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
public DropTarget getDropTarget()
Gets the associated drag-and-drop target, if there is one.
- Returns:
- the drop target
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
public FocusListener[] getFocusListeners()
Returns an array of all specified listeners registered on this component.
- Returns:
- an array of listeners
- Since:
- 1.4
public SetgetFocusTraversalKeys(int id)
Returns the set of keys for a given focus traversal action, as defined insetFocusTraversalKeys
. 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
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)
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)
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)
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)
public Graphics getGraphics()
Returns a graphics object for this component. Returnsnull
if this component is not currently displayed on the screen.
- Returns:
- a graphics object for this component
- See Also:
paint(Graphics)
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
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
public HierarchyBoundsListener[] getHierarchyBoundsListeners()
Returns an array of all specified listeners registered on this component.
- Returns:
- an array of listeners
- Since:
- 1.4
public HierarchyListener[] getHierarchyListeners()
Returns an array of all specified listeners registered on this component.
- Returns:
- an array of listeners
- Since:
- 1.4
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)
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
public InputMethodListener[] getInputMethodListeners()
Returns an array of all specified listeners registered on this component.
- Returns:
- an array of listeners
- Since:
- 1.4
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
public KeyListener[] getKeyListeners()
Returns an array of all specified listeners registered on this component.
- Returns:
- an array of listeners
- Since:
- 1.4
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)
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()
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
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
public Dimension getMaximumSize()
Returns the component's maximum size.
- Returns:
- the component's maximum size
public Dimension getMinimumSize()
Returns the component's minimum size.
- Returns:
- the component's minimum size
public MouseListener[] getMouseListeners()
Returns an array of all specified listeners registered on this component.
- Returns:
- an array of listeners
- Since:
- 1.4
public MouseMotionListener[] getMouseMotionListeners()
Returns an array of all specified listeners registered on this component.
- Returns:
- an array of listeners
- Since:
- 1.4
public MouseWheelListener[] getMouseWheelListeners()
Returns an array of all specified listeners registered on this component.
- Returns:
- an array of listeners
- Since:
- 1.4
public String getName()
Returns the name of this component.
- Returns:
- the name of this component
- Since:
- 1.1
- See Also:
setName(String)
public Container getParent()
Returns the parent of this component.
- Returns:
- the parent of this component
public ComponentPeer getPeer()
Deprecated. user programs should not directly manipulate peers; use
isDisplayable()
insteadReturns the native windowing system peer for this component. Only the platform specific implementation code should call this method.
- Returns:
- the peer for this component
public Dimension getPreferredSize()
Returns the component's preferred size.
- Returns:
- the component's preferred size
public PropertyChangeListener[] getPropertyChangeListeners()
Returns an array of all specified listeners registered on this component.
- Returns:
- an array of listeners
- Since:
- 1.4
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
public Dimension getSize()
Returns the size of this object.
- Returns:
- the size of this object
- Since:
- 1.1
- See Also:
setSize(int,int)
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
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
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
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
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
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
public boolean gotFocus(Event evt, Object what)
Deprecated. use
processFocusEvent(FocusEvent)
insteadAWT 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 handlewhat
- the Object focused, ignored
- Returns:
- false
public boolean handleEvent(Event evt)
Deprecated. use
processEvent(AWTEvent)
insteadAWT 1.0 event handler. This method calls one of the event-specific handler methods. For example for key events, eitherkeyDown(Event,int)
orkeyUp(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
public boolean hasFocus()
Tests if this component is the focus owner. Use()
instead.
- Returns:
- true if this component owns focus
- Since:
- 1.2
public void hide()
Deprecated. use
setVisible(boolean)
insteadHides this component so that it is no longer shown on the screen.
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 propertyawt.image.incrementalDraw
is not present or is true, in which case the redraw rate is set to 100ms or the value of the system propertyawt.image.redrawrate
. The coordinate system used depends on the particular flags.
- Specified by:
- imageUpdate in interface ImageObserver
- Parameters:
img
- the image that has been updatedflags
- tlags as specified inImageObserver
x
- the X coordinatey
- the Y coordinatew
- the widthh
- 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)
public boolean inside(int x, int y)
Deprecated. use
contains(int,int)
insteadTests 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 testy
- the Y coordinate of the point to test
- Returns:
- true if the point is within this component
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.
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
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
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
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
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)
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
public boolean isFocusOwner()
Tests if this component is the focus owner.
- Returns:
- true if this component owns focus
- Since:
- 1.4
public boolean isFocusTraversable()
Deprecated. use
isFocusable()
insteadTests 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)
public boolean isFocusable()
Tests if this component can receive focus.
- Returns:
- true if this component can receive focus
- Since:
- 1.4
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
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
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()
public boolean isMaximumSizeSet()
Returnstrue
if the current maximum size is notnull
and was set by a call tosetMaximumSize(Dimension)
, otherwise returnsfalse
.
- Returns:
- A boolean.
- Since:
- 1.5
public boolean isMinimumSizeSet()
Returnstrue
if the current minimum size is notnull
and was set by a call tosetMinimumSize(Dimension)
, otherwise returnsfalse
.
- Returns:
- A boolean.
- Since:
- 1.5
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()
public boolean isPreferredSizeSet()
Returnstrue
if the current preferred size is notnull
and was set by a call tosetPreferredSize(Dimension)
, otherwise returnsfalse
.
- Returns:
- A boolean.
- Since:
- 1.5
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)
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()
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)
public boolean keyDown(Event evt, int key)
Deprecated. use
processKeyEvent(KeyEvent)
insteadAWT 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 handlekey
- the key pressed, ignored
- Returns:
- false
public boolean keyUp(Event evt, int key)
Deprecated. use
processKeyEvent(KeyEvent)
insteadAWT 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 handlekey
- the key pressed, ignored
- Returns:
- false
public void layout()
Deprecated. use
doLayout()
insteadCalls the layout manager to re-layout the component. This is called during validation of a container in most cases.
public void list(PrintStream out)
Prints a listing of this component to the specified print stream.
- Parameters:
out
- thePrintStream
to print to
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
- thePrintStream
to print toindent
- the indentation point
public void list(PrintWriter out)
Prints a listing of this component to the specified print writer.
- Parameters:
out
- thePrintWrinter
to print to
- Since:
- 1.1
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
- thePrintWriter
to print toindent
- the indentation point
- Since:
- 1.1
public Component locate(int x, int y)
Deprecated. use
getComponentAt(int,int)
insteadReturns the component occupying the position (x,y). This will either be this component, an immediate child component, ornull
if neither of the first two occupies the specified location.
- Parameters:
x
- the X coordinate to search for components aty
- the Y coordinate to search for components at
- Returns:
- the component at the specified location, or null
public Point location()
Deprecated. use
getLocation()
insteadReturns the location of this component's top left corner relative to its parent component.
- Returns:
- the location of this component
public boolean lostFocus(Event evt, Object what)
Deprecated. use
processFocusEvent(FocusEvent)
insteadAWT 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 handlewhat
- the Object focused, ignored
- Returns:
- false
public Dimension minimumSize()
Deprecated. use
getMinimumSize()
insteadReturns the component's minimum size.
- Returns:
- the component's minimum size
public boolean mouseDown(Event evt, int x, int y)
Deprecated. use
processMouseEvent(MouseEvent)
insteadAWT 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 handlex
- the x coordinate, ignoredy
- the y coordinate, ignored
- Returns:
- false
public boolean mouseDrag(Event evt, int x, int y)
Deprecated. use
processMouseMotionEvent(MouseEvent)
insteadAWT 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 handlex
- the x coordinate, ignoredy
- the y coordinate, ignored
- Returns:
- false
public boolean mouseEnter(Event evt, int x, int y)
Deprecated. use
processMouseEvent(MouseEvent)
insteadAWT 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 handlex
- the x coordinate, ignoredy
- the y coordinate, ignored
- Returns:
- false
public boolean mouseExit(Event evt, int x, int y)
Deprecated. use
processMouseEvent(MouseEvent)
insteadAWT 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 handlex
- the x coordinate, ignoredy
- the y coordinate, ignored
- Returns:
- false
public boolean mouseMove(Event evt, int x, int y)
Deprecated. use
processMouseMotionEvent(MouseEvent)
insteadAWT 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 handlex
- the x coordinate, ignoredy
- the y coordinate, ignored
- Returns:
- false
public boolean mouseUp(Event evt, int x, int y)
Deprecated. use
processMouseEvent(MouseEvent)
insteadAWT 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 handlex
- the x coordinate, ignoredy
- the y coordinate, ignored
- Returns:
- false
public void move(int x, int y)
Deprecated. use
setLocation(int,int)
insteadMoves 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 componenty
- the new Y coordinate of this component
public void nextFocus()
Deprecated. use
()
insteadAWT 1.0 focus event processor. Transfers focus to the next component in the focus traversal order, as though this were the current focus owner.
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 callsuper.paint(g)
. Components with no area are not painted.
- Parameters:
g
- the graphics context for this paint job
- See Also:
update(Graphics)
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)
protected String paramString()
Returns a debugging string representing this component. The string may be empty but not null.
- Returns:
- a string representing this component
public boolean postEvent(Event e)
Deprecated. use
dispatchEvent(AWTEvent)
insteadAWT 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
public Dimension preferredSize()
Deprecated. use
getPreferredSize()
insteadReturns the component's preferred size.
- Returns:
- the component's preferred size
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 renderingwidth
- the scaled width of the imageheight
- the scaled height of the imageobserver
- the observer to notify of image preparation status
- Returns:
- true if the image is already fully prepared
public boolean prepareImage(Image image, ImageObserver observer)
Prepares the specified image for rendering on this component.
- Parameters:
image
- the image to prepare for renderingobserver
- the observer to notify of image preparation status
- Returns:
- true if the image is already fully prepared
- Throws:
NullPointerException
- if image is null
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 thepaint()
method.
- Parameters:
g
- the graphics context of the print device
- See Also:
paint(Graphics)
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)
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
- theComponentEvent
to process
- Throws:
NullPointerException
- if e is null
- Since:
- 1.1
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
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
- theFocusEvent
to process
- Throws:
NullPointerException
- if e is null
- Since:
- 1.1
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
- theHierarchyEvent
to process
- Throws:
NullPointerException
- if e is null
- Since:
- 1.3
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
- theHierarchyEvent
to process
- Throws:
NullPointerException
- if e is null
- Since:
- 1.3
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
- theInputMethodEvent
to process
- Throws:
NullPointerException
- if e is null
- Since:
- 1.2
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
- theKeyEvent
to process
- Throws:
NullPointerException
- if e is null
- Since:
- 1.1
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
- theMouseEvent
to process
- Throws:
NullPointerException
- if e is null
- Since:
- 1.1
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
- theMouseMotionEvent
to process
- Throws:
NullPointerException
- if e is null
- Since:
- 1.1
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
- theMouseWheelEvent
to process
- Throws:
NullPointerException
- if e is null
- Since:
- 1.4
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)
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
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
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
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
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
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()
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
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
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
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()
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
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 onlistener
- the listener to remove
- Since:
- 1.1
public void repaint()
Repaint this entire component. Theupdate()
method on this component will be called as soon as possible.
public void repaint(int x, int y, int w, int h)
Repaints the specified rectangular region within this component. Theupdate
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 repainty
- the Y coordinate of the upper left of the region to repaintw
- the width of the region to repainth
- the height of the region to repaint
public void repaint(long tm)
Repaint this entire component. Theupdate()
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)
public void repaint(long tm, int x, int y, int width, int height)
Repaints the specified rectangular region within this component. Theupdate
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 repaintedx
- the X coordinate of the upper left of the region to repainty
- the Y coordinate of the upper left of the region to repaintwidth
- the width of the region to repaintheight
- the height of the region to repaint
- See Also:
update(Graphics)
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)
,()
,()
,()
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)
,()
,()
,()
public boolean requestFocusInWindow()
Request that this component be given the keyboard input focus, if its top-level ancestor is the currently focused Window. AFOCUS_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)
,()
,()
,()
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. AFOCUS_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)
,()
,()
,()
public void reshape(int x, int y, int width, int height)
Deprecated. use
setBounds(int,int,int,int)
insteadSets 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 rectangley
- the Y coordinate of the upper left corner of the rectanglewidth
- the width of the rectangleheight
- the height of the rectangle
public void resize(int width, int height)
Deprecated. use
setSize(int,int)
insteadSets the size of this component to the specified value.
- Parameters:
width
- the new width of the componentheight
- the new height of the component
public void resize(Dimension d)
Deprecated. use
setSize(Dimension)
insteadSets the size of this component to the specified value.
- Parameters:
d
- the new size of this component
- Throws:
NullPointerException
- if d is null
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()
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 rectangley
- the Y coordinate of the upper left corner of the rectanglew
- the width of the rectangleh
- the height of the rectangle
- Since:
- 1.1
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)
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, whileapplyComponentOrientation(ComponentOrientation)
affects the entire hierarchy.
- Parameters:
o
- the new orientation (null
is accepted)
- See Also:
getComponentOrientation()
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
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()
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()
public void setFocusTraversalKeys(int id, AWTKeyStroke> keystrokes)
Sets the focus traversal keys for one of the three focus traversal directions supported by Components:KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS
,KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS
, orKeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS
. Normally, the default values should match the operating system's native choices. To disable a given traversal, useCollections.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: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.
Identifier Meaning Default 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 cycle None
- Parameters:
id
- one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS, or UP_CYCLE_TRAVERSAL_KEYSkeystrokes
- a set of keys, or null
- Throws:
IllegalArgumentException
- if id or keystrokes is invalid
- Since:
- 1.4
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)
public void setFocusable(boolean focusable)
Specify whether this component can receive focus. This method also sets theisFocusTraversableOverridden
field to 1, which appears to be the undocumented wayDefaultFocusTraversalPolicy.accept(Component)
determines whether to respect theisFocusable()
method of the component.
- Parameters:
focusable
- the new focusable status
- Since:
- 1.4
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()
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()
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
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
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 componenty
- the new Y coordinate of this component
- See Also:
getLocation()
,setBounds(int,int,int,int)
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)
public void setMaximumSize(Dimension size)
Sets the maximum size that will be returned bygetMaximumSize()
always, and sends aPropertyChangeEvent
(with the property name 'maximumSize') to all registered listeners.
- Parameters:
size
- the maximum size (null
permitted).
- Since:
- 1.5
- See Also:
getMaximumSize()
public void setMinimumSize(Dimension size)
Sets the minimum size that will be returned bygetMinimumSize()
always, and sends aPropertyChangeEvent
(with the property name 'minimumSize') to all registered listeners.
- Parameters:
size
- the minimum size (null
permitted).
- Since:
- 1.5
- See Also:
getMinimumSize()
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()
public void setPreferredSize(Dimension size)
Sets the preferred size that will be returned bygetPreferredSize()
always, and sends aPropertyChangeEvent
(with the property name 'preferredSize') to all registered listeners.
- Parameters:
size
- the preferred size (null
permitted).
- Since:
- 1.5
- See Also:
getPreferredSize()
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 componentheight
- the new height of this component
- See Also:
getSize()
,setBounds(int,int,int,int)
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)
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()
public void show()
Deprecated. use
setVisible(boolean)
insteadMakes this component visible on the screen.
public void show(boolean visible)
Deprecated. use
setVisible(boolean)
insteadMakes this component visible or invisible.
- Parameters:
visible
- true to make this component visible
public Dimension size()
Deprecated. use
getSize()
insteadReturns the size of this object.
- Returns:
- the size of this object
public String toString()
Returns a string representation of this component. This is implemented asgetClass().getName() + '[' + paramString() + ']'
.
- Returns:
- a string representation of this component
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()
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:
()
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)
public void update(Graphics g)
Updates this component. This is called for heavyweight components in response torepaint()
. The default implementation simply forwards topaint(Graphics)
. The coordinates of the graphics are relative to this component. Subclasses should call eithersuper.update(g)
orpaint(g)
.
- Parameters:
g
- the graphics context for this update
- See Also:
paint(Graphics)
,repaint()
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()
GNU Classpath (0.95) |