0N/A/*
3261N/A * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/Apackage java.awt;
0N/A
0N/Aimport java.awt.peer.FramePeer;
0N/Aimport java.awt.event.*;
0N/Aimport java.util.ArrayList;
0N/Aimport java.util.Arrays;
0N/Aimport java.util.List;
0N/Aimport java.util.Vector;
0N/Aimport java.io.Serializable;
0N/Aimport java.io.ObjectOutputStream;
0N/Aimport java.io.ObjectInputStream;
0N/Aimport java.io.IOException;
0N/Aimport sun.awt.AppContext;
0N/Aimport sun.awt.SunToolkit;
1047N/Aimport sun.awt.AWTAccessor;
0N/Aimport java.lang.ref.WeakReference;
0N/Aimport javax.accessibility.*;
0N/A
0N/A/**
0N/A * A <code>Frame</code> is a top-level window with a title and a border.
0N/A * <p>
0N/A * The size of the frame includes any area designated for the
0N/A * border. The dimensions of the border area may be obtained
0N/A * using the <code>getInsets</code> method, however, since
0N/A * these dimensions are platform-dependent, a valid insets
0N/A * value cannot be obtained until the frame is made displayable
0N/A * by either calling <code>pack</code> or <code>show</code>.
0N/A * Since the border area is included in the overall size of the
0N/A * frame, the border effectively obscures a portion of the frame,
0N/A * constraining the area available for rendering and/or displaying
0N/A * subcomponents to the rectangle which has an upper-left corner
0N/A * location of <code>(insets.left, insets.top)</code>, and has a size of
0N/A * <code>width - (insets.left + insets.right)</code> by
0N/A * <code>height - (insets.top + insets.bottom)</code>.
0N/A * <p>
0N/A * The default layout for a frame is <code>BorderLayout</code>.
0N/A * <p>
0N/A * A frame may have its native decorations (i.e. <code>Frame</code>
0N/A * and <code>Titlebar</code>) turned off
0N/A * with <code>setUndecorated</code>. This can only be done while the frame
0N/A * is not {@link Component#isDisplayable() displayable}.
0N/A * <p>
0N/A * In a multi-screen environment, you can create a <code>Frame</code>
0N/A * on a different screen device by constructing the <code>Frame</code>
0N/A * with {@link #Frame(GraphicsConfiguration)} or
0N/A * {@link #Frame(String title, GraphicsConfiguration)}. The
0N/A * <code>GraphicsConfiguration</code> object is one of the
0N/A * <code>GraphicsConfiguration</code> objects of the target screen
0N/A * device.
0N/A * <p>
0N/A * In a virtual device multi-screen environment in which the desktop
0N/A * area could span multiple physical screen devices, the bounds of all
0N/A * configurations are relative to the virtual-coordinate system. The
0N/A * origin of the virtual-coordinate system is at the upper left-hand
0N/A * corner of the primary physical screen. Depending on the location
0N/A * of the primary screen in the virtual device, negative coordinates
0N/A * are possible, as shown in the following figure.
0N/A * <p>
0N/A * <img src="doc-files/MultiScreen.gif"
0N/A * alt="Diagram of virtual device encompassing three physical screens and one primary physical screen. The primary physical screen
0N/A * shows (0,0) coords while a different physical screen shows (-80,-100) coords."
0N/A * ALIGN=center HSPACE=10 VSPACE=7>
0N/A * <p>
0N/A * In such an environment, when calling <code>setLocation</code>,
0N/A * you must pass a virtual coordinate to this method. Similarly,
0N/A * calling <code>getLocationOnScreen</code> on a <code>Frame</code>
0N/A * returns virtual device coordinates. Call the <code>getBounds</code>
0N/A * method of a <code>GraphicsConfiguration</code> to find its origin in
0N/A * the virtual coordinate system.
0N/A * <p>
0N/A * The following code sets the
0N/A * location of the <code>Frame</code> at (10, 10) relative
0N/A * to the origin of the physical screen of the corresponding
0N/A * <code>GraphicsConfiguration</code>. If the bounds of the
0N/A * <code>GraphicsConfiguration</code> is not taken into account, the
0N/A * <code>Frame</code> location would be set at (10, 10) relative to the
0N/A * virtual-coordinate system and would appear on the primary physical
0N/A * screen, which might be different from the physical screen of the
0N/A * specified <code>GraphicsConfiguration</code>.
0N/A *
0N/A * <pre>
0N/A * Frame f = new Frame(GraphicsConfiguration gc);
0N/A * Rectangle bounds = gc.getBounds();
0N/A * f.setLocation(10 + bounds.x, 10 + bounds.y);
0N/A * </pre>
0N/A *
0N/A * <p>
0N/A * Frames are capable of generating the following types of
0N/A * <code>WindowEvent</code>s:
0N/A * <ul>
0N/A * <li><code>WINDOW_OPENED</code>
0N/A * <li><code>WINDOW_CLOSING</code>:
0N/A * <br>If the program doesn't
0N/A * explicitly hide or dispose the window while processing
0N/A * this event, the window close operation is canceled.
0N/A * <li><code>WINDOW_CLOSED</code>
0N/A * <li><code>WINDOW_ICONIFIED</code>
0N/A * <li><code>WINDOW_DEICONIFIED</code>
0N/A * <li><code>WINDOW_ACTIVATED</code>
0N/A * <li><code>WINDOW_DEACTIVATED</code>
0N/A * <li><code>WINDOW_GAINED_FOCUS</code>
0N/A * <li><code>WINDOW_LOST_FOCUS</code>
0N/A * <li><code>WINDOW_STATE_CHANGED</code>
0N/A * </ul>
0N/A *
0N/A * @author Sami Shaio
0N/A * @see WindowEvent
0N/A * @see Window#addWindowListener
0N/A * @since JDK1.0
0N/A */
0N/Apublic class Frame extends Window implements MenuContainer {
0N/A
0N/A /* Note: These are being obsoleted; programs should use the Cursor class
0N/A * variables going forward. See Cursor and Component.setCursor.
0N/A */
0N/A
0N/A /**
0N/A * @deprecated replaced by <code>Cursor.DEFAULT_CURSOR</code>.
0N/A */
0N/A @Deprecated
0N/A public static final int DEFAULT_CURSOR = Cursor.DEFAULT_CURSOR;
0N/A
0N/A
0N/A /**
0N/A * @deprecated replaced by <code>Cursor.CROSSHAIR_CURSOR</code>.
0N/A */
0N/A @Deprecated
0N/A public static final int CROSSHAIR_CURSOR = Cursor.CROSSHAIR_CURSOR;
0N/A
0N/A /**
0N/A * @deprecated replaced by <code>Cursor.TEXT_CURSOR</code>.
0N/A */
0N/A @Deprecated
0N/A public static final int TEXT_CURSOR = Cursor.TEXT_CURSOR;
0N/A
0N/A /**
0N/A * @deprecated replaced by <code>Cursor.WAIT_CURSOR</code>.
0N/A */
0N/A @Deprecated
0N/A public static final int WAIT_CURSOR = Cursor.WAIT_CURSOR;
0N/A
0N/A /**
0N/A * @deprecated replaced by <code>Cursor.SW_RESIZE_CURSOR</code>.
0N/A */
0N/A @Deprecated
0N/A public static final int SW_RESIZE_CURSOR = Cursor.SW_RESIZE_CURSOR;
0N/A
0N/A /**
0N/A * @deprecated replaced by <code>Cursor.SE_RESIZE_CURSOR</code>.
0N/A */
0N/A @Deprecated
0N/A public static final int SE_RESIZE_CURSOR = Cursor.SE_RESIZE_CURSOR;
0N/A
0N/A /**
0N/A * @deprecated replaced by <code>Cursor.NW_RESIZE_CURSOR</code>.
0N/A */
0N/A @Deprecated
0N/A public static final int NW_RESIZE_CURSOR = Cursor.NW_RESIZE_CURSOR;
0N/A
0N/A /**
0N/A * @deprecated replaced by <code>Cursor.NE_RESIZE_CURSOR</code>.
0N/A */
0N/A @Deprecated
0N/A public static final int NE_RESIZE_CURSOR = Cursor.NE_RESIZE_CURSOR;
0N/A
0N/A /**
0N/A * @deprecated replaced by <code>Cursor.N_RESIZE_CURSOR</code>.
0N/A */
0N/A @Deprecated
0N/A public static final int N_RESIZE_CURSOR = Cursor.N_RESIZE_CURSOR;
0N/A
0N/A /**
0N/A * @deprecated replaced by <code>Cursor.S_RESIZE_CURSOR</code>.
0N/A */
0N/A @Deprecated
0N/A public static final int S_RESIZE_CURSOR = Cursor.S_RESIZE_CURSOR;
0N/A
0N/A /**
0N/A * @deprecated replaced by <code>Cursor.W_RESIZE_CURSOR</code>.
0N/A */
0N/A @Deprecated
0N/A public static final int W_RESIZE_CURSOR = Cursor.W_RESIZE_CURSOR;
0N/A
0N/A /**
0N/A * @deprecated replaced by <code>Cursor.E_RESIZE_CURSOR</code>.
0N/A */
0N/A @Deprecated
0N/A public static final int E_RESIZE_CURSOR = Cursor.E_RESIZE_CURSOR;
0N/A
0N/A /**
0N/A * @deprecated replaced by <code>Cursor.HAND_CURSOR</code>.
0N/A */
0N/A @Deprecated
0N/A public static final int HAND_CURSOR = Cursor.HAND_CURSOR;
0N/A
0N/A /**
0N/A * @deprecated replaced by <code>Cursor.MOVE_CURSOR</code>.
0N/A */
0N/A @Deprecated
0N/A public static final int MOVE_CURSOR = Cursor.MOVE_CURSOR;
0N/A
0N/A
0N/A /**
0N/A * Frame is in the "normal" state. This symbolic constant names a
0N/A * frame state with all state bits cleared.
0N/A * @see #setExtendedState(int)
0N/A * @see #getExtendedState
0N/A */
0N/A public static final int NORMAL = 0;
0N/A
0N/A /**
0N/A * This state bit indicates that frame is iconified.
0N/A * @see #setExtendedState(int)
0N/A * @see #getExtendedState
0N/A */
0N/A public static final int ICONIFIED = 1;
0N/A
0N/A /**
0N/A * This state bit indicates that frame is maximized in the
0N/A * horizontal direction.
0N/A * @see #setExtendedState(int)
0N/A * @see #getExtendedState
0N/A * @since 1.4
0N/A */
0N/A public static final int MAXIMIZED_HORIZ = 2;
0N/A
0N/A /**
0N/A * This state bit indicates that frame is maximized in the
0N/A * vertical direction.
0N/A * @see #setExtendedState(int)
0N/A * @see #getExtendedState
0N/A * @since 1.4
0N/A */
0N/A public static final int MAXIMIZED_VERT = 4;
0N/A
0N/A /**
0N/A * This state bit mask indicates that frame is fully maximized
0N/A * (that is both horizontally and vertically). It is just a
0N/A * convenience alias for
0N/A * <code>MAXIMIZED_VERT&nbsp;|&nbsp;MAXIMIZED_HORIZ</code>.
0N/A *
0N/A * <p>Note that the correct test for frame being fully maximized is
0N/A * <pre>
0N/A * (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH
0N/A * </pre>
0N/A *
0N/A * <p>To test is frame is maximized in <em>some</em> direction use
0N/A * <pre>
0N/A * (state & Frame.MAXIMIZED_BOTH) != 0
0N/A * </pre>
0N/A *
0N/A * @see #setExtendedState(int)
0N/A * @see #getExtendedState
0N/A * @since 1.4
0N/A */
0N/A public static final int MAXIMIZED_BOTH = MAXIMIZED_VERT | MAXIMIZED_HORIZ;
0N/A
0N/A /**
0N/A * Maximized bounds for this frame.
0N/A * @see #setMaximizedBounds(Rectangle)
0N/A * @see #getMaximizedBounds
0N/A * @serial
0N/A * @since 1.4
0N/A */
0N/A Rectangle maximizedBounds;
0N/A
0N/A
0N/A /**
0N/A * This is the title of the frame. It can be changed
0N/A * at any time. <code>title</code> can be null and if
0N/A * this is the case the <code>title</code> = "".
0N/A *
0N/A * @serial
0N/A * @see #getTitle
0N/A * @see #setTitle(String)
0N/A */
0N/A String title = "Untitled";
0N/A
0N/A /**
0N/A * The frames menubar. If <code>menuBar</code> = null
0N/A * the frame will not have a menubar.
0N/A *
0N/A * @serial
0N/A * @see #getMenuBar
0N/A * @see #setMenuBar(MenuBar)
0N/A */
0N/A MenuBar menuBar;
0N/A
0N/A /**
0N/A * This field indicates whether the frame is resizable.
0N/A * This property can be changed at any time.
0N/A * <code>resizable</code> will be true if the frame is
0N/A * resizable, otherwise it will be false.
0N/A *
0N/A * @serial
0N/A * @see #isResizable()
0N/A */
0N/A boolean resizable = true;
0N/A
0N/A /**
0N/A * This field indicates whether the frame is undecorated.
0N/A * This property can only be changed while the frame is not displayable.
0N/A * <code>undecorated</code> will be true if the frame is
0N/A * undecorated, otherwise it will be false.
0N/A *
0N/A * @serial
0N/A * @see #setUndecorated(boolean)
0N/A * @see #isUndecorated()
0N/A * @see Component#isDisplayable()
0N/A * @since 1.4
0N/A */
0N/A boolean undecorated = false;
0N/A
0N/A /**
0N/A * <code>mbManagement</code> is only used by the Motif implementation.
0N/A *
0N/A * @serial
0N/A */
0N/A boolean mbManagement = false; /* used only by the Motif impl. */
0N/A
0N/A // XXX: uwe: abuse old field for now
0N/A // will need to take care of serialization
0N/A private int state = NORMAL;
0N/A
0N/A /*
0N/A * The Windows owned by the Frame.
0N/A * Note: in 1.2 this has been superceded by Window.ownedWindowList
0N/A *
0N/A * @serial
0N/A * @see java.awt.Window#ownedWindowList
0N/A */
0N/A Vector ownedWindows;
0N/A
0N/A private static final String base = "frame";
0N/A private static int nameCounter = 0;
0N/A
0N/A /*
0N/A * JDK 1.1 serialVersionUID
0N/A */
0N/A private static final long serialVersionUID = 2673458971256075116L;
0N/A
0N/A static {
0N/A /* ensure that the necessary native libraries are loaded */
0N/A Toolkit.loadLibraries();
0N/A if (!GraphicsEnvironment.isHeadless()) {
0N/A initIDs();
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Constructs a new instance of <code>Frame</code> that is
0N/A * initially invisible. The title of the <code>Frame</code>
0N/A * is empty.
0N/A * @exception HeadlessException when
0N/A * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
0N/A * @see java.awt.GraphicsEnvironment#isHeadless()
0N/A * @see Component#setSize
0N/A * @see Component#setVisible(boolean)
0N/A */
0N/A public Frame() throws HeadlessException {
0N/A this("");
0N/A }
0N/A
0N/A /**
0N/A * Constructs a new, initially invisible {@code Frame} with the
0N/A * specified {@code GraphicsConfiguration}.
0N/A *
0N/A * @param gc the <code>GraphicsConfiguration</code>
0N/A * of the target screen device. If <code>gc</code>
0N/A * is <code>null</code>, the system default
0N/A * <code>GraphicsConfiguration</code> is assumed.
0N/A * @exception IllegalArgumentException if
0N/A * <code>gc</code> is not from a screen device.
0N/A * @exception HeadlessException when
0N/A * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
0N/A * @see java.awt.GraphicsEnvironment#isHeadless()
0N/A * @since 1.3
0N/A */
0N/A public Frame(GraphicsConfiguration gc) {
0N/A this("", gc);
0N/A }
0N/A
0N/A /**
0N/A * Constructs a new, initially invisible <code>Frame</code> object
0N/A * with the specified title.
0N/A * @param title the title to be displayed in the frame's border.
0N/A * A <code>null</code> value
0N/A * is treated as an empty string, "".
0N/A * @exception HeadlessException when
0N/A * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
0N/A * @see java.awt.GraphicsEnvironment#isHeadless()
0N/A * @see java.awt.Component#setSize
0N/A * @see java.awt.Component#setVisible(boolean)
0N/A * @see java.awt.GraphicsConfiguration#getBounds
0N/A */
0N/A public Frame(String title) throws HeadlessException {
0N/A init(title, null);
0N/A }
0N/A
0N/A /**
0N/A * Constructs a new, initially invisible <code>Frame</code> object
0N/A * with the specified title and a
0N/A * <code>GraphicsConfiguration</code>.
0N/A * @param title the title to be displayed in the frame's border.
0N/A * A <code>null</code> value
0N/A * is treated as an empty string, "".
0N/A * @param gc the <code>GraphicsConfiguration</code>
0N/A * of the target screen device. If <code>gc</code> is
0N/A * <code>null</code>, the system default
0N/A * <code>GraphicsConfiguration</code> is assumed.
0N/A * @exception IllegalArgumentException if <code>gc</code>
0N/A * is not from a screen device.
0N/A * @exception HeadlessException when
0N/A * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
0N/A * @see java.awt.GraphicsEnvironment#isHeadless()
0N/A * @see java.awt.Component#setSize
0N/A * @see java.awt.Component#setVisible(boolean)
0N/A * @see java.awt.GraphicsConfiguration#getBounds
0N/A * @since 1.3
0N/A */
0N/A public Frame(String title, GraphicsConfiguration gc) {
0N/A super(gc);
0N/A init(title, gc);
0N/A }
0N/A
0N/A private void init(String title, GraphicsConfiguration gc) {
0N/A this.title = title;
4875N/A SunToolkit.checkAndSetPolicy(this);
0N/A }
0N/A
0N/A /**
0N/A * Construct a name for this component. Called by getName() when the
0N/A * name is null.
0N/A */
0N/A String constructComponentName() {
0N/A synchronized (Frame.class) {
0N/A return base + nameCounter++;
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Makes this Frame displayable by connecting it to
0N/A * a native screen resource. Making a frame displayable will
0N/A * cause any of its children to be made displayable.
0N/A * This method is called internally by the toolkit and should
0N/A * not be called directly by programs.
0N/A * @see Component#isDisplayable
0N/A * @see #removeNotify
0N/A */
0N/A public void addNotify() {
0N/A synchronized (getTreeLock()) {
0N/A if (peer == null) {
0N/A peer = getToolkit().createFrame(this);
0N/A }
0N/A FramePeer p = (FramePeer)peer;
0N/A MenuBar menuBar = this.menuBar;
0N/A if (menuBar != null) {
0N/A mbManagement = true;
0N/A menuBar.addNotify();
0N/A p.setMenuBar(menuBar);
0N/A }
0N/A p.setMaximizedBounds(maximizedBounds);
0N/A super.addNotify();
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Gets the title of the frame. The title is displayed in the
0N/A * frame's border.
0N/A * @return the title of this frame, or an empty string ("")
0N/A * if this frame doesn't have a title.
0N/A * @see #setTitle(String)
0N/A */
0N/A public String getTitle() {
0N/A return title;
0N/A }
0N/A
0N/A /**
0N/A * Sets the title for this frame to the specified string.
0N/A * @param title the title to be displayed in the frame's border.
0N/A * A <code>null</code> value
0N/A * is treated as an empty string, "".
0N/A * @see #getTitle
0N/A */
0N/A public void setTitle(String title) {
0N/A String oldTitle = this.title;
0N/A if (title == null) {
0N/A title = "";
0N/A }
0N/A
0N/A
0N/A synchronized(this) {
0N/A this.title = title;
0N/A FramePeer peer = (FramePeer)this.peer;
0N/A if (peer != null) {
0N/A peer.setTitle(title);
0N/A }
0N/A }
0N/A firePropertyChange("title", oldTitle, title);
0N/A }
0N/A
0N/A /**
0N/A * Returns the image to be displayed as the icon for this frame.
0N/A * <p>
0N/A * This method is obsolete and kept for backward compatibility
0N/A * only. Use {@link Window#getIconImages Window.getIconImages()} instead.
0N/A * <p>
0N/A * If a list of several images was specified as a Window's icon,
0N/A * this method will return the first item of the list.
0N/A *
0N/A * @return the icon image for this frame, or <code>null</code>
0N/A * if this frame doesn't have an icon image.
0N/A * @see #setIconImage(Image)
0N/A * @see Window#getIconImages()
0N/A * @see Window#setIconImages
0N/A */
0N/A public Image getIconImage() {
0N/A java.util.List<Image> icons = this.icons;
0N/A if (icons != null) {
0N/A if (icons.size() > 0) {
0N/A return icons.get(0);
0N/A }
0N/A }
0N/A return null;
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public void setIconImage(Image image) {
0N/A super.setIconImage(image);
0N/A }
0N/A
0N/A /**
0N/A * Gets the menu bar for this frame.
0N/A * @return the menu bar for this frame, or <code>null</code>
0N/A * if this frame doesn't have a menu bar.
0N/A * @see #setMenuBar(MenuBar)
0N/A */
0N/A public MenuBar getMenuBar() {
0N/A return menuBar;
0N/A }
0N/A
0N/A /**
0N/A * Sets the menu bar for this frame to the specified menu bar.
0N/A * @param mb the menu bar being set.
0N/A * If this parameter is <code>null</code> then any
0N/A * existing menu bar on this frame is removed.
0N/A * @see #getMenuBar
0N/A */
0N/A public void setMenuBar(MenuBar mb) {
0N/A synchronized (getTreeLock()) {
0N/A if (menuBar == mb) {
0N/A return;
0N/A }
0N/A if ((mb != null) && (mb.parent != null)) {
0N/A mb.parent.remove(mb);
0N/A }
0N/A if (menuBar != null) {
0N/A remove(menuBar);
0N/A }
0N/A menuBar = mb;
0N/A if (menuBar != null) {
0N/A menuBar.parent = this;
0N/A
0N/A FramePeer peer = (FramePeer)this.peer;
0N/A if (peer != null) {
0N/A mbManagement = true;
0N/A menuBar.addNotify();
555N/A invalidateIfValid();
0N/A peer.setMenuBar(menuBar);
0N/A }
0N/A }
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Indicates whether this frame is resizable by the user.
0N/A * By default, all frames are initially resizable.
0N/A * @return <code>true</code> if the user can resize this frame;
0N/A * <code>false</code> otherwise.
0N/A * @see java.awt.Frame#setResizable(boolean)
0N/A */
0N/A public boolean isResizable() {
0N/A return resizable;
0N/A }
0N/A
0N/A /**
0N/A * Sets whether this frame is resizable by the user.
0N/A * @param resizable <code>true</code> if this frame is resizable;
0N/A * <code>false</code> otherwise.
0N/A * @see java.awt.Frame#isResizable
0N/A */
0N/A public void setResizable(boolean resizable) {
0N/A boolean oldResizable = this.resizable;
0N/A boolean testvalid = false;
0N/A
0N/A synchronized (this) {
0N/A this.resizable = resizable;
0N/A FramePeer peer = (FramePeer)this.peer;
0N/A if (peer != null) {
0N/A peer.setResizable(resizable);
0N/A testvalid = true;
0N/A }
0N/A }
0N/A
0N/A // On some platforms, changing the resizable state affects
0N/A // the insets of the Frame. If we could, we'd call invalidate()
0N/A // from the peer, but we need to guarantee that we're not holding
0N/A // the Frame lock when we call invalidate().
555N/A if (testvalid) {
555N/A invalidateIfValid();
0N/A }
0N/A firePropertyChange("resizable", oldResizable, resizable);
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Sets the state of this frame (obsolete).
0N/A * <p>
0N/A * In older versions of JDK a frame state could only be NORMAL or
0N/A * ICONIFIED. Since JDK 1.4 set of supported frame states is
0N/A * expanded and frame state is represented as a bitwise mask.
0N/A * <p>
0N/A * For compatibility with applications developed
0N/A * earlier this method still accepts
0N/A * {@code Frame.NORMAL} and
0N/A * {@code Frame.ICONIFIED} only. The iconic
0N/A * state of the frame is only changed, other aspects
0N/A * of frame state are not affected by this method. If
0N/A * the state passed to this method is neither {@code
0N/A * Frame.NORMAL} nor {@code Frame.ICONIFIED} the
0N/A * method performs no actions at all.
0N/A * <p>Note that if the state is not supported on a
0N/A * given platform, neither the state nor the return
0N/A * value of the {@link #getState} method will be
0N/A * changed. The application may determine whether a
0N/A * specific state is supported via the {@link
0N/A * java.awt.Toolkit#isFrameStateSupported} method.
0N/A * <p><b>If the frame is currently visible on the
0N/A * screen</b> (the {@link #isShowing} method returns
0N/A * {@code true}), the developer should examine the
0N/A * return value of the {@link
0N/A * java.awt.event.WindowEvent#getNewState} method of
0N/A * the {@code WindowEvent} received through the
0N/A * {@link java.awt.event.WindowStateListener} to
0N/A * determine that the state has actually been
0N/A * changed.
0N/A * <p><b>If the frame is not visible on the
0N/A * screen</b>, the events may or may not be
0N/A * generated. In this case the developer may assume
0N/A * that the state changes immediately after this
0N/A * method returns. Later, when the {@code
0N/A * setVisible(true)} method is invoked, the frame
0N/A * will attempt to apply this state. Receiving any
0N/A * {@link
0N/A * java.awt.event.WindowEvent#WINDOW_STATE_CHANGED}
0N/A * events is not guaranteed in this case also.
0N/A *
0N/A * @param state either <code>Frame.NORMAL</code> or
0N/A * <code>Frame.ICONIFIED</code>.
0N/A * @see #setExtendedState(int)
0N/A * @see java.awt.Window#addWindowStateListener
0N/A */
0N/A public synchronized void setState(int state) {
0N/A int current = getExtendedState();
0N/A if (state == ICONIFIED && (current & ICONIFIED) == 0) {
0N/A setExtendedState(current | ICONIFIED);
0N/A }
0N/A else if (state == NORMAL && (current & ICONIFIED) != 0) {
0N/A setExtendedState(current & ~ICONIFIED);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Sets the state of this frame. The state is
0N/A * represented as a bitwise mask.
0N/A * <ul>
0N/A * <li><code>NORMAL</code>
0N/A * <br>Indicates that no state bits are set.
0N/A * <li><code>ICONIFIED</code>
0N/A * <li><code>MAXIMIZED_HORIZ</code>
0N/A * <li><code>MAXIMIZED_VERT</code>
0N/A * <li><code>MAXIMIZED_BOTH</code>
0N/A * <br>Concatenates <code>MAXIMIZED_HORIZ</code>
0N/A * and <code>MAXIMIZED_VERT</code>.
0N/A * </ul>
0N/A * <p>Note that if the state is not supported on a
0N/A * given platform, neither the state nor the return
0N/A * value of the {@link #getExtendedState} method will
0N/A * be changed. The application may determine whether
0N/A * a specific state is supported via the {@link
0N/A * java.awt.Toolkit#isFrameStateSupported} method.
0N/A * <p><b>If the frame is currently visible on the
0N/A * screen</b> (the {@link #isShowing} method returns
0N/A * {@code true}), the developer should examine the
0N/A * return value of the {@link
0N/A * java.awt.event.WindowEvent#getNewState} method of
0N/A * the {@code WindowEvent} received through the
0N/A * {@link java.awt.event.WindowStateListener} to
0N/A * determine that the state has actually been
0N/A * changed.
0N/A * <p><b>If the frame is not visible on the
0N/A * screen</b>, the events may or may not be
0N/A * generated. In this case the developer may assume
0N/A * that the state changes immediately after this
0N/A * method returns. Later, when the {@code
0N/A * setVisible(true)} method is invoked, the frame
0N/A * will attempt to apply this state. Receiving any
0N/A * {@link
0N/A * java.awt.event.WindowEvent#WINDOW_STATE_CHANGED}
0N/A * events is not guaranteed in this case also.
0N/A *
0N/A * @param state a bitwise mask of frame state constants
0N/A * @since 1.4
0N/A * @see java.awt.Window#addWindowStateListener
0N/A */
1047N/A public void setExtendedState(int state) {
0N/A if ( !isFrameStateSupported( state ) ) {
0N/A return;
0N/A }
1047N/A synchronized (getObjectLock()) {
1047N/A this.state = state;
1047N/A }
1047N/A // peer.setState must be called outside of object lock
1047N/A // synchronization block to avoid possible deadlock
0N/A FramePeer peer = (FramePeer)this.peer;
0N/A if (peer != null) {
0N/A peer.setState(state);
0N/A }
0N/A }
0N/A private boolean isFrameStateSupported(int state) {
0N/A if( !getToolkit().isFrameStateSupported( state ) ) {
0N/A // * Toolkit.isFrameStateSupported returns always false
0N/A // on compound state even if all parts are supported;
0N/A // * if part of state is not supported, state is not supported;
0N/A // * MAXIMIZED_BOTH is not a compound state.
0N/A if( ((state & ICONIFIED) != 0) &&
0N/A !getToolkit().isFrameStateSupported( ICONIFIED )) {
0N/A return false;
0N/A }else {
0N/A state &= ~ICONIFIED;
0N/A }
0N/A return getToolkit().isFrameStateSupported( state );
0N/A }
0N/A return true;
0N/A }
0N/A
0N/A /**
0N/A * Gets the state of this frame (obsolete).
0N/A * <p>
0N/A * In older versions of JDK a frame state could only be NORMAL or
0N/A * ICONIFIED. Since JDK 1.4 set of supported frame states is
0N/A * expanded and frame state is represented as a bitwise mask.
0N/A * <p>
0N/A * For compatibility with old programs this method still returns
0N/A * <code>Frame.NORMAL</code> and <code>Frame.ICONIFIED</code> but
0N/A * it only reports the iconic state of the frame, other aspects of
0N/A * frame state are not reported by this method.
0N/A *
0N/A * @return <code>Frame.NORMAL</code> or <code>Frame.ICONIFIED</code>.
0N/A * @see #setState(int)
0N/A * @see #getExtendedState
0N/A */
0N/A public synchronized int getState() {
0N/A return (getExtendedState() & ICONIFIED) != 0 ? ICONIFIED : NORMAL;
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Gets the state of this frame. The state is
0N/A * represented as a bitwise mask.
0N/A * <ul>
0N/A * <li><code>NORMAL</code>
0N/A * <br>Indicates that no state bits are set.
0N/A * <li><code>ICONIFIED</code>
0N/A * <li><code>MAXIMIZED_HORIZ</code>
0N/A * <li><code>MAXIMIZED_VERT</code>
0N/A * <li><code>MAXIMIZED_BOTH</code>
0N/A * <br>Concatenates <code>MAXIMIZED_HORIZ</code>
0N/A * and <code>MAXIMIZED_VERT</code>.
0N/A * </ul>
0N/A *
0N/A * @return a bitwise mask of frame state constants
0N/A * @see #setExtendedState(int)
0N/A * @since 1.4
0N/A */
1047N/A public int getExtendedState() {
1047N/A synchronized (getObjectLock()) {
1047N/A return state;
0N/A }
1047N/A }
1047N/A
1047N/A static {
1047N/A AWTAccessor.setFrameAccessor(
1047N/A new AWTAccessor.FrameAccessor() {
1047N/A public void setExtendedState(Frame frame, int state) {
1047N/A synchronized(frame.getObjectLock()) {
1047N/A frame.state = state;
1047N/A }
1047N/A }
1047N/A public int getExtendedState(Frame frame) {
1047N/A synchronized(frame.getObjectLock()) {
1047N/A return frame.state;
1047N/A }
1047N/A }
3073N/A public Rectangle getMaximizedBounds(Frame frame) {
3073N/A synchronized(frame.getObjectLock()) {
3073N/A return frame.maximizedBounds;
3073N/A }
3073N/A }
1047N/A }
1047N/A );
0N/A }
0N/A
0N/A /**
0N/A * Sets the maximized bounds for this frame.
0N/A * <p>
0N/A * When a frame is in maximized state the system supplies some
0N/A * defaults bounds. This method allows some or all of those
0N/A * system supplied values to be overridden.
0N/A * <p>
0N/A * If <code>bounds</code> is <code>null</code>, accept bounds
0N/A * supplied by the system. If non-<code>null</code> you can
0N/A * override some of the system supplied values while accepting
0N/A * others by setting those fields you want to accept from system
0N/A * to <code>Integer.MAX_VALUE</code>.
0N/A * <p>
1889N/A * Note, the given maximized bounds are used as a hint for the native
1889N/A * system, because the underlying platform may not support setting the
1889N/A * location and/or size of the maximized windows. If that is the case, the
1889N/A * provided values do not affect the appearance of the frame in the
1889N/A * maximized state.
0N/A *
0N/A * @param bounds bounds for the maximized state
0N/A * @see #getMaximizedBounds()
0N/A * @since 1.4
0N/A */
3073N/A public void setMaximizedBounds(Rectangle bounds) {
3073N/A synchronized(getObjectLock()) {
3073N/A this.maximizedBounds = bounds;
3073N/A }
0N/A FramePeer peer = (FramePeer)this.peer;
0N/A if (peer != null) {
0N/A peer.setMaximizedBounds(bounds);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Gets maximized bounds for this frame.
0N/A * Some fields may contain <code>Integer.MAX_VALUE</code> to indicate
0N/A * that system supplied values for this field must be used.
0N/A *
0N/A * @return maximized bounds for this frame; may be <code>null</code>
0N/A * @see #setMaximizedBounds(Rectangle)
0N/A * @since 1.4
0N/A */
0N/A public Rectangle getMaximizedBounds() {
3073N/A synchronized(getObjectLock()) {
3073N/A return maximizedBounds;
3073N/A }
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Disables or enables decorations for this frame.
3070N/A * <p>
3070N/A * This method can only be called while the frame is not displayable. To
3070N/A * make this frame decorated, it must be opaque and have the default shape,
3070N/A * otherwise the {@code IllegalComponentStateException} will be thrown.
3070N/A * Refer to {@link Window#setShape}, {@link Window#setOpacity} and {@link
3070N/A * Window#setBackground} for details
3070N/A *
3070N/A * @param undecorated {@code true} if no frame decorations are to be
3070N/A * enabled; {@code false} if frame decorations are to be enabled
3070N/A *
3070N/A * @throws IllegalComponentStateException if the frame is displayable
3070N/A * @throws IllegalComponentStateException if {@code undecorated} is
3070N/A * {@code false}, and this frame does not have the default shape
3070N/A * @throws IllegalComponentStateException if {@code undecorated} is
3070N/A * {@code false}, and this frame opacity is less than {@code 1.0f}
3070N/A * @throws IllegalComponentStateException if {@code undecorated} is
3070N/A * {@code false}, and the alpha value of this frame background
3070N/A * color is less than {@code 1.0f}
3070N/A *
0N/A * @see #isUndecorated
0N/A * @see Component#isDisplayable
3070N/A * @see Window#getShape
3070N/A * @see Window#getOpacity
3070N/A * @see Window#getBackground
0N/A * @see javax.swing.JFrame#setDefaultLookAndFeelDecorated(boolean)
3070N/A *
0N/A * @since 1.4
0N/A */
0N/A public void setUndecorated(boolean undecorated) {
0N/A /* Make sure we don't run in the middle of peer creation.*/
0N/A synchronized (getTreeLock()) {
0N/A if (isDisplayable()) {
0N/A throw new IllegalComponentStateException("The frame is displayable.");
0N/A }
3070N/A if (!undecorated) {
3070N/A if (getOpacity() < 1.0f) {
3070N/A throw new IllegalComponentStateException("The frame is not opaque");
3070N/A }
3070N/A if (getShape() != null) {
3070N/A throw new IllegalComponentStateException("The frame does not have a default shape");
3070N/A }
3070N/A Color bg = getBackground();
3070N/A if ((bg != null) && (bg.getAlpha() < 255)) {
3070N/A throw new IllegalComponentStateException("The frame background color is not opaque");
3070N/A }
3070N/A }
0N/A this.undecorated = undecorated;
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Indicates whether this frame is undecorated.
0N/A * By default, all frames are initially decorated.
0N/A * @return <code>true</code> if frame is undecorated;
0N/A * <code>false</code> otherwise.
0N/A * @see java.awt.Frame#setUndecorated(boolean)
0N/A * @since 1.4
0N/A */
0N/A public boolean isUndecorated() {
0N/A return undecorated;
0N/A }
0N/A
0N/A /**
3070N/A * {@inheritDoc}
3070N/A */
3070N/A @Override
3070N/A public void setOpacity(float opacity) {
3070N/A synchronized (getTreeLock()) {
3070N/A if ((opacity < 1.0f) && !isUndecorated()) {
3070N/A throw new IllegalComponentStateException("The frame is decorated");
3070N/A }
3070N/A super.setOpacity(opacity);
3070N/A }
3070N/A }
3070N/A
3070N/A /**
3070N/A * {@inheritDoc}
3070N/A */
3070N/A @Override
3070N/A public void setShape(Shape shape) {
3070N/A synchronized (getTreeLock()) {
3070N/A if ((shape != null) && !isUndecorated()) {
3070N/A throw new IllegalComponentStateException("The frame is decorated");
3070N/A }
3070N/A super.setShape(shape);
3070N/A }
3070N/A }
3070N/A
3070N/A /**
3070N/A * {@inheritDoc}
3070N/A */
3070N/A @Override
3070N/A public void setBackground(Color bgColor) {
3070N/A synchronized (getTreeLock()) {
3070N/A if ((bgColor != null) && (bgColor.getAlpha() < 255) && !isUndecorated()) {
3070N/A throw new IllegalComponentStateException("The frame is decorated");
3070N/A }
3070N/A super.setBackground(bgColor);
3070N/A }
3070N/A }
3070N/A
3070N/A /**
0N/A * Removes the specified menu bar from this frame.
0N/A * @param m the menu component to remove.
0N/A * If <code>m</code> is <code>null</code>, then
0N/A * no action is taken
0N/A */
0N/A public void remove(MenuComponent m) {
0N/A if (m == null) {
0N/A return;
0N/A }
0N/A synchronized (getTreeLock()) {
0N/A if (m == menuBar) {
0N/A menuBar = null;
0N/A FramePeer peer = (FramePeer)this.peer;
0N/A if (peer != null) {
0N/A mbManagement = true;
555N/A invalidateIfValid();
0N/A peer.setMenuBar(null);
0N/A m.removeNotify();
0N/A }
0N/A m.parent = null;
0N/A } else {
0N/A super.remove(m);
0N/A }
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Makes this Frame undisplayable by removing its connection
0N/A * to its native screen resource. Making a Frame undisplayable
0N/A * will cause any of its children to be made undisplayable.
0N/A * This method is called by the toolkit internally and should
0N/A * not be called directly by programs.
0N/A * @see Component#isDisplayable
0N/A * @see #addNotify
0N/A */
0N/A public void removeNotify() {
0N/A synchronized (getTreeLock()) {
0N/A FramePeer peer = (FramePeer)this.peer;
0N/A if (peer != null) {
0N/A // get the latest Frame state before disposing
0N/A getState();
0N/A
0N/A if (menuBar != null) {
0N/A mbManagement = true;
0N/A peer.setMenuBar(null);
0N/A menuBar.removeNotify();
0N/A }
0N/A }
0N/A super.removeNotify();
0N/A }
0N/A }
0N/A
0N/A void postProcessKeyEvent(KeyEvent e) {
0N/A if (menuBar != null && menuBar.handleShortcut(e)) {
0N/A e.consume();
0N/A return;
0N/A }
0N/A super.postProcessKeyEvent(e);
0N/A }
0N/A
0N/A /**
0N/A * Returns a string representing the state of this <code>Frame</code>.
0N/A * This method is intended to be used only for debugging purposes, and the
0N/A * content and format of the returned string may vary between
0N/A * implementations. The returned string may be empty but may not be
0N/A * <code>null</code>.
0N/A *
0N/A * @return the parameter string of this frame
0N/A */
0N/A protected String paramString() {
0N/A String str = super.paramString();
0N/A if (title != null) {
0N/A str += ",title=" + title;
0N/A }
0N/A if (resizable) {
0N/A str += ",resizable";
0N/A }
1047N/A int state = getExtendedState();
0N/A if (state == NORMAL) {
0N/A str += ",normal";
0N/A }
0N/A else {
0N/A if ((state & ICONIFIED) != 0) {
0N/A str += ",iconified";
0N/A }
0N/A if ((state & MAXIMIZED_BOTH) == MAXIMIZED_BOTH) {
0N/A str += ",maximized";
0N/A }
0N/A else if ((state & MAXIMIZED_HORIZ) != 0) {
0N/A str += ",maximized_horiz";
0N/A }
0N/A else if ((state & MAXIMIZED_VERT) != 0) {
0N/A str += ",maximized_vert";
0N/A }
0N/A }
0N/A return str;
0N/A }
0N/A
0N/A /**
0N/A * @deprecated As of JDK version 1.1,
0N/A * replaced by <code>Component.setCursor(Cursor)</code>.
0N/A */
0N/A @Deprecated
0N/A public void setCursor(int cursorType) {
0N/A if (cursorType < DEFAULT_CURSOR || cursorType > MOVE_CURSOR) {
0N/A throw new IllegalArgumentException("illegal cursor type");
0N/A }
0N/A setCursor(Cursor.getPredefinedCursor(cursorType));
0N/A }
0N/A
0N/A /**
0N/A * @deprecated As of JDK version 1.1,
0N/A * replaced by <code>Component.getCursor()</code>.
0N/A */
0N/A @Deprecated
0N/A public int getCursorType() {
0N/A return (getCursor().getType());
0N/A }
0N/A
0N/A /**
0N/A * Returns an array of all {@code Frame}s created by this application.
0N/A * If called from an applet, the array includes only the {@code Frame}s
0N/A * accessible by that applet.
0N/A * <p>
0N/A * <b>Warning:</b> this method may return system created frames, such
0N/A * as a shared, hidden frame which is used by Swing. Applications
0N/A * should not assume the existence of these frames, nor should an
0N/A * application assume anything about these frames such as component
0N/A * positions, <code>LayoutManager</code>s or serialization.
0N/A * <p>
0N/A * <b>Note</b>: To obtain a list of all ownerless windows, including
0N/A * ownerless {@code Dialog}s (introduced in release 1.6), use {@link
0N/A * Window#getOwnerlessWindows Window.getOwnerlessWindows}.
0N/A *
0N/A * @see Window#getWindows()
0N/A * @see Window#getOwnerlessWindows
0N/A *
0N/A * @since 1.2
0N/A */
0N/A public static Frame[] getFrames() {
0N/A Window[] allWindows = Window.getWindows();
0N/A
0N/A int frameCount = 0;
0N/A for (Window w : allWindows) {
0N/A if (w instanceof Frame) {
0N/A frameCount++;
0N/A }
0N/A }
0N/A
0N/A Frame[] frames = new Frame[frameCount];
0N/A int c = 0;
0N/A for (Window w : allWindows) {
0N/A if (w instanceof Frame) {
0N/A frames[c++] = (Frame)w;
0N/A }
0N/A }
0N/A
0N/A return frames;
0N/A }
0N/A
0N/A /* Serialization support. If there's a MenuBar we restore
0N/A * its (transient) parent field here. Likewise for top level
0N/A * windows that are "owned" by this frame.
0N/A */
0N/A
0N/A /**
0N/A * <code>Frame</code>'s Serialized Data Version.
0N/A *
0N/A * @serial
0N/A */
0N/A private int frameSerializedDataVersion = 1;
0N/A
0N/A /**
0N/A * Writes default serializable fields to stream. Writes
0N/A * an optional serializable icon <code>Image</code>, which is
0N/A * available as of 1.4.
0N/A *
0N/A * @param s the <code>ObjectOutputStream</code> to write
0N/A * @serialData an optional icon <code>Image</code>
0N/A * @see java.awt.Image
0N/A * @see #getIconImage
0N/A * @see #setIconImage(Image)
0N/A * @see #readObject(ObjectInputStream)
0N/A */
0N/A private void writeObject(ObjectOutputStream s)
0N/A throws IOException
0N/A {
0N/A s.defaultWriteObject();
0N/A if (icons != null && icons.size() > 0) {
0N/A Image icon1 = icons.get(0);
0N/A if (icon1 instanceof Serializable) {
0N/A s.writeObject(icon1);
0N/A return;
0N/A }
0N/A }
0N/A s.writeObject(null);
0N/A }
0N/A
0N/A /**
0N/A * Reads the <code>ObjectInputStream</code>. Tries
0N/A * to read an icon <code>Image</code>, which is optional
0N/A * data available as of 1.4. If an icon <code>Image</code>
0N/A * is not available, but anything other than an EOF
0N/A * is detected, an <code>OptionalDataException</code>
0N/A * will be thrown.
0N/A * Unrecognized keys or values will be ignored.
0N/A *
0N/A * @param s the <code>ObjectInputStream</code> to read
0N/A * @exception java.io.OptionalDataException if an icon <code>Image</code>
0N/A * is not available, but anything other than an EOF
0N/A * is detected
0N/A * @exception HeadlessException if
0N/A * <code>GraphicsEnvironment.isHeadless</code> returns
0N/A * <code>true</code>
0N/A * @see java.awt.GraphicsEnvironment#isHeadless()
0N/A * @see java.awt.Image
0N/A * @see #getIconImage
0N/A * @see #setIconImage(Image)
0N/A * @see #writeObject(ObjectOutputStream)
0N/A */
0N/A private void readObject(ObjectInputStream s)
0N/A throws ClassNotFoundException, IOException, HeadlessException
0N/A {
0N/A // HeadlessException is thrown by Window's readObject
0N/A s.defaultReadObject();
0N/A try {
0N/A Image icon = (Image) s.readObject();
0N/A if (icons == null) {
0N/A icons = new ArrayList<Image>();
0N/A icons.add(icon);
0N/A }
0N/A } catch (java.io.OptionalDataException e) {
0N/A // pre-1.4 instances will not have this optional data.
0N/A // 1.6 and later instances serialize icons in the Window class
0N/A // e.eof will be true to indicate that there is no more
0N/A // data available for this object.
0N/A
0N/A // If e.eof is not true, throw the exception as it
0N/A // might have been caused by unrelated reasons.
0N/A if (!e.eof) {
0N/A throw (e);
0N/A }
0N/A }
0N/A
0N/A if (menuBar != null)
0N/A menuBar.parent = this;
0N/A
0N/A // Ensure 1.1 serialized Frames can read & hook-up
0N/A // owned windows properly
0N/A //
0N/A if (ownedWindows != null) {
0N/A for (int i = 0; i < ownedWindows.size(); i++) {
0N/A connectOwnedWindow((Window) ownedWindows.elementAt(i));
0N/A }
0N/A ownedWindows = null;
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Initialize JNI field and method IDs
0N/A */
0N/A private static native void initIDs();
0N/A
0N/A /*
0N/A * --- Accessibility Support ---
0N/A *
0N/A */
0N/A
0N/A /**
0N/A * Gets the AccessibleContext associated with this Frame.
0N/A * For frames, the AccessibleContext takes the form of an
0N/A * AccessibleAWTFrame.
0N/A * A new AccessibleAWTFrame instance is created if necessary.
0N/A *
0N/A * @return an AccessibleAWTFrame that serves as the
0N/A * AccessibleContext of this Frame
0N/A * @since 1.3
0N/A */
0N/A public AccessibleContext getAccessibleContext() {
0N/A if (accessibleContext == null) {
0N/A accessibleContext = new AccessibleAWTFrame();
0N/A }
0N/A return accessibleContext;
0N/A }
0N/A
0N/A /**
0N/A * This class implements accessibility support for the
0N/A * <code>Frame</code> class. It provides an implementation of the
0N/A * Java Accessibility API appropriate to frame user-interface elements.
0N/A * @since 1.3
0N/A */
0N/A protected class AccessibleAWTFrame extends AccessibleAWTWindow
0N/A {
0N/A /*
0N/A * JDK 1.3 serialVersionUID
0N/A */
0N/A private static final long serialVersionUID = -6172960752956030250L;
0N/A
0N/A /**
0N/A * Get the role of this object.
0N/A *
0N/A * @return an instance of AccessibleRole describing the role of the
0N/A * object
0N/A * @see AccessibleRole
0N/A */
0N/A public AccessibleRole getAccessibleRole() {
0N/A return AccessibleRole.FRAME;
0N/A }
0N/A
0N/A /**
0N/A * Get the state of this object.
0N/A *
0N/A * @return an instance of AccessibleStateSet containing the current
0N/A * state set of the object
0N/A * @see AccessibleState
0N/A */
0N/A public AccessibleStateSet getAccessibleStateSet() {
0N/A AccessibleStateSet states = super.getAccessibleStateSet();
0N/A if (getFocusOwner() != null) {
0N/A states.add(AccessibleState.ACTIVE);
0N/A }
0N/A if (isResizable()) {
0N/A states.add(AccessibleState.RESIZABLE);
0N/A }
0N/A return states;
0N/A }
0N/A
0N/A
0N/A } // inner class AccessibleAWTFrame
0N/A
0N/A}