Methods Summary |
---|
public void | addNotify()Makes this Window displayable by creating the connection to its
native screen resource.
This method is called internally by the toolkit and should
not be called directly by programs.
synchronized (getTreeLock()) {
Container parent = this.parent;
if (parent != null && parent.getPeer() == null) {
parent.addNotify();
}
if (peer == null)
peer = getToolkit().createWindow(this);
super.addNotify();
}
|
void | addOwnedWindow(java.lang.ref.WeakReference weakWindow)
if (weakWindow != null) {
synchronized(ownedWindowList) {
// this if statement should really be an assert, but we don't
// have asserts...
if (!ownedWindowList.contains(weakWindow)) {
ownedWindowList.addElement(weakWindow);
}
}
}
|
public void | addPropertyChangeListener(java.beans.PropertyChangeListener listener)Adds a PropertyChangeListener to the listener list. The listener is
registered for all bound properties of this class, including the
following:
- this Window's font ("font")
- this Window's background color ("background")
- this Window's foreground color ("foreground")
- this Window's focusability ("focusable")
- this Window's focus traversal keys enabled state
("focusTraversalKeysEnabled")
- this Window's Set of FORWARD_TRAVERSAL_KEYS
("forwardFocusTraversalKeys")
- this Window's Set of BACKWARD_TRAVERSAL_KEYS
("backwardFocusTraversalKeys")
- this Window's Set of UP_CYCLE_TRAVERSAL_KEYS
("upCycleFocusTraversalKeys")
- this Window's Set of DOWN_CYCLE_TRAVERSAL_KEYS
("downCycleFocusTraversalKeys")
- this Window's focus traversal policy ("focusTraversalPolicy")
- this Window's focusable Window state ("focusableWindowState")
- this Window's always-on-top state("alwaysOnTop")
Note that if this Window is inheriting a bound property, then no
event will be fired in response to a change in the inherited property.
If listener is null, no exception is thrown and no action is performed.
super.addPropertyChangeListener(listener);
|
public void | addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)Adds a PropertyChangeListener to the listener list for a specific
property. The specified property may be user-defined, or one of the
following:
- this Window's font ("font")
- this Window's background color ("background")
- this Window's foreground color ("foreground")
- this Window's focusability ("focusable")
- this Window's focus traversal keys enabled state
("focusTraversalKeysEnabled")
- this Window's Set of FORWARD_TRAVERSAL_KEYS
("forwardFocusTraversalKeys")
- this Window's Set of BACKWARD_TRAVERSAL_KEYS
("backwardFocusTraversalKeys")
- this Window's Set of UP_CYCLE_TRAVERSAL_KEYS
("upCycleFocusTraversalKeys")
- this Window's Set of DOWN_CYCLE_TRAVERSAL_KEYS
("downCycleFocusTraversalKeys")
- this Window's focus traversal policy ("focusTraversalPolicy")
- this Window's focusable Window state ("focusableWindowState")
- this Window's always-on-top state("alwaysOnTop")
Note that if this Window is inheriting a bound property, then no
event will be fired in response to a change in the inherited property.
If listener is null, no exception is thrown and no action is performed.
super.addPropertyChangeListener(propertyName, listener);
|
public synchronized void | addWindowFocusListener(java.awt.event.WindowFocusListener l)Adds the specified window focus listener to receive window events
from this window.
If l is null, no exception is thrown and no action is performed.
if (l == null) {
return;
}
windowFocusListener = AWTEventMulticaster.add(windowFocusListener, l);
newEventsOnly = true;
|
public synchronized void | addWindowListener(java.awt.event.WindowListener l)Adds the specified window listener to receive window events from
this window.
If l is null, no exception is thrown and no action is performed.
if (l == null) {
return;
}
newEventsOnly = true;
windowListener = AWTEventMulticaster.add(windowListener, l);
|
public synchronized void | addWindowStateListener(java.awt.event.WindowStateListener l)Adds the specified window state listener to receive window
events from this window. If l is null,
no exception is thrown and no action is performed.
if (l == null) {
return;
}
windowStateListener = AWTEventMulticaster.add(windowStateListener, l);
newEventsOnly = true;
|
void | adjustDecendantsOnParent(int num)
// do nothing since parent == owner and we shouldn't
// ajust counter on owner
|
void | adjustListeningChildrenOnParent(long mask, int num)
|
public void | applyResourceBundle(java.util.ResourceBundle rb)
applyComponentOrientation(ComponentOrientation.getOrientation(rb));
|
public void | applyResourceBundle(java.lang.String rbName)
applyResourceBundle(ResourceBundle.getBundle(rbName));
|
boolean | canContainFocusOwner(java.awt.Component focusOwnerCandidate)Checks whether this window can contain focus owner.
Verifies that it is focusable and as container it can container focus owner.
return super.canContainFocusOwner(focusOwnerCandidate) && isFocusableWindow();
|
final void | clearMostRecentFocusOwnerOnHide()
/* do nothing */
|
void | connectOwnedWindow(java.awt.Window child)
WeakReference weakChild = new WeakReference(child);
child.weakThis = weakChild;
child.parent = this;
addOwnedWindow(weakChild);
|
java.lang.String | constructComponentName()Construct a name for this component. Called by getName() when the
name is null.
synchronized (getClass()) {
return base + nameCounter++;
}
|
public void | createBufferStrategy(int numBuffers)Creates a new strategy for multi-buffering on this component.
Multi-buffering is useful for rendering performance. This method
attempts to create the best strategy available with the number of
buffers supplied. It will always create a BufferStrategy
with that number of buffers.
A page-flipping strategy is attempted first, then a blitting strategy
using accelerated buffers. Finally, an unaccelerated blitting
strategy is used.
Each time this method is called,
the existing buffer strategy for this component is discarded.
super.createBufferStrategy(numBuffers);
|
public void | createBufferStrategy(int numBuffers, java.awt.BufferCapabilities caps)Creates a new strategy for multi-buffering on this component with the
required buffer capabilities. This is useful, for example, if only
accelerated memory or page flipping is desired (as specified by the
buffer capabilities).
Each time this method
is called, the existing buffer strategy for this component is discarded.
super.createBufferStrategy(numBuffers, caps);
|
void | deliverMouseWheelToAncestor(java.awt.event.MouseWheelEvent e)Overridden from Component. Top-level Windows should not propagate a
MouseWheelEvent beyond themselves into their owning Windows.
|
void | dispatchEventImpl(java.awt.AWTEvent e)Dispatches an event to this window or one of its sub components.
if (e.getID() == ComponentEvent.COMPONENT_RESIZED) {
invalidate();
validate();
}
super.dispatchEventImpl(e);
|
boolean | dispatchMouseWheelToAncestor(java.awt.event.MouseWheelEvent e)Overridden from Component. Top-level Windows don't dispatch to ancestorsreturn false;
|
public void | dispose()Releases all of the native screen resources used by this
Window , its subcomponents, and all of its owned
children. That is, the resources for these Component s
will be destroyed, any memory they consume will be returned to the
OS, and they will be marked as undisplayable.
The Window and its subcomponents can be made displayable
again by rebuilding the native resources with a subsequent call to
pack or show . The states of the recreated
Window and its subcomponents will be identical to the
states of these objects at the point where the Window
was disposed (not accounting for additional modifications between
those actions).
Note: When the last displayable window
within the Java virtual machine (VM) is disposed of, the VM may
terminate. See
AWT Threading Issues for more information.
doDispose();
|
void | disposeImpl()
dispose();
if (getPeer() != null) {
doDispose();
}
|
void | doDispose()
class DisposeAction implements Runnable {
public void run() {
Object[] ownedWindowArray;
synchronized(ownedWindowList) {
ownedWindowArray = new Object[ownedWindowList.size()];
ownedWindowList.copyInto(ownedWindowArray);
}
for (int i = 0; i < ownedWindowArray.length; i++) {
Window child = (Window) (((WeakReference)
(ownedWindowArray[i])).get());
if (child != null) {
child.disposeImpl();
}
}
hide();
beforeFirstShow = true;
removeNotify();
synchronized (inputContextLock) {
if (inputContext != null) {
inputContext.dispose();
inputContext = null;
}
}
clearCurrentFocusCycleRootOnHide();
}
}
DisposeAction action = new DisposeAction();
if (EventQueue.isDispatchThread()) {
action.run();
}
else {
try {
EventQueue.invokeAndWait(action);
}
catch (InterruptedException e) {
System.err.println("Disposal was interrupted:");
e.printStackTrace();
}
catch (InvocationTargetException e) {
System.err.println("Exception during disposal:");
e.printStackTrace();
}
}
// Execute outside the Runnable because postWindowEvent is
// synchronized on (this). We don't need to synchronize the call
// on the EventQueue anyways.
postWindowEvent(WindowEvent.WINDOW_CLOSED);
|
boolean | eventEnabled(java.awt.AWTEvent e)
switch(e.id) {
case WindowEvent.WINDOW_OPENED:
case WindowEvent.WINDOW_CLOSING:
case WindowEvent.WINDOW_CLOSED:
case WindowEvent.WINDOW_ICONIFIED:
case WindowEvent.WINDOW_DEICONIFIED:
case WindowEvent.WINDOW_ACTIVATED:
case WindowEvent.WINDOW_DEACTIVATED:
if ((eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0 ||
windowListener != null) {
return true;
}
return false;
case WindowEvent.WINDOW_GAINED_FOCUS:
case WindowEvent.WINDOW_LOST_FOCUS:
if ((eventMask & AWTEvent.WINDOW_FOCUS_EVENT_MASK) != 0 ||
windowFocusListener != null) {
return true;
}
return false;
case WindowEvent.WINDOW_STATE_CHANGED:
if ((eventMask & AWTEvent.WINDOW_STATE_EVENT_MASK) != 0 ||
windowStateListener != null) {
return true;
}
return false;
default:
break;
}
return super.eventEnabled(e);
|
protected void | finalize()Disposes of the input methods and context, and removes
this Window from the GUI hierarchy. Subclasses that override
this method should call super.finalize().
// We have to remove the (hard) reference to weakThis in the
// parent's ownedWindowList, otherwise the WeakReference
// instance that points to this Window will never get garbage
// collected.
if (parent != null) {
((Window)parent).removeOwnedWindow(weakThis);
}
super.finalize();
|
public javax.accessibility.AccessibleContext | getAccessibleContext()Gets the AccessibleContext associated with this Window.
For windows, the AccessibleContext takes the form of an
AccessibleAWTWindow.
A new AccessibleAWTWindow instance is created if necessary.
if (accessibleContext == null) {
accessibleContext = new AccessibleAWTWindow();
}
return accessibleContext;
|
public java.awt.image.BufferStrategy | getBufferStrategy()
return super.getBufferStrategy();
|
public final java.awt.Container | getFocusCycleRootAncestor()Always returns null because Windows have no ancestors; they
represent the top of the Component hierarchy.
return null;
|
public java.awt.Component | getFocusOwner()Returns the child Component of this Window that has focus if this Window
is focused; returns null otherwise.
return (isFocused())
? KeyboardFocusManager.getCurrentKeyboardFocusManager().
getFocusOwner()
: null;
|
public java.util.Set | getFocusTraversalKeys(int id)Gets a focus traversal key for this Window. (See
setFocusTraversalKeys for a full description of each key.)
If the traversal key has not been explicitly set for this Window,
then this Window's parent's traversal key is returned. If the
traversal key has not been explicitly set for any of this Window's
ancestors, then the current KeyboardFocusManager's default traversal key
is returned.
if (id < 0 || id >= KeyboardFocusManager.TRAVERSAL_KEY_LENGTH) {
throw new IllegalArgumentException("invalid focus traversal key identifier");
}
// Okay to return Set directly because it is an unmodifiable view
Set keystrokes = (focusTraversalKeys != null)
? focusTraversalKeys[id]
: null;
if (keystrokes != null) {
return keystrokes;
} else {
return KeyboardFocusManager.getCurrentKeyboardFocusManager().
getDefaultFocusTraversalKeys(id);
}
|
public boolean | getFocusableWindowState()Returns whether this Window can become the focused Window if it meets
the other requirements outlined in isFocusableWindow . If
this method returns false , then
isFocusableWindow will return false as well.
If this method returns true , then
isFocusableWindow may return true or
false depending upon the other requirements which must be
met in order for a Window to be focusable.
By default, all Windows have a focusable Window state of
true .
return focusableWindowState;
|
public java.awt.GraphicsConfiguration | getGraphicsConfiguration()This method returns the GraphicsConfiguration used by this Window.
//NOTE: for multiscreen, this will need to take into account
//which screen the window is on/mostly on instead of returning the
//default or constructor argument config.
synchronized(getTreeLock()) {
if (graphicsConfig == null && !GraphicsEnvironment.isHeadless()) {
graphicsConfig =
GraphicsEnvironment. getLocalGraphicsEnvironment().
getDefaultScreenDevice().
getDefaultConfiguration();
}
return graphicsConfig;
}
|
public java.awt.im.InputContext | getInputContext()Gets the input context for this window. A window always has an input context,
which is shared by subcomponents unless they create and set their own.
if (inputContext == null) {
synchronized (inputContextLock) {
if (inputContext == null) {
inputContext = InputContext.getInstance();
}
}
}
return inputContext;
|
public T[] | getListeners(java.lang.Class listenerType)Returns an array of all the objects currently registered
as FooListener s
upon this Window .
FooListener s are registered using the
addFooListener method.
You can specify the listenerType argument
with a class literal, such as
FooListener.class .
For example, you can query a
Window w
for its window listeners with the following code:
WindowListener[] wls = (WindowListener[])(w.getListeners(WindowListener.class));
If no such listeners exist, this method returns an empty array.
EventListener l = null;
if (listenerType == WindowFocusListener.class) {
l = windowFocusListener;
} else if (listenerType == WindowStateListener.class) {
l = windowStateListener;
} else if (listenerType == WindowListener.class) {
l = windowListener;
} else {
return super.getListeners(listenerType);
}
return AWTEventMulticaster.getListeners(l, listenerType);
|
public java.util.Locale | getLocale()Gets the Locale object that is associated
with this window, if the locale has been set.
If no locale has been set, then the default locale
is returned.
if (this.locale == null) {
return Locale.getDefault();
}
return this.locale;
|
public java.awt.Component | getMostRecentFocusOwner()Returns the child Component of this Window that will receive the focus
when this Window is focused. If this Window is currently focused, this
method returns the same Component as getFocusOwner() . If
this Window is not focused, then the child Component that most recently
requested focus will be returned. If no child Component has ever
requested focus, and this is a focusable Window, then this Window's
initial focusable Component is returned. If no child Component has ever
requested focus, and this is a non-focusable Window, null is returned.
if (isFocused()) {
return getFocusOwner();
} else {
Component mostRecent =
KeyboardFocusManager.getMostRecentFocusOwner(this);
if (mostRecent != null) {
return mostRecent;
} else {
return (isFocusableWindow())
? getFocusTraversalPolicy().getInitialComponent(this)
: null;
}
}
|
public java.awt.Window[] | getOwnedWindows()Return an array containing all the windows this
window currently owns.
Window realCopy[];
synchronized(ownedWindowList) {
// Recall that ownedWindowList is actually a Vector of
// WeakReferences and calling get() on one of these references
// may return null. Make two arrays-- one the size of the
// Vector (fullCopy with size fullSize), and one the size of
// all non-null get()s (realCopy with size realSize).
int fullSize = ownedWindowList.size();
int realSize = 0;
Window fullCopy[] = new Window[fullSize];
for (int i = 0; i < fullSize; i++) {
fullCopy[realSize] = (Window) (((WeakReference)
(ownedWindowList.elementAt(i))).get());
if (fullCopy[realSize] != null) {
realSize++;
}
}
if (fullSize != realSize) {
realCopy = new Window[realSize];
System.arraycopy(fullCopy, 0, realCopy, 0, realSize);
} else {
realCopy = fullCopy;
}
}
return realCopy;
|
public java.awt.Window | getOwner()Returns the owner of this window.
return (Window)parent;
|
java.awt.Component | getTemporaryLostComponent()
return temporaryLostComponent;
|
public java.awt.Toolkit | getToolkit()Returns the toolkit of this frame.
return Toolkit.getDefaultToolkit();
|
public final java.lang.String | getWarningString()Gets the warning string that is displayed with this window.
If this window is insecure, the warning string is displayed
somewhere in the visible area of the window. A window is
insecure if there is a security manager, and the security
manager's checkTopLevelWindow method returns
false when this window is passed to it as an
argument.
If the window is secure, then getWarningString
returns null . If the window is insecure, this
method checks for the system property
awt.appletWarning
and returns the string value of that property.
return warningString;
|
public synchronized java.awt.event.WindowFocusListener[] | getWindowFocusListeners()Returns an array of all the window focus listeners
registered on this window.
return (WindowFocusListener[])(getListeners(WindowFocusListener.class));
|
public synchronized java.awt.event.WindowListener[] | getWindowListeners()Returns an array of all the window listeners
registered on this window.
return (WindowListener[])(getListeners(WindowListener.class));
|
public synchronized java.awt.event.WindowStateListener[] | getWindowStateListeners()Returns an array of all the window state listeners
registered on this window.
return (WindowStateListener[])(getListeners(WindowStateListener.class));
|
public void | hide()
synchronized(ownedWindowList) {
for (int i = 0; i < ownedWindowList.size(); i++) {
Window child = (Window) (((WeakReference)
(ownedWindowList.elementAt(i))).get());
if ((child != null) && child.visible) {
child.hide();
child.showWithParent = true;
}
}
}
super.hide();
|
private void | init(java.awt.GraphicsConfiguration gc)
if (GraphicsEnvironment.isHeadless()) {
throw new IllegalArgumentException("headless environment");
}
syncLWRequests = systemSyncLWRequests;
setWarningString();
this.cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
this.visible = false;
if (gc == null) {
this.graphicsConfig =
GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getDefaultConfiguration();
} else {
this.graphicsConfig = gc;
}
if (graphicsConfig.getDevice().getType() !=
GraphicsDevice.TYPE_RASTER_SCREEN) {
throw new IllegalArgumentException("not a screen device");
}
setLayout(new BorderLayout());
/* offset the initial location with the original of the screen */
/* and any insets */
Rectangle screenBounds = graphicsConfig.getBounds();
Insets screenInsets = getToolkit().getScreenInsets(graphicsConfig);
int x = getX() + screenBounds.x + screenInsets.left;
int y = getY() + screenBounds.y + screenInsets.top;
if (x != this.x || y != this.y) {
setLocation(x, y);
/* reset after setLocation */
setLocationByPlatform(locationByPlatformProp);
}
|
private static native void | initIDs()Initialize JNI field and method IDs for fields that may be
accessed from C.
|
public boolean | isActive()Returns whether this Window is active. Only a Frame or a Dialog may be
active. The native windowing system may denote the active Window or its
children with special decorations, such as a highlighted title bar. The
active Window is always either the focused Window, or the first Frame or
Dialog that is an owner of the focused Window.
return (KeyboardFocusManager.getCurrentKeyboardFocusManager().
getActiveWindow() == this);
|
public final boolean | isAlwaysOnTop()Returns whether this window is an always-on-top window.
return alwaysOnTop;
|
public final boolean | isFocusCycleRoot()Always returns true because all Windows must be roots of a
focus traversal cycle.
return true;
|
public final boolean | isFocusableWindow()Returns whether this Window can become the focused Window, that is,
whether this Window or any of its subcomponents can become the focus
owner. For a Frame or Dialog to be focusable, its focusable Window state
must be set to true . For a Window which is not a Frame or
Dialog to be focusable, its focusable Window state must be set to
true , its nearest owning Frame or Dialog must be
showing on the screen, and it must contain at least one Component in
its focus traversal cycle. If any of these conditions is not met, then
neither this Window nor any of its subcomponents can become the focus
owner.
// If a Window/Frame/Dialog was made non-focusable, then it is always
// non-focusable.
if (!getFocusableWindowState()) {
return false;
}
// All other tests apply only to Windows.
if (this instanceof Frame || this instanceof Dialog) {
return true;
}
// A Window must have at least one Component in its root focus
// traversal cycle to be focusable.
if (getFocusTraversalPolicy().getDefaultComponent(this) == null) {
return false;
}
// A Window's nearest owning Frame or Dialog must be showing on the
// screen.
for (Window owner = getOwner(); owner != null;
owner = owner.getOwner())
{
if (owner instanceof Frame || owner instanceof Dialog) {
return owner.isShowing();
}
}
return false;
|
public boolean | isFocused()Returns whether this Window is focused. If there exists a focus owner,
the focused Window is the Window that is, or contains, that focus owner.
If there is no focus owner, then no Window is focused.
If the focused Window is a Frame or a Dialog it is also the active
Window. Otherwise, the active Window is the first Frame or Dialog that
is an owner of the focused Window.
return (KeyboardFocusManager.getCurrentKeyboardFocusManager().
getGlobalFocusedWindow() == this);
|
public boolean | isLocationByPlatform()Returns true if this Window will appear at the default location
for the native windowing system the next time this Window is made visible.
This method always returns false if the Window is showing on the
screen.
synchronized (getTreeLock()) {
return locationByPlatform;
}
|
public boolean | isShowing()Checks if this Window is showing on screen.
return visible;
|
private void | ownedInit(java.awt.Window owner)
if (owner == null) {
throw new IllegalArgumentException("null owner window");
}
this.parent = owner;
this.weakThis = new WeakReference(this);
owner.addOwnedWindow(weakThis);
modalExcluded = owner.modalExcluded;
|
public void | pack()Causes this Window to be sized to fit the preferred size
and layouts of its subcomponents. If the window and/or its owner
are not yet displayable, both are made displayable before
calculating the preferred size. The Window will be validated
after the preferredSize is calculated.
Container parent = this.parent;
if (parent != null && parent.getPeer() == null) {
parent.addNotify();
}
if (peer == null) {
addNotify();
}
Dimension newSize = getPreferredSize();
if (peer != null) {
setClientSize(newSize.width, newSize.height);
}
if(beforeFirstShow) {
isPacked = true;
}
validate();
|
public boolean | postEvent(java.awt.Event e)
if (handleEvent(e)) {
e.consume();
return true;
}
return false;
|
void | postProcessKeyEvent(java.awt.event.KeyEvent e)
// Do nothing
|
synchronized void | postWindowEvent(int id)
if (windowListener != null
|| (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0
|| Toolkit.enabledOnToolkit(AWTEvent.WINDOW_EVENT_MASK)) {
WindowEvent e = new WindowEvent(this, id);
Toolkit.getEventQueue().postEvent(e);
}
|
void | preProcessKeyEvent(java.awt.event.KeyEvent e)Implements a debugging hook -- checks to see if
the user has typed control-shift-F1. If so,
the list of child windows is dumped to System.out .
// Dump the list of child windows to System.out.
if (e.isActionKey() && e.getKeyCode() == KeyEvent.VK_F1 &&
e.isControlDown() && e.isShiftDown() &&
e.getID() == KeyEvent.KEY_PRESSED) {
list(System.out, 0);
}
|
protected void | processEvent(java.awt.AWTEvent e)Processes events on this window. If the event is an
WindowEvent , it invokes the
processWindowEvent method, else it invokes its
superclass's processEvent .
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
if (e instanceof WindowEvent) {
switch (e.getID()) {
case WindowEvent.WINDOW_OPENED:
case WindowEvent.WINDOW_CLOSING:
case WindowEvent.WINDOW_CLOSED:
case WindowEvent.WINDOW_ICONIFIED:
case WindowEvent.WINDOW_DEICONIFIED:
case WindowEvent.WINDOW_ACTIVATED:
case WindowEvent.WINDOW_DEACTIVATED:
processWindowEvent((WindowEvent)e);
break;
case WindowEvent.WINDOW_GAINED_FOCUS:
case WindowEvent.WINDOW_LOST_FOCUS:
processWindowFocusEvent((WindowEvent)e);
break;
case WindowEvent.WINDOW_STATE_CHANGED:
processWindowStateEvent((WindowEvent)e);
default:
break;
}
return;
}
super.processEvent(e);
|
protected void | processWindowEvent(java.awt.event.WindowEvent e)Processes window events occurring on this window by
dispatching them to any registered WindowListener objects.
NOTE: This method will not be called unless window events
are enabled for this component; this happens when one of the
following occurs:
- A WindowListener object is registered via
addWindowListener
- Window events are enabled via
enableEvents
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
WindowListener listener = windowListener;
if (listener != null) {
switch(e.getID()) {
case WindowEvent.WINDOW_OPENED:
listener.windowOpened(e);
break;
case WindowEvent.WINDOW_CLOSING:
listener.windowClosing(e);
break;
case WindowEvent.WINDOW_CLOSED:
listener.windowClosed(e);
break;
case WindowEvent.WINDOW_ICONIFIED:
listener.windowIconified(e);
break;
case WindowEvent.WINDOW_DEICONIFIED:
listener.windowDeiconified(e);
break;
case WindowEvent.WINDOW_ACTIVATED:
listener.windowActivated(e);
break;
case WindowEvent.WINDOW_DEACTIVATED:
listener.windowDeactivated(e);
break;
default:
break;
}
}
|
protected void | processWindowFocusEvent(java.awt.event.WindowEvent e)Processes window focus event occuring on this window by
dispatching them to any registered WindowFocusListener objects.
NOTE: this method will not be called unless window focus events
are enabled for this window. This happens when one of the
following occurs:
- a WindowFocusListener is registered via
addWindowFocusListener
- Window focus events are enabled via
enableEvents
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
WindowFocusListener listener = windowFocusListener;
if (listener != null) {
switch (e.getID()) {
case WindowEvent.WINDOW_GAINED_FOCUS:
listener.windowGainedFocus(e);
break;
case WindowEvent.WINDOW_LOST_FOCUS:
listener.windowLostFocus(e);
break;
default:
break;
}
}
|
protected void | processWindowStateEvent(java.awt.event.WindowEvent e)Processes window state event occuring on this window by
dispatching them to any registered WindowStateListener
objects.
NOTE: this method will not be called unless window state events
are enabled for this window. This happens when one of the
following occurs:
- a
WindowStateListener is registered via
addWindowStateListener
- window state events are enabled via
enableEvents
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
WindowStateListener listener = windowStateListener;
if (listener != null) {
switch (e.getID()) {
case WindowEvent.WINDOW_STATE_CHANGED:
listener.windowStateChanged(e);
break;
default:
break;
}
}
|
private void | readObject(java.io.ObjectInputStream s)Reads the ObjectInputStream and an optional
list of listeners to receive various events fired by
the component; also reads a list of
(possibly null ) child windows.
Unrecognized keys or values will be ignored.
GraphicsEnvironment.checkHeadless();
s.defaultReadObject();
if (windowSerializedDataVersion < 2) {
// Translate old-style focus tracking to new model. For 1.4 and
// later releases, we'll rely on the Window's initial focusable
// Component.
if (focusMgr != null) {
if (focusMgr.focusOwner != null) {
KeyboardFocusManager.
setMostRecentFocusOwner(this, focusMgr.focusOwner);
}
}
// This field is non-transient and relies on default serialization.
// However, the default value is insufficient, so we need to set
// it explicitly for object data streams prior to 1.4.
focusableWindowState = true;
}
// 1.4 doesn't use this field, so just null it out.
focusMgr = null;
ownedWindowList = new Vector();
Object keyOrNull;
while(null != (keyOrNull = s.readObject())) {
String key = ((String)keyOrNull).intern();
if (windowListenerK == key) {
addWindowListener((WindowListener)(s.readObject()));
} else if (windowFocusListenerK == key) {
addWindowFocusListener((WindowFocusListener)(s.readObject()));
} else if (windowStateListenerK == key) {
addWindowStateListener((WindowStateListener)(s.readObject()));
} else // skip value for unrecognized key
s.readObject();
}
try {
while (null != (keyOrNull = s.readObject())) {
String key = ((String)keyOrNull).intern();
if (ownedWindowK == key)
connectOwnedWindow((Window) s.readObject());
else // skip value for unrecognized key
s.readObject();
}
}
catch (OptionalDataException e) {
// 1.1 serialized form
// ownedWindowList will be updated by Frame.readObject
}
setWarningString();
inputContextLock = new Object();
// Deserialized Windows are not yet visible.
visible = false;
|
void | removeOwnedWindow(java.lang.ref.WeakReference weakWindow)
if (weakWindow != null) {
// synchronized block not required since removeElement is
// already synchronized
ownedWindowList.removeElement(weakWindow);
}
|
public synchronized void | removeWindowFocusListener(java.awt.event.WindowFocusListener l)Removes the specified window focus listener so that it no longer
receives window events from this window.
If l is null, no exception is thrown and no action is performed.
if (l == null) {
return;
}
windowFocusListener = AWTEventMulticaster.remove(windowFocusListener, l);
|
public synchronized void | removeWindowListener(java.awt.event.WindowListener l)Removes the specified window listener so that it no longer
receives window events from this window.
If l is null, no exception is thrown and no action is performed.
if (l == null) {
return;
}
windowListener = AWTEventMulticaster.remove(windowListener, l);
|
public synchronized void | removeWindowStateListener(java.awt.event.WindowStateListener l)Removes the specified window state listener so that it no
longer receives window events from this window. If
l is null , no exception is thrown and
no action is performed.
if (l == null) {
return;
}
windowStateListener = AWTEventMulticaster.remove(windowStateListener, l);
|
void | resetGC()Reset this Window's GraphicsConfiguration to match its peer.
if (!GraphicsEnvironment.isHeadless()) {
// use the peer's GC
setGCFromPeer();
// if it's still null, use the default
if (graphicsConfig == null) {
graphicsConfig = GraphicsEnvironment.
getLocalGraphicsEnvironment().
getDefaultScreenDevice().
getDefaultConfiguration();
}
if (dbg.on) {
dbg.println("+ Window.resetGC(): new GC is \n+ " + graphicsConfig + "\n+ this is " + this);
}
}
|
public final void | setAlwaysOnTop(boolean alwaysOnTop)Changes the always-on-top window state. An always-on-top window
is a window that stays above all other windows except maybe
other always-on-top windows. If there are several always-on-top
windows the order in which they stay relative to each other is
not specified and is platform dependent.
If some other window already is always-on-top then the
relative order between these windows is unspecified (depends on
platform). No window can be brought to be over always-on-top
window except maybe another always-on-top window.
All owned windows of an always-on-top window automatically
become always-on-top windows. If a window ceases to be
always-on-top its owned windows cease to be always-on-top.
When an always-on-top window is sent {@link #toBack toBack}
its always-on-top state is set to false .
This method makes the window always-on-top if
alwaysOnTop is true . If the window is
visible, this includes bringing window toFront , then
"sticking" it to the top-most position. If the window is not
visible it does nothing other than setting the always-on-top
property. If later the window is shown, it will be always-on-top.
If the Window is already always-on-top, this call does nothing.
If alwaysOnTop is false this
method changes the state from always-on-top to normal. The window
remains top-most but its z-order can be changed in the normal way
as for any other window. Does nothing if this Window is not
always-on-top. Has no effect on relative z-order of windows if
there are no other always-on-top windows.
Note: some platforms might not support always-on-top
windows. There is no public API to detect if the platform
supports always-on-top at runtime.
If a SecurityManager is installed, the calling thread must be
granted the AWTPermission "setWindowAlwaysOnTop" in
order to set the value of this property. If this
permission is not granted, this method will throw a
SecurityException, and the current value of the property will
be left unchanged.
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(SecurityConstants.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION);
}
boolean oldAlwaysOnTop;
synchronized(this) {
oldAlwaysOnTop = this.alwaysOnTop;
this.alwaysOnTop = alwaysOnTop;
}
if (oldAlwaysOnTop != alwaysOnTop ) {
WindowPeer peer = (WindowPeer)this.peer;
synchronized(getTreeLock()) {
if (peer != null) {
peer.updateAlwaysOnTop();
}
}
firePropertyChange("alwaysOnTop", oldAlwaysOnTop, alwaysOnTop);
}
|
public void | setBounds(int x, int y, int width, int height)
synchronized (getTreeLock()) {
if (getBoundsOp() == ComponentPeer.SET_LOCATION ||
getBoundsOp() == ComponentPeer.SET_BOUNDS)
{
locationByPlatform = false;
}
super.setBounds(x, y, width, height);
}
|
void | setClientSize(int w, int h)
synchronized (getTreeLock()) {
setBoundsOp(ComponentPeer.SET_CLIENT_SIZE);
setBounds(x, y, w, h);
}
|
public void | setCursor(java.awt.Cursor cursor)Set the cursor image to a specified cursor.
if (cursor == null) {
cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
}
super.setCursor(cursor);
|
public final void | setFocusCycleRoot(boolean focusCycleRoot)Does nothing because Windows must always be roots of a focus traversal
cycle. The passed-in value is ignored.
|
public void | setFocusableWindowState(boolean focusableWindowState)Sets whether this Window can become the focused Window if it meets
the other requirements outlined in isFocusableWindow . If
this Window's focusable Window state is set to false , then
isFocusableWindow will return false . If this
Window's focusable Window state is set to true , then
isFocusableWindow may return true or
false depending upon the other requirements which must be
met in order for a Window to be focusable.
Setting a Window's focusability state to false is the
standard mechanism for an application to identify to the AWT a Window
which will be used as a floating palette or toolbar, and thus should be
a non-focusable Window.
Setting the focusability state on a visible Window
can have a delayed effect on some platforms the actual
change may happen only when the Window becomes
hidden and then visible again. To ensure consistent behavior
across platforms, set the Window 's focusable state
when the WIndow is invisible and then show it.
boolean oldFocusableWindowState;
synchronized (this) {
oldFocusableWindowState = this.focusableWindowState;
this.focusableWindowState = focusableWindowState;
}
firePropertyChange("focusableWindowState", oldFocusableWindowState,
focusableWindowState);
if (oldFocusableWindowState && !focusableWindowState && isFocused()) {
for (Window owner = (Window)getParent();
owner != null;
owner = (Window)owner.getParent())
{
Component toFocus =
KeyboardFocusManager.getMostRecentFocusOwner(owner);
if (toFocus != null && toFocus.requestFocus(false)) {
return;
}
}
KeyboardFocusManager.getCurrentKeyboardFocusManager().
clearGlobalFocusOwner();
}
|
public void | setLocationByPlatform(boolean locationByPlatform)Sets whether this Window should appear at the default location for the
native windowing system or at the current location (returned by
getLocation ) the next time the Window is made visible.
This behavior resembles a native window shown without programmatically
setting its location. Most windowing systems cascade windows if their
locations are not explicitly set. The actual location is determined once the
window is shown on the screen.
This behavior can also be enabled by setting the System Property
"java.awt.Window.locationByPlatform" to "true", though calls to this method
take precedence.
Calls to setVisible , setLocation and
setBounds after calling setLocationByPlatform clear
this property of the Window.
For example, after the following code is executed:
setLocationByPlatform(true);
setVisible(true);
boolean flag = isLocationByPlatform();
The window will be shown at platform's default location and
flag will be false .
In the following sample:
setLocationByPlatform(true);
setLocation(10, 10);
boolean flag = isLocationByPlatform();
setVisible(true);
The window will be shown at (10, 10) and flag will be
false .
synchronized (getTreeLock()) {
if (locationByPlatform && isShowing()) {
throw new IllegalComponentStateException("The window is showing on screen.");
}
this.locationByPlatform = locationByPlatform;
}
|
public void | setLocationRelativeTo(java.awt.Component c)Sets the location of the window relative to the specified
component. If the component is not currently showing,
or c is null , the
window is centered on the screen. If the bottom of the
component is offscreen, the window is placed to the
side of the Component that is closest
to the center of the screen. So if the
Component is on the right part of the
screen, the Window is placed to its left,
and visa versa.
Container root=null;
if (c != null) {
if (c instanceof Window || c instanceof Applet) {
root = (Container)c;
} else {
Container parent;
for(parent = c.getParent() ; parent != null ; parent = parent.getParent()) {
if (parent instanceof Window || parent instanceof Applet) {
root = parent;
break;
}
}
}
}
if((c != null && !c.isShowing()) || root == null ||
!root.isShowing()) {
Dimension paneSize = getSize();
Dimension screenSize = getToolkit().getScreenSize();
setLocation((screenSize.width - paneSize.width) / 2,
(screenSize.height - paneSize.height) / 2);
} else {
Dimension invokerSize = c.getSize();
Point invokerScreenLocation = c.getLocationOnScreen();
Rectangle windowBounds = getBounds();
int dx = invokerScreenLocation.x+((invokerSize.width-windowBounds.width)>>1);
int dy = invokerScreenLocation.y+((invokerSize.height - windowBounds.height)>>1);
Rectangle ss = root.getGraphicsConfiguration().getBounds();
// Adjust for bottom edge being offscreen
if (dy+windowBounds.height>ss.height) {
dy = ss.height-windowBounds.height;
if (invokerScreenLocation.x - ss.x + invokerSize.width / 2 <
ss.width / 2) {
dx = invokerScreenLocation.x+invokerSize.width;
}
else {
dx = invokerScreenLocation.x-windowBounds.width;
}
}
// Avoid being placed off the edge of the screen
if (dx+windowBounds.width > ss.x + ss.width) {
dx = ss.x + ss.width - windowBounds.width;
}
if (dx < ss.x) dx = 0;
if (dy < ss.y) dy = 0;
setLocation(dx, dy);
}
|
java.awt.Component | setTemporaryLostComponent(java.awt.Component component)
Component previousComp = temporaryLostComponent;
// Check that "component" is an acceptable focus owner and don't store it otherwise
// - or later we will have problems with opposite while handling WINDOW_GAINED_FOCUS
if (component == null
|| (component.isDisplayable() && component.isVisible() && component.isEnabled() && component.isFocusable()))
{
temporaryLostComponent = component;
} else {
temporaryLostComponent = null;
}
return previousComp;
|
private void | setWarningString()
warningString = null;
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
if (!sm.checkTopLevelWindow(this)) {
// make sure the privileged action is only
// for getting the property! We don't want the
// above checkTopLevelWindow call to always succeed!
warningString = (String) AccessController.doPrivileged(
new GetPropertyAction("awt.appletWarning",
"Java Applet Window"));
}
}
|
public void | show()
if (peer == null) {
addNotify();
}
validate();
if (visible) {
toFront();
} else {
beforeFirstShow = false;
super.show();
locationByPlatform = false;
for (int i = 0; i < ownedWindowList.size(); i++) {
Window child = (Window) (((WeakReference)
(ownedWindowList.elementAt(i))).get());
if ((child != null) && child.showWithParent) {
child.show();
child.showWithParent = false;
} // endif
} // endfor
}
// If first time shown, generate WindowOpened event
if ((state & OPENED) == 0) {
postWindowEvent(WindowEvent.WINDOW_OPENED);
state |= OPENED;
}
|
public void | toBack()If this Window is visible, sends this Window to the back and may cause
it to lose focus or activation if it is the focused or active Window.
Places this Window at the bottom of the stacking order and shows it
behind any other Windows in this VM. No action will take place is this
Window is not visible. Some platforms do not allow Windows which are
owned by other Windows to appear below their owners. Every attempt will
be made to move this Window as low as possible in the stacking order;
however, developers should not assume that this method will move this
Window below all other windows in every situation.
Because of variations in native windowing systems, no guarantees about
changes to the focused and active Windows can be made. Developers must
never assume that this Window is no longer the focused or active Window
until this Window receives a WINDOW_LOST_FOCUS or WINDOW_DEACTIVATED
event. On platforms where the top-most window is the focused window,
this method will probably cause this Window to lose focus. In
that case, the next highest, focusable Window in this VM will receive
focus. On platforms where the stacking order does not typically affect
the focused window, this method will probably leave the focused
and active Windows unchanged.
if (visible) {
WindowPeer peer = (WindowPeer)this.peer;
if (peer != null) {
peer.toBack();
}
}
|
public void | toFront()If this Window is visible, brings this Window to the front and may make
it the focused Window.
Places this Window at the top of the stacking order and shows it in
front of any other Windows in this VM. No action will take place if this
Window is not visible. Some platforms do not allow Windows which own
other Windows to appear on top of those owned Windows. Some platforms
may not permit this VM to place its Windows above windows of native
applications, or Windows of other VMs. This permission may depend on
whether a Window in this VM is already focused. Every attempt will be
made to move this Window as high as possible in the stacking order;
however, developers should not assume that this method will move this
Window above all other windows in every situation.
Because of variations in native windowing systems, no guarantees about
changes to the focused and active Windows can be made. Developers must
never assume that this Window is the focused or active Window until this
Window receives a WINDOW_GAINED_FOCUS or WINDOW_ACTIVATED event. On
platforms where the top-most window is the focused window, this method
will probably focus this Window, if it is not already focused. On
platforms where the stacking order does not typically affect the focused
window, this method will probably leave the focused and active
Windows unchanged.
If this method causes this Window to be focused, and this Window is a
Frame or a Dialog, it will also become activated. If this Window is
focused, but it is not a Frame or a Dialog, then the first Frame or
Dialog that is an owner of this Window will be activated.
if (visible) {
WindowPeer peer = (WindowPeer)this.peer;
if (peer != null) {
peer.toFront();
}
}
|
private void | writeObject(java.io.ObjectOutputStream s)Writes default serializable fields to stream. Writes
a list of serializable WindowListener s and
WindowFocusListener s as optional data.
Writes a list of child windows as optional data.
synchronized (this) {
// Update old focusMgr fields so that our object stream can be read
// by previous releases
focusMgr = new FocusManager();
focusMgr.focusRoot = this;
focusMgr.focusOwner = getMostRecentFocusOwner();
s.defaultWriteObject();
// Clear fields so that we don't keep extra references around
focusMgr = null;
AWTEventMulticaster.save(s, windowListenerK, windowListener);
AWTEventMulticaster.save(s, windowFocusListenerK, windowFocusListener);
AWTEventMulticaster.save(s, windowStateListenerK, windowStateListener);
}
s.writeObject(null);
synchronized (ownedWindowList) {
for (int i = 0; i < ownedWindowList.size(); i++) {
Window child = (Window) (((WeakReference)
(ownedWindowList.elementAt(i))).get());
if (child != null) {
s.writeObject(ownedWindowK);
s.writeObject(child);
}
}
}
s.writeObject(null);
|