java.awt

Class Frame

Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable
Known Direct Subclasses:
EmbeddedWindow, JFrame

public class Frame
extends Window
implements MenuContainer

This class is a top-level window with a title bar and window decorations.
See Also:
Serialized Form

Nested Class Summary

protected class
Frame.AccessibleAWTFrame
Accessibility support for Frame.

Nested classes/interfaces inherited from class java.awt.Window

Window.AccessibleAWTWindow

Nested classes/interfaces inherited from class java.awt.Container

Container.AccessibleAWTContainer

Nested classes/interfaces inherited from class java.awt.Component

Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy

Field Summary

static int
CROSSHAIR_CURSOR
Deprecated. Use Cursor.CROSSHAIR_CURSOR instead.
static int
DEFAULT_CURSOR
Deprecated. Replaced by Cursor.DEFAULT_CURSOR instead.
static int
E_RESIZE_CURSOR
Deprecated. Use Cursor.E_RESIZE_CURSOR instead.
static int
HAND_CURSOR
Deprecated. Use Cursor.HAND_CURSOR instead.
static int
ICONIFIED
static int
MAXIMIZED_BOTH
static int
MAXIMIZED_HORIZ
static int
MAXIMIZED_VERT
static int
MOVE_CURSOR
Deprecated. Use Cursor.MOVE_CURSOR instead.
static int
NE_RESIZE_CURSOR
Deprecated. Use Cursor.NE_RESIZE_CURSOR instead.
static int
NORMAL
static int
NW_RESIZE_CURSOR
Deprecated. Use Cursor.NW_RESIZE_CURSOR instead.
static int
N_RESIZE_CURSOR
Deprecated. Use Cursor.N_RESIZE_CURSOR instead.
static int
SE_RESIZE_CURSOR
Deprecated. Use Cursor.SE_RESIZE_CURSOR instead.
static int
SW_RESIZE_CURSOR
Deprecated. Use Cursor.SW_RESIZE_CURSOR instead.
static int
S_RESIZE_CURSOR
Deprecated. Use Cursor.S_RESIZE_CURSOR instead.
static int
TEXT_CURSOR
Deprecated. Use Cursor.TEXT_CURSOR instead.
static int
WAIT_CURSOR
Deprecated. Use Cursor.WAIT_CURSOR.
static int
W_RESIZE_CURSOR
Deprecated. Use Cursor.W_RESIZE_CURSOR instead.

Fields inherited from class java.awt.Component

BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT

Fields inherited from interface java.awt.image.ImageObserver

ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH

Constructor Summary

Frame()
Initializes a new instance of Frame that is not visible and has no title.
Frame(GraphicsConfiguration gc)
Frame(String title)
Initializes a new instance of Frame that is not visible and has the specified title.
Frame(String title, GraphicsConfiguration gc)

Method Summary

void
addNotify()
Called when the parent of this Component is made visible or when the Component is added to an already visible Container and needs to be shown.
AccessibleContext
getAccessibleContext()
Gets the AccessibleContext associated with this Frame.
int
getCursorType()
Deprecated. Use Component.getCursor() instead.
int
getExtendedState()
static Frame[]
getFrames()
Image
getIconImage()
Returns this frame's icon.
Rectangle
getMaximizedBounds()
Returns the maximized bounds of this frame.
MenuBar
getMenuBar()
Returns this frame's menu bar.
int
getState()
String
getTitle()
Returns this frame's title string.
boolean
isResizable()
Tests whether or not this frame is resizable.
boolean
isUndecorated()
Returns whether this frame is undecorated or not.
protected String
paramString()
Returns a debugging string describing this window.
void
remove(MenuComponent menu)
Removes the specified menu component from this frame.
void
removeNotify()
Called to inform this component is has been removed from its container.
void
setCursor(int type)
Deprecated. Use Component.setCursor(Cursor) instead.
void
setExtendedState(int state)
void
setIconImage(Image icon)
Sets this frame's icon to the specified value.
void
setMaximizedBounds(Rectangle maximizedBounds)
void
setMenuBar(MenuBar menuBar)
Sets this frame's menu bar.
void
setResizable(boolean resizable)
Sets the resizability of this frame to the specified value.
void
setState(int state)
void
setTitle(String title)
Sets this frame's title to the specified value.
void
setUndecorated(boolean undecorated)
Disables or enables decorations for this frame.

Methods inherited from class java.awt.Window

addNotify, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, extends EventListener> T[] getListeners, getAccessibleContext, getBufferStrategy, getFocusCycleRootAncestor, getFocusOwner, getFocusableWindowState, getGraphicsConfiguration, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isAlwaysOnTop, isFocusCycleRoot, isFocusableWindow, isFocused, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setCursor, setFocusCycleRoot, setFocusableWindowState, setLocationRelativeTo, toBack, toFront, void hide, void show

Methods inherited from class java.awt.Container

add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, extends EventListener> T[] getListeners, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponentZOrder, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree

Methods inherited from class java.awt.Component

action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, extends EventListener> T[] getListeners, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFocusable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFocusable, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

CROSSHAIR_CURSOR

public static final int CROSSHAIR_CURSOR

Deprecated. Use Cursor.CROSSHAIR_CURSOR instead.

Constant for a cross-hair cursor.
Field Value:
1

DEFAULT_CURSOR

public static final int DEFAULT_CURSOR

Deprecated. Replaced by Cursor.DEFAULT_CURSOR instead.

Constant for the default cursor.
Field Value:
0

E_RESIZE_CURSOR

public static final int E_RESIZE_CURSOR

Deprecated. Use Cursor.E_RESIZE_CURSOR instead.

Cursor used over E edge of window decorations.
Field Value:
11

HAND_CURSOR

public static final int HAND_CURSOR

Deprecated. Use Cursor.HAND_CURSOR instead.

Constant for a hand cursor.
Field Value:
12

ICONIFIED

public static final int ICONIFIED
Field Value:
1

MAXIMIZED_BOTH

public static final int MAXIMIZED_BOTH
Field Value:
6

MAXIMIZED_HORIZ

public static final int MAXIMIZED_HORIZ
Field Value:
2

MAXIMIZED_VERT

public static final int MAXIMIZED_VERT
Field Value:
4

MOVE_CURSOR

public static final int MOVE_CURSOR

Deprecated. Use Cursor.MOVE_CURSOR instead.

Constant for a cursor used during window move operations.
Field Value:
13

NE_RESIZE_CURSOR

public static final int NE_RESIZE_CURSOR

Deprecated. Use Cursor.NE_RESIZE_CURSOR instead.

Cursor used over NE corner of window decorations.
Field Value:
7

NORMAL

public static final int NORMAL
Field Value:
0

NW_RESIZE_CURSOR

public static final int NW_RESIZE_CURSOR

Deprecated. Use Cursor.NW_RESIZE_CURSOR instead.

Cursor used over NW corner of window decorations.
Field Value:
6

N_RESIZE_CURSOR

public static final int N_RESIZE_CURSOR

Deprecated. Use Cursor.N_RESIZE_CURSOR instead.

Cursor used over N edge of window decorations.
Field Value:
8

SE_RESIZE_CURSOR

public static final int SE_RESIZE_CURSOR

Deprecated. Use Cursor.SE_RESIZE_CURSOR instead.

Cursor used over SE corner of window decorations.
Field Value:
5

SW_RESIZE_CURSOR

public static final int SW_RESIZE_CURSOR

Deprecated. Use Cursor.SW_RESIZE_CURSOR instead.

Cursor used over SW corner of window decorations.
Field Value:
4

S_RESIZE_CURSOR

public static final int S_RESIZE_CURSOR

Deprecated. Use Cursor.S_RESIZE_CURSOR instead.

Cursor used over S edge of window decorations.
Field Value:
9

TEXT_CURSOR

public static final int TEXT_CURSOR

Deprecated. Use Cursor.TEXT_CURSOR instead.

Constant for a cursor over a text field.
Field Value:
2

WAIT_CURSOR

public static final int WAIT_CURSOR

Deprecated. Use Cursor.WAIT_CURSOR.

Constant for a cursor to display while waiting for an action to complete.
Field Value:
3

W_RESIZE_CURSOR

public static final int W_RESIZE_CURSOR

Deprecated. Use Cursor.W_RESIZE_CURSOR instead.

Cursor used over W edge of window decorations.
Field Value:
10

Constructor Details

Frame

public Frame()
Initializes a new instance of Frame that is not visible and has no title.

Frame

public Frame(GraphicsConfiguration gc)

Frame

public Frame(String title)
Initializes a new instance of Frame that is not visible and has the specified title.
Parameters:
title - the title of this frame

Frame

public Frame(String title,
             GraphicsConfiguration gc)

Method Details

addNotify

public void addNotify()
Called when the parent of this Component is made visible or when the Component is added to an already visible Container and needs to be shown. A native peer - if any - is created at this time. This method is called automatically by the AWT system and should not be called by user level code.
Overrides:
addNotify in interface Window

getAccessibleContext

public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this Frame. The context is created, if necessary.
Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in interface Window
Returns:
the associated context

getCursorType

public int getCursorType()

Deprecated. Use Component.getCursor() instead.

Returns the cursor type of the cursor for this window. This will be one of the constants in this class.
Returns:
the cursor type for this frame

getExtendedState

public int getExtendedState()
Since:
1.4

getFrames

public static Frame[] getFrames()

getIconImage

public Image getIconImage()
Returns this frame's icon.
Returns:
this frame's icon, or null if this frame does not have an icon

getMaximizedBounds

public Rectangle getMaximizedBounds()
Returns the maximized bounds of this frame.
Returns:
the maximized rectangle, may be null
Since:
1.4

getMenuBar

public MenuBar getMenuBar()
Returns this frame's menu bar.
Returns:
this frame's menu bar, or null if this frame does not have a menu bar

getState

public int getState()

getTitle

public String getTitle()
Returns this frame's title string.
Returns:
this frame's title string

isResizable

public boolean isResizable()
Tests whether or not this frame is resizable. This will be true by default.
Returns:
true if this frame is resizable, false otherwise

isUndecorated

public boolean isUndecorated()
Returns whether this frame is undecorated or not.
Since:
1.4

paramString

protected String paramString()
Returns a debugging string describing this window.
Overrides:
paramString in interface Container
Returns:
a debugging string describing this window

remove

public void remove(MenuComponent menu)
Removes the specified menu component from this frame. If it is the current MenuBar it is removed from the frame. If it is a Popup it is removed from this component. If it is any other menu component it is ignored.
Specified by:
remove in interface MenuContainer
Overrides:
remove in interface Component
Parameters:
menu - the menu component to remove

removeNotify

public void removeNotify()
Called to inform this component is has been removed from its container. Its native peer - if any - is destroyed at this time. This method is called automatically by the AWT system and should not be called by user level code.
Overrides:
removeNotify in interface Container

setCursor

public void setCursor(int type)

Deprecated. Use Component.setCursor(Cursor) instead.

Sets the cursor for this window to the specified type. The specified type should be one of the constants in this class.
Parameters:
type - the cursor type

setExtendedState

public void setExtendedState(int state)
Since:
1.4

setIconImage

public void setIconImage(Image icon)
Sets this frame's icon to the specified value.

setMaximizedBounds

public void setMaximizedBounds(Rectangle maximizedBounds)
Since:
1.4

setMenuBar

public void setMenuBar(MenuBar menuBar)
Sets this frame's menu bar. Removes any existing menu bar. If the given menu bar is part of another frame it will be removed from that frame.
Parameters:
menuBar - the new menu bar for this frame

setResizable

public void setResizable(boolean resizable)
Sets the resizability of this frame to the specified value.
Parameters:
resizable - true to make the frame resizable, false to make it non-resizable

setState

public void setState(int state)

setTitle

public void setTitle(String title)
Sets this frame's title to the specified value.
Parameters:
title - the new frame title

setUndecorated

public void setUndecorated(boolean undecorated)
Disables or enables decorations for this frame. This method can only be called while the frame is not displayable.
Throws:
IllegalComponentStateException - if this frame is displayable
Since:
1.4

Frame.java -- AWT toplevel window Copyright (C) 1999, 2000, 2002, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.