| Method from java.awt.Component Detail: |
public boolean action(Event evt,
Object what) {
return false;
} Deprecated! in - classes which support actions, use
processActionEvent(ActionEvent) instead
AWT 1.0 ACTION_EVENT event handler. This method is meant to be
overridden by components providing their own action event
handler. The default implementation simply returns false. |
public synchronized void add(PopupMenu popup) {
if (popups == null)
popups = new Vector();
popups.add(popup);
if (popup.parent != null)
popup.parent.remove(popup);
popup.parent = this;
if (peer != null)
popup.addNotify();
}
Adds the specified popup menu to this component. |
public synchronized void addComponentListener(ComponentListener listener) {
componentListener = AWTEventMulticaster.add(componentListener, listener);
if (componentListener != null)
enableEvents(AWTEvent.COMPONENT_EVENT_MASK);
}
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. |
public synchronized void addFocusListener(FocusListener listener) {
focusListener = AWTEventMulticaster.add(focusListener, listener);
if (focusListener != null)
enableEvents(AWTEvent.FOCUS_EVENT_MASK);
}
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. |
public synchronized void addHierarchyBoundsListener(HierarchyBoundsListener listener) {
hierarchyBoundsListener =
AWTEventMulticaster.add(hierarchyBoundsListener, listener);
if (hierarchyBoundsListener != null)
enableEvents(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK);
}
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. |
public synchronized void addHierarchyListener(HierarchyListener listener) {
hierarchyListener = AWTEventMulticaster.add(hierarchyListener, listener);
if (hierarchyListener != null)
enableEvents(AWTEvent.HIERARCHY_EVENT_MASK);
}
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. |
public synchronized void addInputMethodListener(InputMethodListener listener) {
inputMethodListener = AWTEventMulticaster.add(inputMethodListener, listener);
if (inputMethodListener != null)
enableEvents(AWTEvent.INPUT_METHOD_EVENT_MASK);
}
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. |
public synchronized void addKeyListener(KeyListener listener) {
keyListener = AWTEventMulticaster.add(keyListener, listener);
if (keyListener != null)
enableEvents(AWTEvent.KEY_EVENT_MASK);
}
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. |
public synchronized void addMouseListener(MouseListener listener) {
mouseListener = AWTEventMulticaster.add(mouseListener, listener);
if (mouseListener != null)
enableEvents(AWTEvent.MOUSE_EVENT_MASK);
}
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. |
public synchronized void addMouseMotionListener(MouseMotionListener listener) {
mouseMotionListener = AWTEventMulticaster.add(mouseMotionListener, listener);
if (mouseMotionListener != null)
enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK);
}
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. |
public synchronized void addMouseWheelListener(MouseWheelListener listener) {
mouseWheelListener = AWTEventMulticaster.add(mouseWheelListener, listener);
if (mouseWheelListener != null)
enableEvents(AWTEvent.MOUSE_WHEEL_EVENT_MASK);
}
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. |
public void addNotify() {
if (peer == null)
peer = getToolkit().createComponent(this);
else if (parent != null && parent.isLightweight())
new HeavyweightInLightweightListener(parent);
/* Now that all the children has gotten their peers, we should
have the event mask needed for this component and its
lightweight subcomponents. */
peer.setEventMask(eventMask);
/* We do not invalidate here, but rather leave that job up to
the peer. For efficiency, the peer can choose not to
invalidate if it is happy with the current dimensions,
etc. */
}
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. |
public void addPropertyChangeListener(PropertyChangeListener listener) {
if (changeSupport == null)
changeSupport = new PropertyChangeSupport(this);
changeSupport.addPropertyChangeListener(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")
|
public void addPropertyChangeListener(String propertyName,
PropertyChangeListener listener) {
if (changeSupport == null)
changeSupport = new PropertyChangeSupport(this);
changeSupport.addPropertyChangeListener(propertyName, 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")
p * - the set of backward traversal keys
(
"backwardFocusTraversalKeys")
- the set of up-cycle traversal keys
(
"upCycleFocusTraversalKeys")
|
public void applyComponentOrientation(ComponentOrientation o) {
setComponentOrientation(o);
}
Sets the text layout orientation of this component. New components default
to UNKNOWN (which behaves like LEFT_TO_RIGHT). This method affects the
entire hierarchy, while
#setComponentOrientation(ComponentOrientation) affects only the
current component. |
public boolean areFocusTraversalKeysSet(int id) {
if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS)
throw new IllegalArgumentException ();
return focusTraversalKeys != null && focusTraversalKeys[id] != null;
}
Tests whether the focus traversal keys for a given action are explicitly
set or inherited. |
public Rectangle bounds() {
return new Rectangle (x, y, width, height);
} Deprecated! use - #getBounds() instead
Returns a bounding rectangle for this component. Note that the
returned rectange is relative to this component's parent, not to
the screen. |
public int checkImage(Image image,
ImageObserver observer) {
return checkImage(image, -1, -1, observer);
}
Returns the status of the loading of the specified image. The value
returned will be those flags defined in ImageObserver. |
public int checkImage(Image image,
int width,
int height,
ImageObserver observer) {
if (peer != null)
return peer.checkImage(image, width, height, observer);
return getToolkit().checkImage(image, width, height, observer);
}
Returns the status of the loading of the specified image. The value
returned will be those flags defined in ImageObserver. |
protected AWTEvent coalesceEvents(AWTEvent existingEvent,
AWTEvent newEvent) {
switch (existingEvent.id)
{
case MouseEvent.MOUSE_MOVED:
case MouseEvent.MOUSE_DRAGGED:
// Just drop the old (intermediate) event and return the new one.
return newEvent;
case PaintEvent.PAINT:
case PaintEvent.UPDATE:
return coalescePaintEvents((PaintEvent) existingEvent,
(PaintEvent) newEvent);
default:
return null;
}
}
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). |
public boolean contains(Point p) {
return contains (p.x, p.y);
}
Tests whether or not the specified point is contained within this
component. Coordinates are relative to this component. |
public boolean contains(int x,
int y) {
return inside (x, y);
}
Tests whether or not the specified point is contained within this
component. Coordinates are relative to this component. |
public Image createImage(ImageProducer producer) {
// Sun allows producer to be null.
if (peer != null)
return peer.createImage(producer);
else
return getToolkit().createImage(producer);
}
Creates an image from the specified producer. |
public Image createImage(int width,
int height) {
Image returnValue = null;
if (!GraphicsEnvironment.isHeadless ())
{
if (isLightweight () && parent != null)
returnValue = parent.createImage (width, height);
else if (peer != null)
returnValue = peer.createImage (width, height);
}
return returnValue;
}
Creates an image with the specified width and height for use in
double buffering. Headless environments do not support images. |
public VolatileImage createVolatileImage(int width,
int height) {
if (GraphicsEnvironment.isHeadless())
return null;
GraphicsConfiguration config = getGraphicsConfiguration();
return config == null ? null
: config.createCompatibleVolatileImage(width, height);
}
Creates an image with the specified width and height for use in
double buffering. Headless environments do not support images. |
public VolatileImage createVolatileImage(int width,
int height,
ImageCapabilities caps) throws AWTException {
if (GraphicsEnvironment.isHeadless())
return null;
GraphicsConfiguration config = getGraphicsConfiguration();
return config == null ? null
: config.createCompatibleVolatileImage(width, height, caps);
}
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. |
public void deliverEvent(Event e) {
postEvent (e);
} Deprecated! use - (AWTEvent) instead
AWT 1.0 event delivery.
Deliver an AWT 1.0 event to this Component. This method simply
calls #postEvent . |
public void disable() {
this.enabled = false;
if (peer != null)
peer.setEnabled (false);
} Deprecated! use - #setEnabled(boolean) instead
|
protected final void disableEvents(long eventsToDisable) {
eventMask &= ~eventsToDisable;
// forward new event mask to peer?
}
Disables the specified events. The events to disable are specified
by OR-ing together the desired masks from AWTEvent. |
public final void dispatchEvent(AWTEvent e) {
Event oldEvent = translateEvent(e);
if (oldEvent != null)
postEvent (oldEvent);
// Give toolkit a chance to dispatch the event
// to globally registered listeners.
Toolkit.getDefaultToolkit().globalDispatchEvent(e);
// Some subclasses in the AWT package need to override this behavior,
// hence the use of dispatchEventImpl().
dispatchEventImpl(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 dispatchEventImpl(AWTEvent e) {
// This boolean tells us not to process focus events when the focus
// opposite component is the same as the focus component.
boolean ignoreFocus =
(e instanceof FocusEvent &&
((FocusEvent)e).getComponent() == ((FocusEvent)e).getOppositeComponent());
if (eventTypeEnabled (e.id))
{
if (e.id != PaintEvent.PAINT && e.id != PaintEvent.UPDATE
&& !ignoreFocus)
processEvent(e);
// the trick we use to communicate between dispatch and redispatch
// is to have KeyboardFocusManager.redispatch synchronize on the
// object itself. we then do not redispatch to KeyboardFocusManager
// if we are already holding the lock.
if (! Thread.holdsLock(e))
{
switch (e.id)
{
case WindowEvent.WINDOW_GAINED_FOCUS:
case WindowEvent.WINDOW_LOST_FOCUS:
case KeyEvent.KEY_PRESSED:
case KeyEvent.KEY_RELEASED:
case KeyEvent.KEY_TYPED:
case FocusEvent.FOCUS_GAINED:
case FocusEvent.FOCUS_LOST:
if (KeyboardFocusManager
.getCurrentKeyboardFocusManager()
.dispatchEvent(e))
return;
case MouseEvent.MOUSE_PRESSED:
if (isLightweight() && !e.isConsumed())
requestFocus();
break;
}
}
}
if (peer != null)
peer.handleEvent(e);
}
Implementation of dispatchEvent. Allows trusted package classes
to dispatch additional events first. This implementation first
translates e to an AWT 1.0 event and sends the
result to #postEvent . If the AWT 1.0 event is not
handled, and events of type e are enabled for this
component, e is passed on to #processEvent . |
public void doLayout() {
layout ();
}
Calls the layout manager to re-layout the component. This is called
during validation of a container in most cases. |
public void enable() {
this.enabled = true;
if (peer != null)
peer.setEnabled (true);
} Deprecated! use - #setEnabled(boolean) instead
|
public void enable(boolean enabled) {
if (enabled)
enable();
else
disable();
} Deprecated! use - #setEnabled(boolean) instead
Enables or disables this component. |
protected final void enableEvents(long eventsToEnable) {
eventMask |= eventsToEnable;
// TODO: Unlike Sun's implementation, I think we should try and
// enable/disable events at the peer (gtk/X) level. This will avoid
// clogging the event pipeline with useless mousemove events that
// we arn't interested in, etc. This will involve extending the peer
// interface, but thats okay because the peer interfaces have been
// deprecated for a long time, and no longer feature in the
// API specification at all.
if (isLightweight() && parent != null)
parent.enableEvents(eventsToEnable);
else if (peer != null)
peer.setEventMask(eventMask);
}
Enables the specified events. The events to enable are specified
by OR-ing together the desired masks from AWTEvent.
Events are enabled by default when a listener is attached to the
component for that event type. This method can be used by subclasses
to ensure the delivery of a specified event regardless of whether
or not a listener is attached. |
public void enableInputMethods(boolean enable) {
if (enable)
eventMask |= AWTEvent.INPUT_ENABLED_EVENT_MASK;
else
eventMask &= ~AWTEvent.INPUT_ENABLED_EVENT_MASK;
}
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. |
boolean eventTypeEnabled(int type) {
if (type > AWTEvent.RESERVED_ID_MAX)
return true;
switch (type)
{
case HierarchyEvent.HIERARCHY_CHANGED:
return (hierarchyListener != null
|| (eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0);
case HierarchyEvent.ANCESTOR_MOVED:
case HierarchyEvent.ANCESTOR_RESIZED:
return (hierarchyBoundsListener != null
|| (eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0);
case ComponentEvent.COMPONENT_HIDDEN:
case ComponentEvent.COMPONENT_MOVED:
case ComponentEvent.COMPONENT_RESIZED:
case ComponentEvent.COMPONENT_SHOWN:
return (componentListener != null
|| (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0);
case KeyEvent.KEY_PRESSED:
case KeyEvent.KEY_RELEASED:
case KeyEvent.KEY_TYPED:
return (keyListener != null
|| (eventMask & AWTEvent.KEY_EVENT_MASK) != 0);
case MouseEvent.MOUSE_CLICKED:
case MouseEvent.MOUSE_ENTERED:
case MouseEvent.MOUSE_EXITED:
case MouseEvent.MOUSE_PRESSED:
case MouseEvent.MOUSE_RELEASED:
return (mouseListener != null
|| (eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0);
case MouseEvent.MOUSE_MOVED:
case MouseEvent.MOUSE_DRAGGED:
return (mouseMotionListener != null
|| (eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0);
case MouseEvent.MOUSE_WHEEL:
return (mouseWheelListener != null
|| (eventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0);
case FocusEvent.FOCUS_GAINED:
case FocusEvent.FOCUS_LOST:
return (focusListener != null
|| (eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0);
case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
case InputMethodEvent.CARET_POSITION_CHANGED:
return (inputMethodListener != null
|| (eventMask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0);
case PaintEvent.PAINT:
case PaintEvent.UPDATE:
return (eventMask & AWTEvent.PAINT_EVENT_MASK) != 0;
default:
return false;
}
}
Tells whether or not an event type is enabled. |
Component findNextFocusComponent(Component child) {
return null;
}
This method is used to implement transferFocus(). CHILD is the child
making the request. This is overridden by Container; when called for an
ordinary component there is no child and so we always return null.
FIXME: is this still needed, in light of focus traversal policies? |
protected void firePropertyChange(String propertyName,
Object oldValue,
Object newValue) {
if (changeSupport != null)
changeSupport.firePropertyChange(propertyName, oldValue, newValue);
}
Report a change in a bound property to any registered property listeners. |
protected void firePropertyChange(String propertyName,
boolean oldValue,
boolean newValue) {
if (changeSupport != null)
changeSupport.firePropertyChange(propertyName, oldValue, newValue);
}
Report a change in a bound property to any registered property listeners. |
protected void firePropertyChange(String propertyName,
int oldValue,
int newValue) {
if (changeSupport != null)
changeSupport.firePropertyChange(propertyName, oldValue, newValue);
}
Report a change in a bound property to any registered property listeners. |
public void firePropertyChange(String propertyName,
byte oldValue,
byte newValue) {
if (changeSupport != null)
changeSupport.firePropertyChange(propertyName, new Byte(oldValue),
new Byte(newValue));
}
Report a change in a bound property to any registered property listeners. |
public void firePropertyChange(String propertyName,
char oldValue,
char newValue) {
if (changeSupport != null)
changeSupport.firePropertyChange(propertyName, new Character(oldValue),
new Character(newValue));
}
Report a change in a bound property to any registered property listeners. |
public void firePropertyChange(String propertyName,
short oldValue,
short newValue) {
if (changeSupport != null)
changeSupport.firePropertyChange(propertyName, new Short(oldValue),
new Short(newValue));
}
Report a change in a bound property to any registered property listeners. |
public void firePropertyChange(String propertyName,
long oldValue,
long newValue) {
if (changeSupport != null)
changeSupport.firePropertyChange(propertyName, new Long(oldValue),
new Long(newValue));
}
Report a change in a bound property to any registered property listeners. |
public void firePropertyChange(String propertyName,
float oldValue,
float newValue) {
if (changeSupport != null)
changeSupport.firePropertyChange(propertyName, new Float(oldValue),
new Float(newValue));
}
Report a change in a bound property to any registered property listeners. |
public void firePropertyChange(String propertyName,
double oldValue,
double newValue) {
if (changeSupport != null)
changeSupport.firePropertyChange(propertyName, new Double(oldValue),
new Double(newValue));
}
Report a change in a bound property to any registered property listeners. |
String generateName() {
// Component is abstract.
return null;
}
Subclasses should override this to return unique component names like
"menuitem0". |
public AccessibleContext getAccessibleContext() {
return null;
}
Returns the accessibility framework context of this class. Component is
not accessible, so the default implementation returns null. Subclasses
must override this behavior, and return an appropriate subclass of
AccessibleAWTComponent . |
public float getAlignmentX() {
return CENTER_ALIGNMENT;
}
|
public float getAlignmentY() {
return CENTER_ALIGNMENT;
}
|
public Color getBackground() {
if (background != null)
return background;
return parent == null ? null : parent.getBackground();
}
Returns this component's background color. If not set, this is inherited
from the parent. |
public Rectangle getBounds() {
return bounds ();
}
Returns a bounding rectangle for this component. Note that the
returned rectange is relative to this component's parent, not to
the screen. |
public Rectangle getBounds(Rectangle r) {
if (r == null)
r = new Rectangle();
r.x = x;
r.y = y;
r.width = width;
r.height = height;
return r;
}
Returns the bounds of this component. This allows reuse of an existing
rectangle, if r is non-null. |
public ColorModel getColorModel() {
GraphicsConfiguration config = getGraphicsConfiguration();
return config != null ? config.getColorModel()
: getToolkit().getColorModel();
}
Returns the color model of the device this componet is displayed on. |
public Component getComponentAt(Point p) {
return getComponentAt (p.x, p.y);
}
Returns the component occupying the position (x,y). This will either
be this component, an immediate child component, or null
if neither of the first two occupies the specified location. |
public Component getComponentAt(int x,
int y) {
return locate (x, y);
}
Returns the component occupying the position (x,y). This will either
be this component, an immediate child component, or null
if neither of the first two occupies the specified location. |
public synchronized ComponentListener[] getComponentListeners() {
return (ComponentListener[])
AWTEventMulticaster.getListeners(componentListener,
ComponentListener.class);
}
Returns an array of all specified listeners registered on this component. |
public ComponentOrientation getComponentOrientation() {
return orientation;
}
Determines the text layout orientation used by this component. |
public Cursor getCursor() {
if (cursor != null)
return cursor;
return parent != null ? parent.getCursor() : Cursor.getDefaultCursor();
}
Returns the cursor for this component. If not set, this is inherited
from the parent, or from Cursor.getDefaultCursor(). |
public DropTarget getDropTarget() {
return dropTarget;
}
Gets the associated drag-and-drop target, if there is one. |
public Container getFocusCycleRootAncestor() {
Container parent = getParent ();
while (parent != null && !parent.isFocusCycleRoot())
parent = parent.getParent ();
return parent;
}
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. |
public synchronized FocusListener[] getFocusListeners() {
return (FocusListener[])
AWTEventMulticaster.getListeners(focusListener, FocusListener.class);
}
Returns an array of all specified listeners registered on this component. |
public Set getFocusTraversalKeys(int id) {
if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS)
throw new IllegalArgumentException();
Set s = null;
if (focusTraversalKeys != null)
s = focusTraversalKeys[id];
if (s == null && parent != null)
s = parent.getFocusTraversalKeys (id);
return s == null ? (KeyboardFocusManager.getCurrentKeyboardFocusManager()
.getDefaultFocusTraversalKeys(id)) : s;
}
Returns the set of keys for a given focus traversal action, as
defined in setFocusTraversalKeys. If not set, this
is inherited from the parent component, which may have gotten it
from the KeyboardFocusManager. |
public boolean getFocusTraversalKeysEnabled() {
return focusTraversalKeysEnabled;
}
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. |
public Font getFont() {
Font f = font;
if (f != null)
return f;
Component p = parent;
if (p != null)
return p.getFont();
return null;
}
Returns the font in use for this component. If not set, this is inherited
from the parent. |
public FontMetrics getFontMetrics(Font font) {
return peer == null ? getToolkit().getFontMetrics(font)
: peer.getFontMetrics(font);
}
Returns the font metrics for the specified font in this component. |
public Color getForeground() {
if (foreground != null)
return foreground;
return parent == null ? null : parent.getForeground();
}
Returns this component's foreground color. If not set, this is inherited
from the parent. |
public Graphics getGraphics() {
if (peer != null)
{
Graphics gfx = peer.getGraphics();
// Create peer for lightweights.
if (gfx == null && parent != null)
{
gfx = parent.getGraphics();
Rectangle bounds = getBounds();
gfx.setClip(bounds);
gfx.translate(bounds.x, bounds.y);
return gfx;
}
gfx.setFont(font);
return gfx;
}
return null;
}
Returns a graphics object for this component. Returns null
if this component is not currently displayed on the screen. |
public GraphicsConfiguration getGraphicsConfiguration() {
return getGraphicsConfigurationImpl();
}
Returns the graphics configuration of this component, if there is one.
If it has not been set, it is inherited from the parent. |
GraphicsConfiguration getGraphicsConfigurationImpl() {
if (peer != null)
{
GraphicsConfiguration config = peer.getGraphicsConfiguration();
if (config != null)
return config;
}
if (parent != null)
return parent.getGraphicsConfiguration();
return null;
}
Implementation method that allows classes such as Canvas and Window to
override the graphics configuration without violating the published API. |
public int getHeight() {
return height;
}
Gets the height of the component. This is more efficient than
getBounds().height or getSize().height. |
public synchronized HierarchyBoundsListener[] getHierarchyBoundsListeners() {
return (HierarchyBoundsListener[])
AWTEventMulticaster.getListeners(hierarchyBoundsListener,
HierarchyBoundsListener.class);
}
Returns an array of all specified listeners registered on this component. |
public synchronized HierarchyListener[] getHierarchyListeners() {
return (HierarchyListener[])
AWTEventMulticaster.getListeners(hierarchyListener,
HierarchyListener.class);
}
Returns an array of all specified listeners registered on this component. |
public boolean getIgnoreRepaint() {
return ignoreRepaint;
}
Test whether paint events from the operating system are ignored. |
public InputContext getInputContext() {
return parent == null ? null : parent.getInputContext();
}
Gets the input context of this component, which is inherited from the
parent unless this is overridden. |
public synchronized InputMethodListener[] getInputMethodListeners() {
return (InputMethodListener[])
AWTEventMulticaster.getListeners(inputMethodListener,
InputMethodListener.class);
}
Returns an array of all specified listeners registered on this component. |
public InputMethodRequests getInputMethodRequests() {
return null;
}
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. |
public synchronized KeyListener[] getKeyListeners() {
return (KeyListener[])
AWTEventMulticaster.getListeners(keyListener, KeyListener.class);
}
Returns an array of all specified listeners registered on this component. |
public EventListener[] getListeners(Class listenerType) {
if (listenerType == ComponentListener.class)
return getComponentListeners();
if (listenerType == FocusListener.class)
return getFocusListeners();
if (listenerType == HierarchyListener.class)
return getHierarchyListeners();
if (listenerType == HierarchyBoundsListener.class)
return getHierarchyBoundsListeners();
if (listenerType == KeyListener.class)
return getKeyListeners();
if (listenerType == MouseListener.class)
return getMouseListeners();
if (listenerType == MouseMotionListener.class)
return getMouseMotionListeners();
if (listenerType == MouseWheelListener.class)
return getMouseWheelListeners();
if (listenerType == InputMethodListener.class)
return getInputMethodListeners();
if (listenerType == PropertyChangeListener.class)
return getPropertyChangeListeners();
return (EventListener[]) Array.newInstance(listenerType, 0);
}
Returns all registered EventListener s of the given
listenerType. |
public Locale getLocale() {
if (locale != null)
return locale;
if (parent == null)
throw new IllegalComponentStateException
("Component has no parent: can't determine Locale");
return parent.getLocale();
}
Returns the locale for this component. If this component does not
have a locale, the locale of the parent component is returned. |
public Point getLocation() {
return location ();
}
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. |
public Point getLocation(Point p) {
if (p == null)
p = new Point();
p.x = x;
p.y = y;
return p;
}
Returns the location of this component. This allows reuse of an existing
point, if p is non-null. |
public Point getLocationOnScreen() {
if (! isShowing())
throw new IllegalComponentStateException("component "
+ getClass().getName()
+ " not showing");
// We know peer != null here.
return peer.getLocationOnScreen();
}
Returns the location of this component's top left corner in screen
coordinates. |
public Dimension getMaximumSize() {
return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
}
Returns the component's maximum size. |
public Dimension getMinimumSize() {
return minimumSize();
}
Returns the component's minimum size. |
public synchronized MouseListener[] getMouseListeners() {
return (MouseListener[])
AWTEventMulticaster.getListeners(mouseListener, MouseListener.class);
}
Returns an array of all specified listeners registered on this component. |
public synchronized MouseMotionListener[] getMouseMotionListeners() {
return (MouseMotionListener[])
AWTEventMulticaster.getListeners(mouseMotionListener,
MouseMotionListener.class);
}
Returns an array of all specified listeners registered on this component. |
public synchronized MouseWheelListener[] getMouseWheelListeners() {
return (MouseWheelListener[])
AWTEventMulticaster.getListeners(mouseWheelListener,
MouseWheelListener.class);
}
Returns an array of all specified listeners registered on this component. |
public String getName() {
if (name == null && ! nameExplicitlySet)
name = generateName();
return name;
}
Returns the name of this component. |
public Container getParent() {
return parent;
}
Returns the parent of this component. |
public ComponentPeer getPeer() {
return peer;
} Deprecated! user - programs should not directly manipulate peers; use
#isDisplayable() instead
Returns the native windowing system peer for this component. Only the
platform specific implementation code should call this method. |
public Dimension getPreferredSize() {
return preferredSize();
}
Returns the component's preferred size. |
public PropertyChangeListener[] getPropertyChangeListeners() {
return changeSupport == null ? new PropertyChangeListener[0]
: changeSupport.getPropertyChangeListeners();
}
Returns an array of all specified listeners registered on this component. |
public PropertyChangeListener[] getPropertyChangeListeners(String property) {
return changeSupport == null ? new PropertyChangeListener[0]
: changeSupport.getPropertyChangeListeners(property);
}
Returns an array of all specified listeners on the named property that
are registered on this component. |
public Dimension getSize() {
return size ();
}
Returns the size of this object. |
public Dimension getSize(Dimension d) {
if (d == null)
d = new Dimension();
d.width = width;
d.height = height;
return d;
}
Returns the size of this component. This allows reuse of an existing
dimension, if d is non-null. |
public Toolkit getToolkit() {
if (peer != null)
{
Toolkit tk = peer.getToolkit();
if (tk != null)
return tk;
}
// Get toolkit for lightweight component.
if (parent != null)
return parent.getToolkit();
return Toolkit.getDefaultToolkit();
}
Returns the toolkit in use for this component. The toolkit is associated
with the frame this component belongs to. |
public final Object getTreeLock() {
return treeLock;
}
Returns the object used for synchronization locks on this component
when performing tree and layout functions. |
public int getWidth() {
return width;
}
Gets the width of the component. This is more efficient than
getBounds().width or getSize().width. |
public int getX() {
return x;
}
Gets the x coordinate of the upper left corner. This is more efficient
than getBounds().x or getLocation().x. |
public int getY() {
return y;
}
Gets the y coordinate of the upper left corner. This is more efficient
than getBounds().y or getLocation().y. |
public boolean gotFocus(Event evt,
Object what) {
return false;
} Deprecated! use - #processFocusEvent(FocusEvent) instead
AWT 1.0 GOT_FOCUS event handler. This method is meant to be
overridden by components providing their own GOT_FOCUS handler.
The default implementation simply returns false. |
public boolean handleEvent(Event evt) {
switch (evt.id)
{
// Handle key events.
case Event.KEY_ACTION:
case Event.KEY_PRESS:
return keyDown (evt, evt.key);
case Event.KEY_ACTION_RELEASE:
case Event.KEY_RELEASE:
return keyUp (evt, evt.key);
// Handle mouse events.
case Event.MOUSE_DOWN:
return mouseDown (evt, evt.x, evt.y);
case Event.MOUSE_UP:
return mouseUp (evt, evt.x, evt.y);
case Event.MOUSE_MOVE:
return mouseMove (evt, evt.x, evt.y);
case Event.MOUSE_DRAG:
return mouseDrag (evt, evt.x, evt.y);
case Event.MOUSE_ENTER:
return mouseEnter (evt, evt.x, evt.y);
case Event.MOUSE_EXIT:
return mouseExit (evt, evt.x, evt.y);
// Handle focus events.
case Event.GOT_FOCUS:
return gotFocus (evt, evt.arg);
case Event.LOST_FOCUS:
return lostFocus (evt, evt.arg);
// Handle action event
|