APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing

public Class JInternalFrame

extends JComponent
implements Accessible, WindowConstants, RootPaneContainer
Class Inheritance
All Implemented Interfaces
javax.swing.RootPaneContainer, javax.swing.WindowConstants, javax.accessibility.Accessible
Annotations
@JavaBean
defaultProperty:JMenuBar
description:A frame container which is contained within another window.
@SwingContainer
delegate:getContentPane
@SuppressWarnings:serial
Imports
java.awt.BorderLayout, .Component, .Container, .Cursor, .Dimension, .FocusTraversalPolicy, .Graphics, .KeyboardFocusManager, .LayoutManager, .Rectangle, .Window, java.beans.BeanProperty, .JavaBean, .PropertyChangeEvent, .PropertyChangeListener, .PropertyVetoException, java.io.IOException, .ObjectOutputStream, .Serial, javax.accessibility.Accessible, .AccessibleContext, .AccessibleRole, .AccessibleValue, javax.swing.event.InternalFrameEvent, .InternalFrameListener, javax.swing.plaf.DesktopIconUI, .InternalFrameUI, sun.swing.SwingUtilities2

A lightweight object that provides many of the features of a native frame, including dragging, closing, becoming an icon, resizing, title display, and support for a menu bar. For task-oriented documentation and examples of using internal frames, see How to Use Internal Frames, a section in The Java Tutorial.

Generally, you add JInternalFrames to a JDesktopPane. The UI delegates the look-and-feel-specific actions to the DesktopManager object maintained by the JDesktopPane.

The JInternalFrame content pane is where you add child components. As a convenience, the add, remove, and setLayout methods of this class are overridden, so that they delegate calls to the corresponding methods of the ContentPane. For example, you can add a child component to an internal frame as follows:

      internalFrame.add(child);
And the child will be added to the contentPane. The content pane is actually managed by an instance of JRootPane, which also manages a layout pane, glass pane, and optional menu bar for the internal frame. Please see the JRootPane documentation for a complete description of these components. Refer to javax.swing.RootPaneContainer for details on adding, removing and setting the LayoutManager of a JInternalFrame.

Warning

Swing is not thread safe. For more information see Swing's Threading Policy.

Warning

Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Authors
David Kloba, Rich Schiavi
Since
1.2
See Also
InternalFrameEvent, JDesktopPane, DesktopManager, JInternalFrame.JDesktopIcon, JRootPane, javax.swing.RootPaneContainer

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
JInternalFrame.AccessibleJInternalFrame

This class implements accessibility support for the JInternalFrame class.

private static class
public static class
JInternalFrame.JDesktopIcon

This component represents an iconified version of a JInternalFrame.

Field Summary

Modifier and TypeField and Description
protected boolean
closable

The frame can be closed.

public static final String
CONTENT_PANE_PROPERTY

Bound property name.

pack-priv boolean
private int
protected JInternalFrame.JDesktopIcon
desktopIcon

The icon that is displayed when this internal frame is iconified.

private static PropertyChangeListener
public static final String
FRAME_ICON_PROPERTY

Bound property name.

protected Icon
frameIcon

The icon shown in the top-left corner of this internal frame.

public static final String
GLASS_PANE_PROPERTY

Bound property name.

protected boolean
iconable

The frame can "iconified" (shrunk down and displayed as an icon-image).

public static final String
IS_CLOSED_PROPERTY

Constrained property name indicating that the internal frame is closed.

public static final String
IS_ICON_PROPERTY

Constrained property name indicating that the internal frame is iconified.

public static final String
IS_MAXIMUM_PROPERTY

Constrained property name indicating that the internal frame is maximized.

public static final String
IS_SELECTED_PROPERTY

Constrained property name indicated that this frame has selected status.

protected boolean
isClosed

The frame has been closed.

pack-priv boolean
protected boolean
isIcon

The frame has been iconified.

protected boolean
isMaximum

The frame has been expanded to its maximum size.

protected boolean
isSelected

The frame is currently selected.

private Cursor
private Component
lastFocusOwner

Contains the Component that focus is to go when restoreSubcomponentFocus is invoked, that is, restoreSubcomponentFocus sets this to the value returned from getMostRecentFocusOwner.

public static final String
LAYERED_PANE_PROPERTY

Bound property name.

protected boolean
maximizable

The frame can be expanded to the size of the desktop pane.

private Rectangle
private boolean
protected boolean
resizable

The frame's size can be changed.

public static final String
ROOT_PANE_PROPERTY

Bound property name.

protected JRootPane
rootPane

The JRootPane instance that manages the content pane and optional menu bar for this internal frame, as well as the glass pane.

protected boolean
rootPaneCheckingEnabled

If true then calls to add and setLayout will be forwarded to the contentPane.

protected String
title

The title displayed in this internal frame's title bar.

public static final String
TITLE_PROPERTY

Bound property name.

private static final String
Inherited from javax.swing.JComponent:
DEBUG_GRAPHICS_LOADEDfocusControllerivSourceComponentlistenerListpaintingChildTOOL_TIP_TEXT_KEYuiUNDEFINED_CONDITIONWHEN_ANCESTOR_OF_FOCUSED_COMPONENTWHEN_FOCUSEDWHEN_IN_FOCUSED_WINDOW

Constructor Summary

AccessConstructor and Description
public
JInternalFrame()

Creates a non-resizable, non-closable, non-maximizable, non-iconifiable JInternalFrame with no title.

public
JInternalFrame(String
the non-null String to display in the title bar
title
)

Creates a non-resizable, non-closable, non-maximizable, non-iconifiable JInternalFrame with the specified title.

public
JInternalFrame(String
the String to display in the title bar
title
,
boolean
if true, the internal frame can be resized
resizable
)

Creates a non-closable, non-maximizable, non-iconifiable JInternalFrame with the specified title and resizability.

public
JInternalFrame(String
the String to display in the title bar
title
,
boolean
if true, the internal frame can be resized
resizable
,
boolean
if true, the internal frame can be closed
closable
)

Creates a non-maximizable, non-iconifiable JInternalFrame with the specified title, resizability, and closability.

public
JInternalFrame(String
the String to display in the title bar
title
,
boolean
if true, the internal frame can be resized
resizable
,
boolean
if true, the internal frame can be closed
closable
,
boolean
if true, the internal frame can be maximized
maximizable
)

Creates a non-iconifiable JInternalFrame with the specified title, resizability, closability, and maximizability.

public
JInternalFrame(String
the String to display in the title bar
title
,
boolean
if true, the internal frame can be resized
resizable
,
boolean
if true, the internal frame can be closed
closable
,
boolean
if true, the internal frame can be maximized
maximizable
,
boolean
if true, the internal frame can be iconified
iconifiable
)

Creates a JInternalFrame with the specified title, resizability, closability, maximizability, and iconifiability.

Method Summary

Modifier and TypeMethod and Description
protected void
addImpl(Component
the component to be enhanced
comp
,
Object
the constraints to be respected
constraints
,
int
the index
index
)

Overrides java.awt.Container.addImpl.

Adds the specified child Component.

public void
addInternalFrameListener(InternalFrameListener
the internal frame listener
l
)

Adds the specified listener to receive internal frame events from this internal frame.

private static void
pack-priv void
compWriteObjectNotify()

Overrides javax.swing.JComponent.compWriteObjectNotify.

This is called from Component by way of reflection.

protected JRootPane

Returns:

a new JRootPane
createRootPane
()

Called by the constructor to set up the JRootPane.

public void
dispose()

Makes this internal frame invisible, unselected, and closed.

public void
doDefaultCloseAction()

Fires an INTERNAL_FRAME_CLOSING event and then performs the action specified by the internal frame's default close operation.

protected void
fireInternalFrameEvent(int
the type of the event being fired; one of the following:
  • InternalFrameEvent.INTERNAL_FRAME_OPENED
  • InternalFrameEvent.INTERNAL_FRAME_CLOSING
  • InternalFrameEvent.INTERNAL_FRAME_CLOSED
  • InternalFrameEvent.INTERNAL_FRAME_ICONIFIED
  • InternalFrameEvent.INTERNAL_FRAME_DEICONIFIED
  • InternalFrameEvent.INTERNAL_FRAME_ACTIVATED
  • InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED
If the event type is not one of the above, nothing happens.
id
)

Fires an internal frame event.

public AccessibleContext

Returns:

an AccessibleJInternalFrame that serves as the AccessibleContext of this JInternalFrame
getAccessibleContext
()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this JInternalFrame.

public Container

Returns:

the content pane
getContentPane
()

Implements javax.swing.RootPaneContainer.getContentPane.

Returns the content pane for this internal frame.

public int

Returns:

the operation that will occur when the user closes the internal frame
getDefaultCloseOperation
()

Returns the default operation that occurs when the user initiates a "close" on this internal frame.

public JInternalFrame.JDesktopIcon

Returns:

the JDesktopIcon displayed on the desktop
getDesktopIcon
()

Returns the JDesktopIcon used when this JInternalFrame is iconified.

public JDesktopPane

Returns:

the JDesktopPane this internal frame belongs to, or null if none is found
getDesktopPane
()

Convenience method that searches the ancestor hierarchy for a JDesktop instance.

public final Container

Returns:

null
getFocusCycleRootAncestor
()

Overrides java.awt.Component.getFocusCycleRootAncestor.

Always returns null because JInternalFrames must always be roots of a focus traversal cycle.

public Component

Returns:

the component with focus, or null if no children have focus
getFocusOwner
()

If this JInternalFrame is active, returns the child that has focus.

public Icon

Returns:

the Icon displayed in the title bar
getFrameIcon
()

Returns the image displayed in the title bar of this internal frame (usually in the top-left corner).

public Component

Returns:

the glass pane
getGlassPane
()

Implements javax.swing.RootPaneContainer.getGlassPane.

Returns the glass pane for this internal frame.

public InternalFrameListener[]

Returns:

all of the InternalFrameListeners added or an empty array if no listeners have been added
getInternalFrameListeners
()

Returns an array of all the InternalFrameListeners added to this JInternalFrame with addInternalFrameListener.

public JMenuBar

Returns:

the JMenuBar used by this internal frame
getJMenuBar
()

Returns the current JMenuBar for this JInternalFrame, or null if no menu bar has been set.

public Cursor

Returns:

the last non-resizable Cursor
getLastCursor
()

Returns the last Cursor that was set by the setCursor method that is not a resizable Cursor.

public int

Returns:

an Integer object specifying this frame's desktop layer
getLayer
()

Convenience method for getting the layer attribute of this component.

public JLayeredPane

Returns:

a JLayeredPane object
getLayeredPane
()

Implements javax.swing.RootPaneContainer.getLayeredPane.

Returns the layered pane for this internal frame.

public JMenuBar

Returns:

the current menu bar, or null if none has been set
getMenuBar
()
Deprecated As of Swing version 1.0.3, replaced by getJMenuBar().

Returns the current JMenuBar for this JInternalFrame, or null if no menu bar has been set.

public Component

Returns:

the child component that will receive focus when this JInternalFrame is selected
getMostRecentFocusOwner
()

Returns the child component of this JInternalFrame that will receive the focus when this JInternalFrame is selected.

public Rectangle

Returns:

a Rectangle containing the bounds of this frame when in the normal state
getNormalBounds
()

If the JInternalFrame is not in maximized state, returns getBounds(); otherwise, returns the bounds that the JInternalFrame would be restored to.

public JRootPane

Returns:

the rootPane property
getRootPane
()

Overrides javax.swing.JComponent.getRootPane.

Implements javax.swing.RootPaneContainer.getRootPane.

Returns the rootPane object for this internal frame.

public String

Returns:

a String containing this internal frame's title
getTitle
()

Returns the title of the JInternalFrame.

public InternalFrameUI

Returns:

the InternalFrameUI object that renders this component
getUI
()

Overrides javax.swing.JComponent.getUI.

Returns the look-and-feel object that renders this component.

public String

Returns:

the string "InternalFrameUI"
getUIClassID
()

Overrides javax.swing.JComponent.getUIClassID.

Returns the name of the look-and-feel class that renders this component.

public final String

Returns:

null
getWarningString
()
Deprecated for removal since 24. since JDK 24

Gets the warning string that is displayed with this internal frame.

public void
public boolean

Returns:

true if this internal frame can be closed
isClosable
()

Returns whether this JInternalFrame can be closed by some user action.

public boolean

Returns:

true if this internal frame is closed, false otherwise
isClosed
()

Returns whether this JInternalFrame is currently closed.

public final boolean

Returns:

true
isFocusCycleRoot
()

Overrides java.awt.Container.isFocusCycleRoot.

Always returns true because all JInternalFrames must be roots of a focus traversal cycle.

public boolean

Returns:

true if this internal frame is iconified
isIcon
()

Returns whether the JInternalFrame is currently iconified.

public boolean

Returns:

the value of the iconable property.
isIconifiable
()

Gets the iconable property, which by default is false.

public boolean

Returns:

the value of the maximizable property
isMaximizable
()

Gets the value of the maximizable property.

public boolean

Returns:

true if this internal frame is maximized, false otherwise
isMaximum
()

Returns whether the JInternalFrame is currently maximized.

public boolean

Returns:

true if this internal frame can be resized, false otherwise
isResizable
()

Returns whether the JInternalFrame can be resized by some user action.

protected boolean

Returns:

true if add and setLayout are forwarded; false otherwise
isRootPaneCheckingEnabled
()

Returns whether calls to add and setLayout are forwarded to the contentPane.

public boolean

Returns:

true if this internal frame is currently selected (active)
isSelected
()

Returns whether the JInternalFrame is the currently "selected" or active frame.

public void
moveToBack()

Convenience method that moves this component to position -1 if its parent is a JLayeredPane.

public void
moveToFront()

Convenience method that moves this component to position 0 if its parent is a JLayeredPane.

public void
pack()

Causes subcomponents of this JInternalFrame to be laid out at their preferred size.

protected void
paintComponent(Graphics g)

Overrides javax.swing.JComponent.paintComponent.

Overridden to allow optimized painting when the internal frame is being dragged.

protected String

Returns:

a string representation of this JInternalFrame
paramString
()

Overrides javax.swing.JComponent.paramString.

Returns a string representation of this JInternalFrame.

public void
remove(Component
the component to be removed
comp
)

Overrides java.awt.Container.remove.

Removes the specified component from the container.

public void
removeInternalFrameListener(InternalFrameListener
the internal frame listener
l
)

Removes the specified internal frame listener so that it no longer receives internal frame events from this internal frame.

public void
reshape(int
an integer giving the component's new horizontal position measured in pixels from the left of its container
x
,
int
an integer giving the component's new vertical position, measured in pixels from the bottom of its container
y
,
int
an integer giving the component's new width in pixels
width
,
int
an integer giving the component's new height in pixels
height
)

Overrides javax.swing.JComponent.reshape.

Moves and resizes this component.

public void
restoreSubcomponentFocus()

Requests the internal frame to restore focus to the last subcomponent that had focus.

public void
setClosable(boolean
a boolean value, where true means this internal frame can be closed
b
)

Sets whether this JInternalFrame can be closed by some user action.

public void
setClosed(boolean
must be true
b
)

Closes this internal frame if the argument is true.

public void
setContentPane(Container
the content pane for this internal frame
c
)

Implements javax.swing.RootPaneContainer.setContentPane.

Sets this JInternalFrame's contentPane property.

public void
setCursor(Cursor cursor)

Overrides java.awt.Component.setCursor.

Sets the cursor image to the specified cursor.

public void
setDefaultCloseOperation(int
one of the following constants defined in javax.swing.WindowConstants (an interface implemented by JInternalFrame): DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, or DISPOSE_ON_CLOSE
operation
)

Sets the operation that will happen by default when the user initiates a "close" on this internal frame.

public void
setDesktopIcon(JInternalFrame.JDesktopIcon
the JDesktopIcon to display on the desktop
d
)

Sets the JDesktopIcon associated with this JInternalFrame.

public final void
setFocusCycleRoot(boolean
this value is ignored
focusCycleRoot
)

Overrides java.awt.Container.setFocusCycleRoot.

Does nothing because JInternalFrames must always be roots of a focus traversal cycle.

public void
setFrameIcon(Icon
the Icon to display in the title bar
icon
)

Sets an image to be displayed in the titlebar of this internal frame (usually in the top-left corner).

public void
setGlassPane(Component
the glass pane for this internal frame
glass
)

Implements javax.swing.RootPaneContainer.setGlassPane.

Sets this JInternalFrame's glassPane property.

public void
setIcon(boolean
a boolean, where true means to iconify this internal frame and false means to de-iconify it
b
)

Iconifies or de-iconifies this internal frame, if the look and feel supports iconification.

public void
setIconifiable(boolean
a boolean, where true means this internal frame can be iconified
b
)

Sets the iconable property, which must be true for the user to be able to make the JInternalFrame an icon.

public void
setJMenuBar(JMenuBar
the JMenuBar to use in this internal frame
m
)

Sets the menuBar property for this JInternalFrame.

private void
public void
setLayer(Integer
an Integer object specifying this frame's desktop layer
layer
)

Convenience method for setting the layer attribute of this component.

public void
setLayer(int
an integer specifying this internal frame's desktop layer
layer
)

Convenience method for setting the layer attribute of this component.

public void
setLayeredPane(JLayeredPane
the JLayeredPane for this internal frame
layered
)

Implements javax.swing.RootPaneContainer.setLayeredPane.

Sets this JInternalFrame's layeredPane property.

public void
setLayout(LayoutManager
the LayoutManager
manager
)

Overrides java.awt.Container.setLayout.

Ensures that, by default, the layout of this component cannot be set.

public void
setMaximizable(boolean
true to specify that this internal frame should be maximizable; false to specify that it should not be
b
)

Sets the maximizable property, which determines whether the JInternalFrame can be maximized by some user action.

public void
setMaximum(boolean
a boolean, where true maximizes this internal frame and false restores it
b
)

Maximizes and restores this internal frame.

public void
setMenuBar(JMenuBar
the JMenuBar to use in this internal frame
m
)
Deprecated As of Swing version 1.0.3 replaced by setJMenuBar(JMenuBar m).

Sets the menuBar property for this JInternalFrame.

public void
setNormalBounds(Rectangle
the bounds that this internal frame should be restored to
r
)

Sets the normal bounds for this internal frame, the bounds that this internal frame would be restored to from its maximized state.

public void
setResizable(boolean
a boolean, where true means this internal frame can be resized
b
)

Sets whether the JInternalFrame can be resized by some user action.

protected void
setRootPane(JRootPane
the new JRootPane object
root
)

Sets the rootPane property for this JInternalFrame.

protected void
setRootPaneCheckingEnabled(boolean
true if add and setLayout are forwarded, false if they should operate directly on the JInternalFrame.
enabled
)

Sets whether calls to add and setLayout are forwarded to the contentPane.

public void
setSelected(boolean
a boolean, where true means this internal frame should become selected (currently active) and false means it should become deselected
selected
)

Selects or deselects the internal frame if it's showing.

public void
setTitle(String
the String to display in the title bar
title
)

Sets the JInternalFrame title.

public void
setUI(InternalFrameUI
the UI delegate
ui
)

Sets the UI delegate for this JInternalFrame.

public void
show()

Overrides java.awt.Component.show.

If the internal frame is not visible, brings the internal frame to the front, makes it visible, and attempts to select it.

public void
toBack()

Sends this internal frame to the back.

public void
toFront()

Brings this internal frame to the front.

private static void
public void
updateUI()

Overrides javax.swing.JComponent.updateUI.

Notification from the UIManager that the look and feel has changed.

pack-priv void
private void
writeObject(ObjectOutputStream s)

Hides javax.swing.JComponent.writeObject.

See readObject and writeObject in JComponent for more information about serialization in Swing.

Inherited from javax.swing.JComponent:
_paintImmediatelyaddAncestorListeneraddNotifyaddVetoableChangeListeneralwaysOnTopcheckIfChildObscuredBySiblingclientPropertyChangedcomponentInputMapChangedcomputeVisibleRectcomputeVisibleRectcontainscreateToolTipdisabledndDonedropLocationForPointenablefirePropertyChangefirePropertyChangefirePropertyChangefireVetoableChangegetActionForKeyStrokegetActionMapgetActionMapgetAlignmentXgetAlignmentYgetAncestorListenersgetAutoscrollsgetBaselinegetBaselineResizeBehaviorgetBordergetBoundsgetClientPropertygetComponentGraphicsgetComponentPopupMenugetConditionForKeyStrokegetCreatedDoubleBuffergetDebugGraphicsOptionsgetDefaultLocalegetFontMetricsgetGraphicsgetGraphicsInvokedgetHeightgetInheritsPopupMenugetInputMapgetInputMapgetInputMapgetInputVerifiergetInsetsgetInsetsgetListenersgetLocationgetManagingFocusBackwardTraversalKeysgetManagingFocusForwardTraversalKeysgetMaximumSizegetMinimumSizegetNextFocusableComponentgetPopupLocationgetPreferredSizegetRegisteredKeyStrokesgetSizegetToolTipLocationgetToolTipTextgetToolTipTextgetTopLevelAncestorgetTransferHandlergetVerifyInputWhenFocusTargetgetVetoableChangeListenersgetVisibleRectgetWidthgetWriteObjCountergetXgetYgrabFocusisDoubleBufferedisLightweightComponentisManagingFocusisOpaqueisOptimizedDrawingEnabledisPaintingisPaintingForPrintisPaintingOriginisPaintingTileisRequestFocusEnabledisValidateRootpaintpaintBorderpaintChildrenpaintForceDoubleBufferedpaintImmediatelypaintImmediatelypaintToOffscreenprintprintAllprintBorderprintChildrenprintComponentprocessComponentKeyEventprocessKeyBindingprocessKeyBindingsprocessKeyBindingsForAllComponentsprocessKeyEventprocessMouseEventprocessMouseMotionEventputClientPropertyrectangleIsObscuredregisterKeyboardActionregisterKeyboardActionremoveAncestorListenerremoveNotifyremoveVetoableChangeListenerrepaintrepaintrequestDefaultFocusrequestFocusrequestFocusrequestFocusInWindowrequestFocusInWindowresetKeyboardActionsrevalidatesafelyGetGraphicssafelyGetGraphicsscrollRectToVisiblesetActionMapsetAlignmentXsetAlignmentYsetAutoscrollssetBackgroundsetBordersetComponentPopupMenusetCreatedDoubleBuffersetDebugGraphicsOptionssetDefaultLocalesetDoubleBufferedsetDropLocationsetEnabledsetFocusTraversalKeyssetFontsetForegroundsetInheritsPopupMenusetInputMapsetInputVerifiersetMaximumSizesetMinimumSizesetNextFocusableComponentsetOpaquesetPaintingChildsetPreferredSizesetRequestFocusEnabledsetToolTipTextsetTransferHandlersetUIsetUIPropertysetVerifyInputWhenFocusTargetsetVisiblesetWriteObjCountershouldDebugGraphicssuperProcessMouseMotionEventunregisterKeyboardActionupdate