Fields Summary |
---|
public static final int | DEFAULT_CURSOR |
public static final int | CROSSHAIR_CURSOR |
public static final int | TEXT_CURSOR |
public static final int | WAIT_CURSOR |
public static final int | SW_RESIZE_CURSOR |
public static final int | SE_RESIZE_CURSOR |
public static final int | NW_RESIZE_CURSOR |
public static final int | NE_RESIZE_CURSOR |
public static final int | N_RESIZE_CURSOR |
public static final int | S_RESIZE_CURSOR |
public static final int | W_RESIZE_CURSOR |
public static final int | E_RESIZE_CURSOR |
public static final int | HAND_CURSOR |
public static final int | MOVE_CURSOR |
public static final int | NORMALFrame is in the "normal" state. This symbolic constant names a
frame state with all state bits cleared. |
public static final int | ICONIFIEDThis state bit indicates that frame is iconified. |
public static final int | MAXIMIZED_HORIZThis state bit indicates that frame is maximized in the
horizontal direction. |
public static final int | MAXIMIZED_VERTThis state bit indicates that frame is maximized in the
vertical direction. |
public static final int | MAXIMIZED_BOTHThis state bit mask indicates that frame is fully maximized
(that is both horizontally and vertically). It is just a
convenience alias for
MAXIMIZED_VERT | MAXIMIZED_HORIZ .
Note that the correct test for frame being fully maximized is
(state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH
To test is frame is maximized in some direction use
(state & Frame.MAXIMIZED_BOTH) != 0
|
Rectangle | maximizedBoundsMaximized bounds for this frame. |
String | titleThis is the title of the frame. It can be changed
at any time. title can be null and if
this is the case the title = "". |
MenuBar | menuBarThe frames menubar. If menuBar = null
the frame will not have a menubar. |
boolean | resizableThis field indicates whether the frame is resizable.
This property can be changed at any time.
resizable will be true if the frame is
resizable, otherwise it will be false. |
boolean | undecoratedThis field indicates whether the frame is undecorated.
This property can only be changed while the frame is not displayable.
undecorated will be true if the frame is
undecorated, otherwise it will be false. |
boolean | mbManagementmbManagement is only used by the Motif implementation. |
private int | state |
Vector | ownedWindows |
private static final String | base |
private static int | nameCounter |
private static final long | serialVersionUID |
private int | frameSerializedDataVersionFrame 's Serialized Data Version. |
Methods Summary |
---|
public void | addNotify()Makes this Frame displayable by connecting it to
a native screen resource. Making a frame displayable will
cause any of its children to be made displayable.
This method is called internally by the toolkit and should
not be called directly by programs.
synchronized (getTreeLock()) {
if (peer == null) {
peer = getToolkit().createFrame(this);
}
FramePeer p = (FramePeer)peer;
MenuBar menuBar = this.menuBar;
if (menuBar != null) {
mbManagement = true;
menuBar.addNotify();
p.setMenuBar(menuBar);
}
p.setMaximizedBounds(maximizedBounds);
super.addNotify();
}
|
java.lang.String | constructComponentName()Construct a name for this component. Called by getName() when the
name is null.
synchronized (getClass()) {
return base + nameCounter++;
}
|
public javax.accessibility.AccessibleContext | getAccessibleContext()Gets the AccessibleContext associated with this Frame.
For frames, the AccessibleContext takes the form of an
AccessibleAWTFrame.
A new AccessibleAWTFrame instance is created if necessary.
if (accessibleContext == null) {
accessibleContext = new AccessibleAWTFrame();
}
return accessibleContext;
|
public int | getCursorType()
return (getCursor().getType());
|
public synchronized int | getExtendedState()Gets the state of this frame. The state is
represented as a bitwise mask.
NORMAL
Indicates that no state bits are set.
ICONIFIED
MAXIMIZED_HORIZ
MAXIMIZED_VERT
MAXIMIZED_BOTH
Concatenates MAXIMIZED_HORIZ
and MAXIMIZED_VERT .
FramePeer peer = (FramePeer)this.peer;
if (peer != null) {
state = peer.getState();
}
return state;
|
public static java.awt.Frame[] | getFrames()Returns an array of all {@code Frame}s created by this application.
If called from an applet, the array includes only the {@code Frame}s
accessible by that applet.
Warning: this method may return system created frames, such
as a shared, hidden frame which is used by Swing. Applications
should not assume the existence of these frames, nor should an
application assume anything about these frames such as component
positions, LayoutManager s or serialization.
Note: To obtain a list of all ownerless windows, including
ownerless {@code Dialog}s (introduced in release 1.6), use {@link
Window#getOwnerlessWindows Window.getOwnerlessWindows}.
Window[] allWindows = Window.getWindows();
int frameCount = 0;
for (Window w : allWindows) {
if (w instanceof Frame) {
frameCount++;
}
}
Frame[] frames = new Frame[frameCount];
int c = 0;
for (Window w : allWindows) {
if (w instanceof Frame) {
frames[c++] = (Frame)w;
}
}
return frames;
|
public java.awt.Image | getIconImage()Returns the image to be displayed as the icon for this frame.
This method is obsolete and kept for backward compatibility
only. Use {@link Window#getIconImages Window.getIconImages()} instead.
If a list of several images was specified as a Window's icon,
this method will return the first item of the list.
java.util.List<Image> icons = this.icons;
if (icons != null) {
if (icons.size() > 0) {
return icons.get(0);
}
}
return null;
|
public java.awt.Rectangle | getMaximizedBounds()Gets maximized bounds for this frame.
Some fields may contain Integer.MAX_VALUE to indicate
that system supplied values for this field must be used.
return maximizedBounds;
|
public java.awt.MenuBar | getMenuBar()Gets the menu bar for this frame.
return menuBar;
|
public synchronized int | getState()Gets the state of this frame (obsolete).
In older versions of JDK a frame state could only be NORMAL or
ICONIFIED. Since JDK 1.4 set of supported frame states is
expanded and frame state is represented as a bitwise mask.
For compatibility with old programs this method still returns
Frame.NORMAL and Frame.ICONIFIED but
it only reports the iconic state of the frame, other aspects of
frame state are not reported by this method.
return (getExtendedState() & ICONIFIED) != 0 ? ICONIFIED : NORMAL;
|
public java.lang.String | getTitle()Gets the title of the frame. The title is displayed in the
frame's border.
return title;
|
private void | init(java.lang.String title, java.awt.GraphicsConfiguration gc)
this.title = title;
SunToolkit.checkAndSetPolicy(this, false);
|
private static native void | initIDs()Initialize JNI field and method IDs
|
private boolean | isFrameStateSupported(int state)
if( !getToolkit().isFrameStateSupported( state ) ) {
// * Toolkit.isFrameStateSupported returns always false
// on compound state even if all parts are supported;
// * if part of state is not supported, state is not supported;
// * MAXIMIZED_BOTH is not a compound state.
if( ((state & ICONIFIED) != 0) &&
!getToolkit().isFrameStateSupported( ICONIFIED )) {
return false;
}else {
state &= ~ICONIFIED;
}
return getToolkit().isFrameStateSupported( state );
}
return true;
|
public boolean | isResizable()Indicates whether this frame is resizable by the user.
By default, all frames are initially resizable.
return resizable;
|
public boolean | isUndecorated()Indicates whether this frame is undecorated.
By default, all frames are initially decorated.
return undecorated;
|
protected java.lang.String | paramString()Returns a string representing the state of this Frame .
This method is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not be
null .
String str = super.paramString();
if (title != null) {
str += ",title=" + title;
}
if (resizable) {
str += ",resizable";
}
getExtendedState(); // sync with peer
if (state == NORMAL) {
str += ",normal";
}
else {
if ((state & ICONIFIED) != 0) {
str += ",iconified";
}
if ((state & MAXIMIZED_BOTH) == MAXIMIZED_BOTH) {
str += ",maximized";
}
else if ((state & MAXIMIZED_HORIZ) != 0) {
str += ",maximized_horiz";
}
else if ((state & MAXIMIZED_VERT) != 0) {
str += ",maximized_vert";
}
}
return str;
|
void | postProcessKeyEvent(java.awt.event.KeyEvent e)
if (menuBar != null && menuBar.handleShortcut(e)) {
e.consume();
return;
}
super.postProcessKeyEvent(e);
|
private void | readObject(java.io.ObjectInputStream s)Reads the ObjectInputStream . Tries
to read an icon Image , which is optional
data available as of 1.4. If an icon Image
is not available, but anything other than an EOF
is detected, an OptionalDataException
will be thrown.
Unrecognized keys or values will be ignored.
// HeadlessException is thrown by Window's readObject
s.defaultReadObject();
try {
Image icon = (Image) s.readObject();
if (icons == null) {
icons = new ArrayList<Image>();
icons.add(icon);
}
} catch (java.io.OptionalDataException e) {
// pre-1.4 instances will not have this optional data.
// 1.6 and later instances serialize icons in the Window class
// e.eof will be true to indicate that there is no more
// data available for this object.
// If e.eof is not true, throw the exception as it
// might have been caused by unrelated reasons.
if (!e.eof) {
throw (e);
}
}
if (menuBar != null)
menuBar.parent = this;
// Ensure 1.1 serialized Frames can read & hook-up
// owned windows properly
//
if (ownedWindows != null) {
for (int i = 0; i < ownedWindows.size(); i++) {
connectOwnedWindow((Window) ownedWindows.elementAt(i));
}
ownedWindows = null;
}
|
public void | remove(java.awt.MenuComponent m)Removes the specified menu bar from this frame.
if (m == null) {
return;
}
synchronized (getTreeLock()) {
if (m == menuBar) {
menuBar = null;
FramePeer peer = (FramePeer)this.peer;
if (peer != null) {
mbManagement = true;
if (valid) {
invalidate();
}
peer.setMenuBar(null);
m.removeNotify();
}
m.parent = null;
} else {
super.remove(m);
}
}
|
public void | removeNotify()Makes this Frame undisplayable by removing its connection
to its native screen resource. Making a Frame undisplayable
will cause any of its children to be made undisplayable.
This method is called by the toolkit internally and should
not be called directly by programs.
synchronized (getTreeLock()) {
FramePeer peer = (FramePeer)this.peer;
if (peer != null) {
// get the latest Frame state before disposing
getState();
if (menuBar != null) {
mbManagement = true;
peer.setMenuBar(null);
menuBar.removeNotify();
}
}
super.removeNotify();
}
|
public void | setCursor(int cursorType)
if (cursorType < DEFAULT_CURSOR || cursorType > MOVE_CURSOR) {
throw new IllegalArgumentException("illegal cursor type");
}
setCursor(Cursor.getPredefinedCursor(cursorType));
|
public synchronized void | setExtendedState(int state)Sets the state of this frame. The state is
represented as a bitwise mask.
NORMAL
Indicates that no state bits are set.
ICONIFIED
MAXIMIZED_HORIZ
MAXIMIZED_VERT
MAXIMIZED_BOTH
Concatenates MAXIMIZED_HORIZ
and MAXIMIZED_VERT .
Note that if the state is not supported on a
given platform, nothing will happen. The application
may determine if a specific state is available via
the java.awt.Toolkit#isFrameStateSupported(int state)
method.
if ( !isFrameStateSupported( state ) ) {
return;
}
this.state = state;
FramePeer peer = (FramePeer)this.peer;
if (peer != null) {
peer.setState(state);
}
|
public void | setIconImage(java.awt.Image image){@inheritDoc}
super.setIconImage(image);
|
public synchronized void | setMaximizedBounds(java.awt.Rectangle bounds)Sets the maximized bounds for this frame.
When a frame is in maximized state the system supplies some
defaults bounds. This method allows some or all of those
system supplied values to be overridden.
If bounds is null , accept bounds
supplied by the system. If non-null you can
override some of the system supplied values while accepting
others by setting those fields you want to accept from system
to Integer.MAX_VALUE .
On some systems only the size portion of the bounds is taken
into account.
this.maximizedBounds = bounds;
FramePeer peer = (FramePeer)this.peer;
if (peer != null) {
peer.setMaximizedBounds(bounds);
}
|
public void | setMenuBar(java.awt.MenuBar mb)Sets the menu bar for this frame to the specified menu bar.
synchronized (getTreeLock()) {
if (menuBar == mb) {
return;
}
if ((mb != null) && (mb.parent != null)) {
mb.parent.remove(mb);
}
if (menuBar != null) {
remove(menuBar);
}
menuBar = mb;
if (menuBar != null) {
menuBar.parent = this;
FramePeer peer = (FramePeer)this.peer;
if (peer != null) {
mbManagement = true;
menuBar.addNotify();
if (valid) {
invalidate();
}
peer.setMenuBar(menuBar);
}
}
}
|
public void | setResizable(boolean resizable)Sets whether this frame is resizable by the user.
boolean oldResizable = this.resizable;
boolean testvalid = false;
synchronized (this) {
this.resizable = resizable;
FramePeer peer = (FramePeer)this.peer;
if (peer != null) {
peer.setResizable(resizable);
testvalid = true;
}
}
// On some platforms, changing the resizable state affects
// the insets of the Frame. If we could, we'd call invalidate()
// from the peer, but we need to guarantee that we're not holding
// the Frame lock when we call invalidate().
if (testvalid && valid) {
invalidate();
}
firePropertyChange("resizable", oldResizable, resizable);
|
public synchronized void | setState(int state)Sets the state of this frame (obsolete).
In older versions of JDK a frame state could only be NORMAL or
ICONIFIED. Since JDK 1.4 set of supported frame states is
expanded and frame state is represented as a bitwise mask.
For compatibility with old programs this method still accepts
Frame.NORMAL and Frame.ICONIFIED but
it only changes the iconic state of the frame, other aspects of
frame state are not affected by this method.
int current = getExtendedState();
if (state == ICONIFIED && (current & ICONIFIED) == 0) {
setExtendedState(current | ICONIFIED);
}
else if (state == NORMAL && (current & ICONIFIED) != 0) {
setExtendedState(current & ~ICONIFIED);
}
|
public void | setTitle(java.lang.String title)Sets the title for this frame to the specified string.
String oldTitle = this.title;
if (title == null) {
title = "";
}
synchronized(this) {
this.title = title;
FramePeer peer = (FramePeer)this.peer;
if (peer != null) {
peer.setTitle(title);
}
}
firePropertyChange("title", oldTitle, title);
|
public void | setUndecorated(boolean undecorated)Disables or enables decorations for this frame.
This method can only be called while the frame is not displayable.
/* Make sure we don't run in the middle of peer creation.*/
synchronized (getTreeLock()) {
if (isDisplayable()) {
throw new IllegalComponentStateException("The frame is displayable.");
}
this.undecorated = undecorated;
}
|
private void | writeObject(java.io.ObjectOutputStream s)Writes default serializable fields to stream. Writes
an optional serializable icon Image , which is
available as of 1.4.
s.defaultWriteObject();
if (icons != null && icons.size() > 0) {
Image icon1 = icons.get(0);
if (icon1 instanceof Serializable) {
s.writeObject(icon1);
return;
}
}
s.writeObject(null);
|