java.awt
Class Frame

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
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 N_RESIZE_CURSOR
          Deprecated. Use Cursor.N_RESIZE_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 S_RESIZE_CURSOR
          Deprecated. Use Cursor.S_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 TEXT_CURSOR
          Deprecated. Use Cursor.TEXT_CURSOR instead.
static int W_RESIZE_CURSOR
          Deprecated. Use Cursor.W_RESIZE_CURSOR instead.
static int WAIT_CURSOR
          Deprecated. Use Cursor.WAIT_CURSOR.
 
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()
          Creates the native peer for this window.
 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 when this container is removed from its parent container to inform it to destroy its peer.
 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
addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getGraphicsConfiguration, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, 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, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

DEFAULT_CURSOR

public static final int DEFAULT_CURSOR
Deprecated. Replaced by Cursor.DEFAULT_CURSOR instead.
Constant for the default cursor.

See Also:
Constant Field Values

CROSSHAIR_CURSOR

public static final int CROSSHAIR_CURSOR
Deprecated. Use Cursor.CROSSHAIR_CURSOR instead.
Constant for a cross-hair cursor.

See Also:
Constant Field Values

TEXT_CURSOR

public static final int TEXT_CURSOR
Deprecated. Use Cursor.TEXT_CURSOR instead.
Constant for a cursor over a text field.

See Also:
Constant Field Values

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.

See Also:
Constant Field Values

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.

See Also:
Constant Field Values

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.

See Also:
Constant Field Values

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.

See Also:
Constant Field Values

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.

See Also:
Constant Field Values

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.

See Also:
Constant Field Values

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.

See Also:
Constant Field Values

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.

See Also:
Constant Field Values

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.

See Also:
Constant Field Values

HAND_CURSOR

public static final int HAND_CURSOR
Deprecated. Use Cursor.HAND_CURSOR instead.
Constant for a hand cursor.

See Also:
Constant Field Values

MOVE_CURSOR

public static final int MOVE_CURSOR
Deprecated. Use Cursor.MOVE_CURSOR instead.
Constant for a cursor used during window move operations.

See Also:
Constant Field Values

ICONIFIED

public static final int ICONIFIED
See Also:
Constant Field Values

MAXIMIZED_BOTH

public static final int MAXIMIZED_BOTH
See Also:
Constant Field Values

MAXIMIZED_HORIZ

public static final int MAXIMIZED_HORIZ
See Also:
Constant Field Values

MAXIMIZED_VERT

public static final int MAXIMIZED_VERT
See Also:
Constant Field Values

NORMAL

public static final int NORMAL
See Also:
Constant Field Values
Constructor Detail

Frame

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


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(GraphicsConfiguration gc)

Frame

public Frame(String title,
             GraphicsConfiguration gc)
Method Detail

getTitle

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

Returns:
this frame's title string

setTitle

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

Parameters:
title - the new frame title

getIconImage

public Image getIconImage()
Returns this frame's icon.

Returns:
this frame's icon, or null if this frame does not have an icon

setIconImage

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


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

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

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

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

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

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

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 class Component
Parameters:
menu - the menu component to remove
See Also:
Component.add(PopupMenu)

addNotify

public void addNotify()
Description copied from class: Window
Creates the native peer for this window.

Overrides:
addNotify in class Window
See Also:
Component.isDisplayable(), Component.removeNotify()

removeNotify

public void removeNotify()
Description copied from class: Container
Called when this container is removed from its parent container to inform it to destroy its peer. This causes the peers of all child component to be destroyed as well.

Overrides:
removeNotify in class Container
See Also:
Component.isDisplayable(), Component.addNotify()

paramString

protected String paramString()
Returns a debugging string describing this window.

Overrides:
paramString in class Container
Returns:
a debugging string describing this window

getFrames

public static Frame[] getFrames()

setState

public void setState(int state)

getState

public int getState()

setExtendedState

public void setExtendedState(int state)
Since:
1.4

getExtendedState

public int getExtendedState()
Since:
1.4

setMaximizedBounds

public void setMaximizedBounds(Rectangle maximizedBounds)
Since:
1.4

getMaximizedBounds

public Rectangle getMaximizedBounds()
Returns the maximized bounds of this frame.

Returns:
the maximized rectangle, may be null
Since:
1.4

isUndecorated

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

Since:
1.4

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

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 class Window
Returns:
the associated context