|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
public abstract class Component
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.
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. |
|
|
getListeners(Class<T> listenerType)
Returns all registered EventListener s 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 |
---|
public static final float TOP_ALIGNMENT
getAlignmentY
method to indicate
that the component wishes to be aligned to the top relative to
other components.
getAlignmentY()
,
Constant Field Valuespublic static final float CENTER_ALIGNMENT
getAlignmentY
and
getAlignmentX
methods to indicate
that the component wishes to be aligned to the center relative to
other components.
getAlignmentX()
,
getAlignmentY()
,
Constant Field Valuespublic static final float BOTTOM_ALIGNMENT
getAlignmentY
method to indicate
that the component wishes to be aligned to the bottom relative to
other components.
getAlignmentY()
,
Constant Field Valuespublic static final float RIGHT_ALIGNMENT
getAlignmentX
method to indicate
that the component wishes to be aligned to the right relative to
other components.
getAlignmentX()
,
Constant Field Valuespublic static final float LEFT_ALIGNMENT
getAlignmentX
method to indicate
that the component wishes to be aligned to the left relative to
other components.
getAlignmentX()
,
Constant Field ValuesConstructor Detail |
---|
protected Component()
Method Detail |
---|
public String getName()
setName(String)
public void setName(String name)
name
- the new name (null
permitted).getName()
public Container getParent()
public ComponentPeer getPeer()
isDisplayable()
instead
public void setDropTarget(DropTarget dt)
dt
- the new drop targetisEnabled()
public DropTarget getDropTarget()
public GraphicsConfiguration getGraphicsConfiguration()
public final Object getTreeLock()
public Toolkit getToolkit()
public boolean isValid()
validate()
,
invalidate()
public boolean isDisplayable()
Container.add(Component)
,
Container.remove(Component)
,
Window.pack()
,
Window.show()
,
Window.dispose()
public boolean isVisible()
setVisible(boolean)
public boolean isShowing()
setVisible(boolean)
public boolean isEnabled()
setEnabled(boolean)
public void setEnabled(boolean enabled)
enabled
- true to enable this componentisEnabled()
,
isLightweight()
public void enable()
setEnabled(boolean)
instead
public void enable(boolean enabled)
setEnabled(boolean)
instead
enabled
- true to enable this componentpublic void disable()
setEnabled(boolean)
instead
public boolean isDoubleBuffered()
public void enableInputMethods(boolean enable)
enable
- true to enable input method processingprocessKeyEvent(KeyEvent)
public void setVisible(boolean visible)
visible
- true to make this component visibleisVisible()
public void show()
setVisible(boolean)
instead
public void show(boolean visible)
setVisible(boolean)
instead
visible
- true to make this component visiblepublic void hide()
setVisible(boolean)
instead
public Color getForeground()
setForeground(Color)
public void setForeground(Color c)
c
- the new foreground colorgetForeground()
public boolean isForegroundSet()
public Color getBackground()
setBackground(Color)
public void setBackground(Color c)
c
- the new background colorgetBackground()
public boolean isBackgroundSet()
public Font getFont()
getFont
in interface MenuContainer
setFont(Font)
public void setFont(Font f)
f
- the new font for this componentgetFont()
public boolean isFontSet()
public Locale getLocale()
IllegalComponentStateException
- if it has no locale or parentsetLocale(Locale)
public void setLocale(Locale newLocale)
newLocale
- the new locale for this componentpublic ColorModel getColorModel()
Toolkit.getColorModel()
public Point getLocation()
setLocation(int, int)
,
getLocationOnScreen()
public Point getLocationOnScreen()
IllegalComponentStateException
- if the component is not showingpublic Point location()
getLocation()
instead
public void setLocation(int x, int y)
x
- the new X coordinate of this componenty
- the new Y coordinate of this componentgetLocation()
,
setBounds(int, int, int, int)
public void move(int x, int y)
setLocation(int, int)
instead
x
- the new X coordinate of this componenty
- the new Y coordinate of this componentpublic void setLocation(Point p)
p
- new coordinates for this component
NullPointerException
- if p is nullgetLocation()
,
setBounds(int, int, int, int)
public Dimension getSize()
setSize(int, int)
public Dimension size()
getSize()
instead
public void setSize(int width, int height)
width
- the new width of this componentheight
- the new height of this componentgetSize()
,
setBounds(int, int, int, int)
public void resize(int width, int height)
setSize(int, int)
instead
width
- the new width of the componentheight
- the new height of the componentpublic void setSize(Dimension d)
d
- the new size of this component
NullPointerException
- if d is nullsetSize(int, int)
,
setBounds(int, int, int, int)
public void resize(Dimension d)
setSize(Dimension)
instead
d
- the new size of this component
NullPointerException
- if d is nullpublic Rectangle getBounds()
setBounds(int, int, int, int)
,
getLocation()
,
getSize()
public Rectangle bounds()
getBounds()
instead
public void setBounds(int x, int y, int w, int h)
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 rectanglegetBounds()
,
setLocation(int, int)
,
setLocation(Point)
,
setSize(int, int)
,
setSize(Dimension)
public void reshape(int x, int y, int width, int height)
setBounds(int, int, int, int)
instead
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 rectanglepublic void setBounds(Rectangle r)
r
- the new bounding rectangle
NullPointerException
- if r is nullgetBounds()
,
setLocation(Point)
,
setSize(Dimension)
public int getX()
public int getY()
public int getWidth()
public int getHeight()
public Rectangle getBounds(Rectangle r)
r
- the rectangle to use, or null
public Dimension getSize(Dimension d)
d
- the dimension to use, or null
public Point getLocation(Point p)
p
- the point to use, or null
public boolean isOpaque()
isLightweight()
public boolean isLightweight()
isDisplayable()
public Dimension getPreferredSize()
getMinimumSize()
,
setPreferredSize(Dimension)
,
LayoutManager
public void setPreferredSize(Dimension size)
getPreferredSize()
always, and sends a
PropertyChangeEvent
(with the property name 'preferredSize') to
all registered listeners.
size
- the preferred size (null
permitted).getPreferredSize()
public boolean isPreferredSizeSet()
true
if the current preferred size is not
null
and was set by a call to
setPreferredSize(Dimension)
, otherwise returns false
.
public Dimension preferredSize()
getPreferredSize()
instead
public Dimension getMinimumSize()
getPreferredSize()
,
setMinimumSize(Dimension)
,
LayoutManager
public void setMinimumSize(Dimension size)
getMinimumSize()
always, and sends a PropertyChangeEvent
(with the property name
'minimumSize') to all registered listeners.
size
- the minimum size (null
permitted).getMinimumSize()
public boolean isMinimumSizeSet()
true
if the current minimum size is not
null
and was set by a call to
setMinimumSize(Dimension)
, otherwise returns false
.
public Dimension minimumSize()
getMinimumSize()
instead
public Dimension getMaximumSize()
getMinimumSize()
,
setMaximumSize(Dimension)
,
getPreferredSize()
,
LayoutManager
public void setMaximumSize(Dimension size)
getMaximumSize()
always, and sends a PropertyChangeEvent
(with the property name
'maximumSize') to all registered listeners.
size
- the maximum size (null
permitted).getMaximumSize()
public boolean isMaximumSizeSet()
true
if the current maximum size is not
null
and was set by a call to
setMaximumSize(Dimension)
, otherwise returns false
.
public float getAlignmentX()
LEFT_ALIGNMENT
and
RIGHT_ALIGNMENT
, inclusive.
public float getAlignmentY()
TOP_ALIGNMENT
and
BOTTOM_ALIGNMENT
, inclusive.
public void doLayout()
validate()
,
LayoutManager
public void layout()
doLayout()
instead
public void validate()
invalidate()
,
doLayout()
,
LayoutManager
,
Container.validate()
public void invalidate()
public Graphics getGraphics()
null
if this component is not currently displayed on the screen.
paint(Graphics)
public FontMetrics getFontMetrics(Font font)
font
- the font to retrieve metrics for
NullPointerException
- if font is nullgetFont()
,
Toolkit.getFontMetrics(Font)
public void setCursor(Cursor cursor)
cursor
- the new cursor for this componentisEnabled()
,
isShowing()
,
getCursor()
,
contains(int, int)
,
Toolkit.createCustomCursor(Image, Point, String)
public Cursor getCursor()
public boolean isCursorSet()
public void paint(Graphics g)
super.paint(g)
. Components with no area
are not painted.
g
- the graphics context for this paint jobupdate(Graphics)
public void update(Graphics g)
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)
.
g
- the graphics context for this updatepaint(Graphics)
,
repaint()
public void paintAll(Graphics g)
g
- the graphics context for this paint jobpaint(Graphics)
public void repaint()
update()
method
on this component will be called as soon as possible.
update(Graphics)
,
repaint(long, int, int, int, int)
public void repaint(long tm)
update()
method on this
component will be called in approximate the specified number of
milliseconds.
tm
- milliseconds before this component should be repaintedpaint(Graphics)
,
repaint(long, int, int, int, int)
public void repaint(int x, int y, int w, int h)
update
method on this component will be called as soon as
possible. The coordinates are relative to this component.
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 repaintupdate(Graphics)
,
repaint(long, int, int, int, int)
public void repaint(long tm, int x, int y, int width, int height)
update
method on this component will be called in
approximately the specified number of milliseconds. The coordinates
are relative to this component.
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 repaintupdate(Graphics)
public void print(Graphics g)
paint()
method.
g
- the graphics context of the print devicepaint(Graphics)
public void printAll(Graphics g)
g
- the graphics context of the print devicepaintAll(Graphics)
public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h)
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.
imageUpdate
in interface ImageObserver
img
- the image that has been updatedflags
- tlags as specified in ImageObserver
x
- the X coordinatey
- the Y coordinatew
- the widthh
- the height
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 Image createImage(ImageProducer producer)
producer
- the image procedure to create the image from
public Image createImage(int width, int height)
width
- the width of the imageheight
- the height of the image
public VolatileImage createVolatileImage(int width, int height)
width
- the width of the imageheight
- the height of the image
public VolatileImage createVolatileImage(int width, int height, ImageCapabilities caps) throws AWTException
width
- the width of the imageheight
- the height of the imagecaps
- the requested capabilities
AWTException
- if a buffer with the capabilities cannot be createdpublic boolean prepareImage(Image image, ImageObserver observer)
image
- the image to prepare for renderingobserver
- the observer to notify of image preparation status
NullPointerException
- if image is nullpublic boolean prepareImage(Image image, int width, int height, ImageObserver observer)
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
public int checkImage(Image image, ImageObserver observer)
ImageObserver
.
image
- the image to check onobserver
- the observer to notify of image loading progress
NullPointerException
- if image is nullprepareImage(Image, int, int, ImageObserver)
,
Toolkit.checkImage(Image, int, int, ImageObserver)
public int checkImage(Image image, int width, int height, ImageObserver observer)
ImageObserver
.
image
- the image to check onwidth
- the scaled image widthheight
- the scaled image heightobserver
- the observer to notify of image loading progress
prepareImage(Image, int, int, ImageObserver)
,
Toolkit.checkImage(Image, int, int, ImageObserver)
public void setIgnoreRepaint(boolean ignoreRepaint)
ignoreRepaint
- the new setting for ignoring repaint eventsgetIgnoreRepaint()
,
BufferStrategy
,
GraphicsDevice.setFullScreenWindow(Window)
public boolean getIgnoreRepaint()
setIgnoreRepaint(boolean)
public boolean contains(int x, int y)
x
- the X coordinate of the point to testy
- the Y coordinate of the point to test
getComponentAt(int, int)
public boolean inside(int x, int y)
contains(int, int)
instead
x
- the X coordinate of the point to testy
- the Y coordinate of the point to test
public boolean contains(Point p)
p
- the point to test
NullPointerException
- if p is nullgetComponentAt(Point)
public Component getComponentAt(int x, int y)
null
if neither of the first two occupies the specified location.
x
- the X coordinate to search for components aty
- the Y coordinate to search for components at
contains(int, int)
public Component locate(int x, int y)
getComponentAt(int, int)
instead
null
if neither of the first two occupies the specified location.
x
- the X coordinate to search for components aty
- the Y coordinate to search for components at
public Component getComponentAt(Point p)
null
if neither of the first two occupies the specified location.
p
- the point to search for components at
NullPointerException
- if p is nullcontains(Point)
public void deliverEvent(Event e)
(AWTEvent)
instead
postEvent(java.awt.Event)
.
e
- the event to deliverpublic final void dispatchEvent(AWTEvent e)
enableEvents()
e
- the event to dispatchpublic boolean postEvent(Event e)
dispatchEvent(AWTEvent)
instead
postEvent
in interface MenuContainer
e
- the event to handle
public void addComponentListener(ComponentListener listener)
listener
- the new listener to addComponentEvent
,
removeComponentListener(ComponentListener)
,
getComponentListeners()
public void removeComponentListener(ComponentListener listener)
listener
- the listener to removeComponentEvent
,
addComponentListener(ComponentListener)
,
getComponentListeners()
public ComponentListener[] getComponentListeners()
addComponentListener(ComponentListener)
,
removeComponentListener(ComponentListener)
public void addFocusListener(FocusListener listener)
listener
- the new listener to addFocusEvent
,
removeFocusListener(FocusListener)
,
getFocusListeners()
public void removeFocusListener(FocusListener listener)
listener
- the listener to removeFocusEvent
,
addFocusListener(FocusListener)
,
getFocusListeners()
public FocusListener[] getFocusListeners()
addFocusListener(FocusListener)
,
removeFocusListener(FocusListener)
public void addHierarchyListener(HierarchyListener listener)
listener
- the new listener to addHierarchyEvent
,
removeHierarchyListener(HierarchyListener)
,
getHierarchyListeners()
public void removeHierarchyListener(HierarchyListener listener)
listener
- the listener to removeHierarchyEvent
,
addHierarchyListener(HierarchyListener)
,
getHierarchyListeners()
public HierarchyListener[] getHierarchyListeners()
addHierarchyListener(HierarchyListener)
,
removeHierarchyListener(HierarchyListener)
public void addHierarchyBoundsListener(HierarchyBoundsListener listener)
listener
- the new listener to addHierarchyEvent
,
removeHierarchyBoundsListener(HierarchyBoundsListener)
,
getHierarchyBoundsListeners()
public void removeHierarchyBoundsListener(HierarchyBoundsListener listener)
listener
- the listener to removeHierarchyEvent
,
addHierarchyBoundsListener(HierarchyBoundsListener)
,
getHierarchyBoundsListeners()
public HierarchyBoundsListener[] getHierarchyBoundsListeners()
addHierarchyBoundsListener(HierarchyBoundsListener)
,
removeHierarchyBoundsListener(HierarchyBoundsListener)
public void addKeyListener(KeyListener listener)
listener
- the new listener to addKeyEvent
,
removeKeyListener(KeyListener)
,
getKeyListeners()
public void removeKeyListener(KeyListener listener)
listener
- the listener to removeKeyEvent
,
addKeyListener(KeyListener)
,
getKeyListeners()
public KeyListener[] getKeyListeners()
addKeyListener(KeyListener)
,
removeKeyListener(KeyListener)
public void addMouseListener(MouseListener listener)
listener
- the new listener to addMouseEvent
,
removeMouseListener(MouseListener)
,
getMouseListeners()
public void removeMouseListener(MouseListener listener)
listener
- the listener to removeMouseEvent
,
addMouseListener(MouseListener)
,
getMouseListeners()
public MouseListener[] getMouseListeners()
addMouseListener(MouseListener)
,
removeMouseListener(MouseListener)
public void addMouseMotionListener(MouseMotionListener listener)
listener
- the new listener to addMouseEvent
,
removeMouseMotionListener(MouseMotionListener)
,
getMouseMotionListeners()
public void removeMouseMotionListener(MouseMotionListener listener)
listener
- the listener to removeMouseEvent
,
addMouseMotionListener(MouseMotionListener)
,
getMouseMotionListeners()
public MouseMotionListener[] getMouseMotionListeners()
addMouseMotionListener(MouseMotionListener)
,
removeMouseMotionListener(MouseMotionListener)
public void addMouseWheelListener(MouseWheelListener listener)
listener
- the new listener to addMouseEvent
,
MouseWheelEvent
,
removeMouseWheelListener(MouseWheelListener)
,
getMouseWheelListeners()
public void removeMouseWheelListener(MouseWheelListener listener)
listener
- the listener to removeMouseEvent
,
MouseWheelEvent
,
addMouseWheelListener(MouseWheelListener)
,
getMouseWheelListeners()
public MouseWheelListener[] getMouseWheelListeners()
addMouseWheelListener(MouseWheelListener)
,
removeMouseWheelListener(MouseWheelListener)
public void addInputMethodListener(InputMethodListener listener)
listener
- the new listener to addInputMethodEvent
,
removeInputMethodListener(InputMethodListener)
,
getInputMethodListeners()
,
getInputMethodRequests()
public void removeInputMethodListener(InputMethodListener listener)
listener
- the listener to removeInputMethodEvent
,
addInputMethodListener(InputMethodListener)
,
getInputMethodRequests()
public InputMethodListener[] getInputMethodListeners()
addInputMethodListener(InputMethodListener)
,
removeInputMethodListener(InputMethodListener)
public <T extends EventListener> T[] getListeners(Class<T> listenerType)
EventListener
s of the given
listenerType
.
listenerType
- the class of listeners to filter (null
not permitted).
ClassCastException
- if listenerType
does not implement
the EventListener
interface.
NullPointerException
- if listenerType
is
null
.getComponentListeners()
,
getFocusListeners()
,
getHierarchyListeners()
,
getHierarchyBoundsListeners()
,
getKeyListeners()
,
getMouseListeners()
,
getMouseMotionListeners()
,
getMouseWheelListeners()
,
getInputMethodListeners()
,
getPropertyChangeListeners()
public InputMethodRequests getInputMethodRequests()
public InputContext getInputContext()
protected final void enableEvents(long eventsToEnable)
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.
eventsToEnable
- the desired events to enableprocessEvent(AWTEvent)
,
disableEvents(long)
,
AWTEvent
protected final void disableEvents(long eventsToDisable)
AWTEvent
.
eventsToDisable
- the desired events to disableenableEvents(long)
protected AWTEvent coalesceEvents(AWTEvent existingEvent, AWTEvent newEvent)
existingEvent
- the event on the queuenewEvent
- the new event that might be entered on the queue
protected void processEvent(AWTEvent e)
e
- the event to process
NullPointerException
- if e is nullprocessComponentEvent(ComponentEvent)
,
processFocusEvent(FocusEvent)
,
processKeyEvent(KeyEvent)
,
processMouseEvent(MouseEvent)
,
processMouseMotionEvent(MouseEvent)
,
processInputMethodEvent(InputMethodEvent)
,
processHierarchyEvent(HierarchyEvent)
,
processMouseWheelEvent(MouseWheelEvent)
protected void processComponentEvent(ComponentEvent e)
e
- the ComponentEvent
to process
NullPointerException
- if e is nullComponentListener
,
addComponentListener(ComponentListener)
,
enableEvents(long)
protected void processFocusEvent(FocusEvent e)
e
- the FocusEvent
to process
NullPointerException
- if e is nullFocusListener
,
addFocusListener(FocusListener)
,
enableEvents(long)
protected void processKeyEvent(KeyEvent e)
e
- the KeyEvent
to process
NullPointerException
- if e is nullKeyListener
,
addKeyListener(KeyListener)
,
enableEvents(long)
protected void processMouseEvent(MouseEvent e)
e
- the MouseEvent
to process
NullPointerException
- if e is nullMouseListener
,
addMouseListener(MouseListener)
,
enableEvents(long)
protected void processMouseMotionEvent(MouseEvent e)
e
- the MouseMotionEvent
to process
NullPointerException
- if e is nullMouseMotionListener
,
addMouseMotionListener(MouseMotionListener)
,
enableEvents(long)
protected void processMouseWheelEvent(MouseWheelEvent e)
e
- the MouseWheelEvent
to process
NullPointerException
- if e is nullMouseWheelListener
,
addMouseWheelListener(MouseWheelListener)
,
enableEvents(long)
protected void processInputMethodEvent(InputMethodEvent e)
e
- the InputMethodEvent
to process
NullPointerException
- if e is nullInputMethodListener
,
addInputMethodListener(InputMethodListener)
,
enableEvents(long)
protected void processHierarchyEvent(HierarchyEvent e)
e
- the HierarchyEvent
to process
NullPointerException
- if e is nullHierarchyListener
,
addHierarchyListener(HierarchyListener)
,
enableEvents(long)
protected void processHierarchyBoundsEvent(HierarchyEvent e)
e
- the HierarchyEvent
to process
NullPointerException
- if e is nullHierarchyBoundsListener
,
addHierarchyBoundsListener(HierarchyBoundsListener)
,
enableEvents(long)
public boolean handleEvent(Event evt)
processEvent(AWTEvent)
instead
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.
evt
- the event to handle
public boolean mouseDown(Event evt, int x, int y)
processMouseEvent(MouseEvent)
instead
evt
- the event to handlex
- the x coordinate, ignoredy
- the y coordinate, ignored
public boolean mouseDrag(Event evt, int x, int y)
processMouseMotionEvent(MouseEvent)
instead
evt
- the event to handlex
- the x coordinate, ignoredy
- the y coordinate, ignored
public boolean mouseUp(Event evt, int x, int y)
processMouseEvent(MouseEvent)
instead
evt
- the event to handlex
- the x coordinate, ignoredy
- the y coordinate, ignored
public boolean mouseMove(Event evt, int x, int y)
processMouseMotionEvent(MouseEvent)
instead
evt
- the event to handlex
- the x coordinate, ignoredy
- the y coordinate, ignored
public boolean mouseEnter(Event evt, int x, int y)
processMouseEvent(MouseEvent)
instead
evt
- the event to handlex
- the x coordinate, ignoredy
- the y coordinate, ignored
public boolean mouseExit(Event evt, int x, int y)
processMouseEvent(MouseEvent)
instead
evt
- the event to handlex
- the x coordinate, ignoredy
- the y coordinate, ignored
public boolean keyDown(Event evt, int key)
processKeyEvent(KeyEvent)
instead
evt
- the event to handlekey
- the key pressed, ignored
public boolean keyUp(Event evt, int key)
processKeyEvent(KeyEvent)
instead
evt
- the event to handlekey
- the key pressed, ignored
public boolean action(Event evt, Object what)
processActionEvent(ActionEvent)
instead
evt
- the event to handlewhat
- the object acted on, ignored
public void addNotify()
isDisplayable()
,
removeNotify()
public void removeNotify()
isDisplayable()
,
addNotify()
public boolean gotFocus(Event evt, Object what)
processFocusEvent(FocusEvent)
instead
evt
- the event to handlewhat
- the Object focused, ignored
public boolean lostFocus(Event evt, Object what)
processFocusEvent(FocusEvent)
instead
evt
- the event to handlewhat
- the Object focused, ignored
public boolean isFocusTraversable()
isFocusable()
instead
setFocusable(boolean)
public boolean isFocusable()
public void setFocusable(boolean focusable)
isFocusTraversableOverridden
field to 1, which
appears to be the undocumented way DefaultFocusTraversalPolicy.accept(Component)
determines whether to
respect the isFocusable()
method of the component.
focusable
- the new focusable statuspublic void setFocusTraversalKeys(int id, Set<? extends AWTKeyStroke> keystrokes)
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:
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 |
id
- one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS, or
UP_CYCLE_TRAVERSAL_KEYSkeystrokes
- a set of keys, or null
IllegalArgumentException
- if id or keystrokes is invalidgetFocusTraversalKeys(int)
,
KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS
,
KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS
,
KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS
public Set<AWTKeyStroke> getFocusTraversalKeys(int id)
setFocusTraversalKeys
. If not set, this
is inherited from the parent component, which may have gotten it
from the KeyboardFocusManager.
id
- one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS,
or UP_CYCLE_TRAVERSAL_KEYS
IllegalArgumentException
- if id is invalid(int, Set)
,
KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS
,
KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS
,
KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS
public boolean areFocusTraversalKeysSet(int id)
id
- one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS,
or UP_CYCLE_TRAVERSAL_KEYS
IllegalArgumentException
- if id is invalid(int)
,
KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS
,
KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS
,
KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS
public void setFocusTraversalKeysEnabled(boolean focusTraversalKeysEnabled)
focusTraversalKeysEnabled
- the new value of the flag()
,
(int, Set)
,
(int)
public boolean getFocusTraversalKeysEnabled()
(boolean)
,
(int, Set)
,
(int)
public void requestFocus()
requestFocusInWindow()
should be used instead.
()
,
FocusEvent
,
(FocusListener)
,
()
,
()
,
()
protected boolean requestFocus(boolean temporary)
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.
temporary
- true if the focus request is temporary
()
,
FocusEvent
,
(FocusListener)
,
()
,
()
,
()
public boolean requestFocusInWindow()
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.
()
,
FocusEvent
,
(FocusListener)
,
()
,
()
,
()
protected boolean requestFocusInWindow(boolean temporary)
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.
temporary
- true if the focus request is temporary
()
,
FocusEvent
,
(FocusListener)
,
()
,
()
,
()
public void transferFocus()
requestFocus()
public Container getFocusCycleRootAncestor()
public boolean isFocusCycleRoot(Container c)
c
- the container to test
public void nextFocus()
()
instead
public void transferFocusBackward()
()
public void transferFocusUpCycle()
requestFocus()
,
isFocusCycleRoot(Container)
public boolean hasFocus()
()
instead.
public boolean isFocusOwner()
public void add(PopupMenu popup)
popup
- the popup menu to be addedremove(MenuComponent)
public void remove(MenuComponent popup)
remove
in interface MenuContainer
popup
- the popup menu to removeadd(PopupMenu)
protected String paramString()
public String toString()
getClass().getName() + '[' + paramString() + ']'
.
toString
in class Object
Object.getClass()
,
Object.hashCode()
,
Class.getName()
,
Integer.toHexString(int)
public void list()
System.out
.
list(PrintStream)
public void list(PrintStream out)
out
- the PrintStream
to print topublic void list(PrintStream out, int indent)
out
- the PrintStream
to print toindent
- the indentation pointpublic void list(PrintWriter out)
out
- the PrintWrinter
to print topublic void list(PrintWriter out, int indent)
out
- the PrintWriter
to print toindent
- the indentation pointpublic void addPropertyChangeListener(PropertyChangeListener listener)
"font"
)"background"
)"foreground"
)"focusable"
)"focusTraversalKeysEnabled"
)"forwardFocusTraversalKeys"
)"backwardFocusTraversalKeys"
)"upCycleFocusTraversalKeys"
)
listener
- the new listener to addremovePropertyChangeListener(PropertyChangeListener)
,
getPropertyChangeListeners()
,
addPropertyChangeListener(String, PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListener listener)
listener
- the listener to removeaddPropertyChangeListener(PropertyChangeListener)
,
getPropertyChangeListeners()
,
removePropertyChangeListener(String, PropertyChangeListener)
public PropertyChangeListener[] getPropertyChangeListeners()
addPropertyChangeListener(PropertyChangeListener)
,
removePropertyChangeListener(PropertyChangeListener)
,
getPropertyChangeListeners(String)
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
"font"
)"background"
)"foreground"
)"focusable"
)"focusTraversalKeysEnabled"
)"forwardFocusTraversalKeys"
)"backwardFocusTraversalKeys"
)"upCycleFocusTraversalKeys"
)
propertyName
- the property name to filter onlistener
- the new listener to addremovePropertyChangeListener(String, PropertyChangeListener)
,
getPropertyChangeListeners(String)
,
addPropertyChangeListener(PropertyChangeListener)
public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
propertyName
- the property name to filter onlistener
- the listener to removeaddPropertyChangeListener(String, PropertyChangeListener)
,
getPropertyChangeListeners(String)
,
removePropertyChangeListener(PropertyChangeListener)
public PropertyChangeListener[] getPropertyChangeListeners(String property)
addPropertyChangeListener(String, PropertyChangeListener)
,
removePropertyChangeListener(String, PropertyChangeListener)
,
getPropertyChangeListeners()
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
propertyName
- the property that changedoldValue
- the old property valuenewValue
- the new property valueprotected void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
propertyName
- the property that changedoldValue
- the old property valuenewValue
- the new property valueprotected void firePropertyChange(String propertyName, int oldValue, int newValue)
propertyName
- the property that changedoldValue
- the old property valuenewValue
- the new property valuepublic void firePropertyChange(String propertyName, byte oldValue, byte newValue)
propertyName
- the property that changedoldValue
- the old property valuenewValue
- the new property valuepublic void firePropertyChange(String propertyName, char oldValue, char newValue)
propertyName
- the property that changedoldValue
- the old property valuenewValue
- the new property valuepublic void firePropertyChange(String propertyName, short oldValue, short newValue)
propertyName
- the property that changedoldValue
- the old property valuenewValue
- the new property valuepublic void firePropertyChange(String propertyName, long oldValue, long newValue)
propertyName
- the property that changedoldValue
- the old property valuenewValue
- the new property valuepublic void firePropertyChange(String propertyName, float oldValue, float newValue)
propertyName
- the property that changedoldValue
- the old property valuenewValue
- the new property valuepublic void firePropertyChange(String propertyName, double oldValue, double newValue)
propertyName
- the property that changedoldValue
- the old property valuenewValue
- the new property valuepublic void setComponentOrientation(ComponentOrientation o)
applyComponentOrientation(ComponentOrientation)
affects the
entire hierarchy.
o
- the new orientation (null
is accepted)getComponentOrientation()
public ComponentOrientation getComponentOrientation()
null
)setComponentOrientation(ComponentOrientation)
public void applyComponentOrientation(ComponentOrientation o)
setComponentOrientation(ComponentOrientation)
affects only the
current component.
o
- the new orientation
NullPointerException
- if o is nullgetComponentOrientation()
public AccessibleContext getAccessibleContext()
Component.AccessibleAWTComponent
.
public Point getMousePosition() throws HeadlessException
HeadlessException
- if in a headless environment
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |