top of page

Questions and Answers

Public·29 members

Frame


  • The size of the frame includes any area designated for the border. The dimensions of the border area may be obtained using the getInsets method, however, since these dimensions are platform-dependent, a valid insets value cannot be obtained until the frame is made displayable by either calling pack or show. Since the border area is included in the overall size of the frame, the border effectively obscures a portion of the frame, constraining the area available for rendering and/or displaying subcomponents to the rectangle which has an upper-left corner location of (insets.left, insets.top), and has a size of width - (insets.left + insets.right) by height - (insets.top + insets.bottom). The default layout for a frame is BorderLayout. A frame may have its native decorations (i.e. Frame and Titlebar) turned off with setUndecorated. This can only be done while the frame is not displayable. In a multi-screen environment, you can create a Frame on a different screen device by constructing the Frame with Frame(GraphicsConfiguration) or Frame(String title, GraphicsConfiguration). The GraphicsConfiguration object is one of the GraphicsConfiguration objects of the target screen device. In a virtual device multi-screen environment in which the desktop area could span multiple physical screen devices, the bounds of all configurations are relative to the virtual-coordinate system. The origin of the virtual-coordinate system is at the upper left-hand corner of the primary physical screen. Depending on the location of the primary screen in the virtual device, negative coordinates are possible, as shown in the following figure. In such an environment, when calling setLocation, you must pass a virtual coordinate to this method. Similarly, calling getLocationOnScreen on a Frame returns virtual device coordinates. Call the getBounds method of a GraphicsConfiguration to find its origin in the virtual coordinate system. The following code sets the location of the Frame at (10, 10) relative to the origin of the physical screen of the corresponding GraphicsConfiguration. If the bounds of the GraphicsConfiguration is not taken into account, the Frame location would be set at (10, 10) relative to the virtual-coordinate system and would appear on the primary physical screen, which might be different from the physical screen of the specified GraphicsConfiguration. Frame f = new Frame(GraphicsConfiguration gc); Rectangle bounds = gc.getBounds(); f.setLocation(10 + bounds.x, 10 + bounds.y); Frames are capable of generating the following types of WindowEvents: WINDOW_OPENED WINDOW_CLOSING: If the program doesn't explicitly hide or dispose the window while processing this event, the window close operation is canceled. WINDOW_CLOSED WINDOW_ICONIFIED WINDOW_DEICONIFIED WINDOW_ACTIVATED WINDOW_DEACTIVATED WINDOW_GAINED_FOCUS WINDOW_LOST_FOCUS WINDOW_STATE_CHANGED Since:JDK1.0See Also:WindowEvent, Window.addWindowListener(java.awt.event.WindowListener), Serialized Form

Nested Class SummaryNested Classes Modifier and TypeClass and Descriptionprotected class Frame.AccessibleAWTFrameThis class implements accessibility support for the Frame class.Nested classes/interfaces inherited from class java.awt.WindowWindow.AccessibleAWTWindow, Window.TypeNested classes/interfaces inherited from class java.awt.ContainerContainer.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.ComponentComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategyField SummaryFields Modifier and TypeField and Descriptionstatic intCROSSHAIR_CURSORDeprecated. replaced by Cursor.CROSSHAIR_CURSOR.static intDEFAULT_CURSORDeprecated. replaced by Cursor.DEFAULT_CURSOR.static intE_RESIZE_CURSORDeprecated. replaced by Cursor.E_RESIZE_CURSOR.static intHAND_CURSORDeprecated. replaced by Cursor.HAND_CURSOR.static intICONIFIEDThis state bit indicates that frame is iconified.static intMAXIMIZED_BOTHThis state bit mask indicates that frame is fully maximized (that is both horizontally and vertically).static intMAXIMIZED_HORIZThis state bit indicates that frame is maximized in the horizontal direction.static intMAXIMIZED_VERTThis state bit indicates that frame is maximized in the vertical direction.static intMOVE_CURSORDeprecated. replaced by Cursor.MOVE_CURSOR.static intN_RESIZE_CURSORDeprecated. replaced by Cursor.N_RESIZE_CURSOR.static intNE_RESIZE_CURSORDeprecated. replaced by Cursor.NE_RESIZE_CURSOR.static intNORMALFrame is in the "normal" state.static intNW_RESIZE_CURSORDeprecated. replaced by Cursor.NW_RESIZE_CURSOR.static intS_RESIZE_CURSORDeprecated. replaced by Cursor.S_RESIZE_CURSOR.static intSE_RESIZE_CURSORDeprecated. replaced by Cursor.SE_RESIZE_CURSOR.static intSW_RESIZE_CURSORDeprecated. replaced by Cursor.SW_RESIZE_CURSOR.static intTEXT_CURSORDeprecated. replaced by Cursor.TEXT_CURSOR.static intW_RESIZE_CURSORDeprecated. replaced by Cursor.W_RESIZE_CURSOR.static intWAIT_CURSORDeprecated. replaced by Cursor.WAIT_CURSOR.Fields inherited from class java.awt.ComponentaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserverABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHConstructor SummaryConstructors Constructor and DescriptionFrame()Constructs a new instance of Frame that is initially invisible.Frame(GraphicsConfiguration gc)Constructs a new, initially invisible Frame with the specified GraphicsConfiguration.Frame(String title)Constructs a new, initially invisible Frame object with the specified title.Frame(String title, GraphicsConfiguration gc)Constructs a new, initially invisible Frame object with the specified title and a GraphicsConfiguration.Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and TypeMethod and DescriptionvoidaddNotify()Makes this Frame displayable by connecting it to a native screen resource.AccessibleContextgetAccessibleContext()Gets the AccessibleContext associated with this Frame.intgetCursorType()Deprecated. As of JDK version 1.1, replaced by Component.getCursor().intgetExtendedState()Gets the state of this frame.static Frame[]getFrames()Returns an array of all Frames created by this application.ImagegetIconImage()Returns the image to be displayed as the icon for this frame.RectanglegetMaximizedBounds()Gets maximized bounds for this frame.MenuBargetMenuBar()Gets the menu bar for this frame.intgetState()Gets the state of this frame (obsolete).StringgetTitle()Gets the title of the frame.booleanisResizable()Indicates whether this frame is resizable by the user.booleanisUndecorated()Indicates whether this frame is undecorated.protected StringparamString()Returns a string representing the state of this Frame.voidremove(MenuComponent m)Removes the specified menu bar from this frame.voidremoveNotify()Makes this Frame undisplayable by removing its connection to its native screen resource.voidsetBackground(Color bgColor)Sets the background color of this window.voidsetCursor(int cursorType)Deprecated. As of JDK version 1.1, replaced by Component.setCursor(Cursor).voidsetExtendedState(int state)Sets the state of this frame.voidsetIconImage(Image image)Sets the image to be displayed as the icon for this window.voidsetMaximizedBounds(Rectangle bounds)Sets the maximized bounds for this frame.voidsetMenuBar(MenuBar mb)Sets the menu bar for this frame to the specified menu bar.voidsetOpacity(float opacity)Sets the opacity of the window.voidsetResizable(boolean resizable)Sets whether this frame is resizable by the user.voidsetShape(Shape shape)Sets the shape of the window.voidsetState(int state)Sets the state of this frame (obsolete).voidsetTitle(String title)Sets the title for this frame to the specified string.voidsetUndecorated(boolean undecorated)Disables or enables decorations for this frame.Methods inherited from class java.awt.WindowaddPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFrontMethods inherited from class java.awt.Containeradd, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTreeMethods inherited from class java.awt.Componentaction, 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, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, 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, 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, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.awt.MenuContainergetFont, postEventField DetailDEFAULT_CURSOR@Deprecatedpublic static final int DEFAULT_CURSORDeprecated. replaced by Cursor.DEFAULT_CURSOR.See Also:Constant Field ValuesCROSSHAIR_CURSOR@Deprecatedpublic static final int CROSSHAIR_CURSORDeprecated. replaced by Cursor.CROSSHAIR_CURSOR.See Also:Constant Field ValuesTEXT_CURSOR@Deprecatedpublic static final int TEXT_CURSORDeprecated. replaced by Cursor.TEXT_CURSOR.See Also:Constant Field ValuesWAIT_CURSOR@Deprecatedpublic static final int WAIT_CURSORDeprecated. replaced by Cursor.WAIT_CURSOR.See Also:Constant Field ValuesSW_RESIZE_CURSOR@Deprecatedpublic static final int SW_RESIZE_CURSORDeprecated. replaced by Cursor.SW_RESIZE_CURSOR.See Also:Constant Field ValuesSE_RESIZE_CURSOR@Deprecatedpublic static final int SE_RESIZE_CURSORDeprecated. replaced by Cursor.SE_RESIZE_CURSOR.See Also:Constant Field ValuesNW_RESIZE_CURSOR@Deprecatedpublic static final int NW_RESIZE_CURSORDeprecated. replaced by Cursor.NW_RESIZE_CURSOR.See Also:Constant Field ValuesNE_RESIZE_CURSOR@Deprecatedpublic static final int NE_RESIZE_CURSORDeprecated. replaced by Cursor.NE_RESIZE_CURSOR.See Also:Constant Field ValuesN_RESIZE_CURSOR@Deprecatedpublic static final int N_RESIZE_CURSORDeprecated. replaced by Cursor.N_RESIZE_CURSOR.See Also:Constant Field ValuesS_RESIZE_CURSOR@Deprecatedpublic static final int S_RESIZE_CURSORDeprecated. replaced by Cursor.S_RESIZE_CURSOR.See Also:Constant Field ValuesW_RESIZE_CURSOR@Deprecatedpublic static final int W_RESIZE_CURSORDeprecated. replaced by Cursor.W_RESIZE_CURSOR.See Also:Constant Field ValuesE_RESIZE_CURSOR@Deprecatedpublic static final int E_RESIZE_CURSORDeprecated. replaced by Cursor.E_RESIZE_CURSOR.See Also:Constant Field ValuesHAND_CURSOR@Deprecatedpublic static final int HAND_CURSORDeprecated. replaced by Cursor.HAND_CURSOR.See Also:Constant Field ValuesMOVE_CURSOR@Deprecatedpublic static final int MOVE_CURSORDeprecated. replaced by Cursor.MOVE_CURSOR.See Also:Constant Field ValuesNORMALpublic static final int NORMALFrame is in the "normal" state. This symbolic constant names a frame state with all state bits cleared.See Also:setExtendedState(int), getExtendedState(), Constant Field ValuesICONIFIEDpublic static final int ICONIFIEDThis state bit indicates that frame is iconified.See Also:setExtendedState(int), getExtendedState(), Constant Field ValuesMAXIMIZED_HORIZpublic static final int MAXIMIZED_HORIZThis state bit indicates that frame is maximized in the horizontal direction.Since:1.4See Also:setExtendedState(int), getExtendedState(), Constant Field ValuesMAXIMIZED_VERTpublic static final int MAXIMIZED_VERTThis state bit indicates that frame is maximized in the vertical direction.Since:1.4See Also:setExtendedState(int), getExtendedState(), Constant Field ValuesMAXIMIZED_BOTHpublic 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 Since:1.4See Also:setExtendedState(int), getExtendedState(), Constant Field ValuesConstructor DetailFramepublic Frame() throws HeadlessExceptionConstructs a new instance of Frame that is initially invisible. The title of the Frame is empty.Throws:HeadlessException - when GraphicsEnvironment.isHeadless() returns trueSee Also:GraphicsEnvironment.isHeadless(), Component.setSize(int, int), Component.setVisible(boolean)Framepublic Frame(GraphicsConfiguration gc)Constructs a new, initially invisible Frame with the specified GraphicsConfiguration.Parameters:gc - the GraphicsConfiguration of the target screen device. If gc is null, the system default GraphicsConfiguration is assumed.Throws:IllegalArgumentException - if gc is not from a screen device.HeadlessException - when GraphicsEnvironment.isHeadless() returns trueSince:1.3See Also:GraphicsEnvironment.isHeadless()Framepublic Frame(String title) throws HeadlessExceptionConstructs a new, initially invisible Frame object with the specified title.Parameters:title - the title to be displayed in the frame's border. A null value is treated as an empty string, "".Throws:HeadlessException - when GraphicsEnvironment.isHeadless() returns trueSee Also:GraphicsEnvironment.isHeadless(), Component.setSize(int, int), Component.setVisible(boolean), GraphicsConfiguration.getBounds()Framepublic Frame(String title, GraphicsConfiguration gc)Constructs a new, initially invisible Frame object with the specified title and a GraphicsConfiguration.Parameters:title - the title to be displayed in the frame's border. A null value is treated as an empty string, "".gc - the GraphicsConfiguration of the target screen device. If gc is null, the system default GraphicsConfiguration is assumed.Throws:IllegalArgumentException - if gc is not from a screen device.HeadlessException - when GraphicsEnvironment.isHeadless() returns trueSince:1.3See Also:GraphicsEnvironment.isHeadless(), Component.setSize(int, int), Component.setVisible(boolean), GraphicsConfiguration.getBounds()Method DetailaddNotifypublic 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.Overrides:addNotify in class WindowSee Also:Component.isDisplayable(), removeNotify()getTitlepublic String getTitle()Gets the title of the frame. The title is displayed in the frame's border.Returns:the title of this frame, or an empty string ("") if this frame doesn't have a title.See Also:setTitle(String)setTitlepublic void setTitle(String title)Sets the title for this frame to the specified string.Parameters:title - the title to be displayed in the frame's border. A null value is treated as an empty string, "".See Also:getTitle()getIconImagepublic 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 Window.getIconImages() instead. If a list of several images was specified as a Window's icon, this me


About

Welcome to the group! You can connect with other members, ge...
bottom of page