Class JInternalFrame
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
,RootPaneContainer
,WindowConstants
Generally,
you add JInternalFrame
s 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 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 XMLEncoder
.
- Since:
- 1.2
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
This class implements accessibility support for theJInternalFrame
class.static class
This component represents an iconified version of aJInternalFrame
.Nested classes/interfaces declared in class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces declared in class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces declared in class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
The frame can be closed.static final String
Bound property name.protected JInternalFrame.JDesktopIcon
The icon that is displayed when this internal frame is iconified.static final String
Bound property name.protected Icon
The icon shown in the top-left corner of this internal frame.static final String
Bound property name.protected boolean
The frame can "iconified" (shrunk down and displayed as an icon-image).static final String
Constrained property name indicating that the internal frame is closed.static final String
Constrained property name indicating that the internal frame is iconified.static final String
Constrained property name indicating that the internal frame is maximized.static final String
Constrained property name indicated that this frame has selected status.protected boolean
The frame has been closed.protected boolean
The frame has been iconified.protected boolean
The frame has been expanded to its maximum size.protected boolean
The frame is currently selected.static final String
Bound property name.protected boolean
The frame can be expanded to the size of the desktop pane.static final String
Bound property name.protected boolean
The frame's size can be changed.static final String
Bound property name.protected JRootPane
TheJRootPane
instance that manages the content pane and optional menu bar for this internal frame, as well as the glass pane.protected boolean
If true then calls toadd
andsetLayout
will be forwarded to thecontentPane
.protected String
The title displayed in this internal frame's title bar.static final String
Bound property name.Fields declared in class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields declared in class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields declared in interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Fields declared in interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a non-resizable, non-closable, non-maximizable, non-iconifiableJInternalFrame
with no title.JInternalFrame
(String title) Creates a non-resizable, non-closable, non-maximizable, non-iconifiableJInternalFrame
with the specified title.JInternalFrame
(String title, boolean resizable) Creates a non-closable, non-maximizable, non-iconifiableJInternalFrame
with the specified title and resizability.JInternalFrame
(String title, boolean resizable, boolean closable) Creates a non-maximizable, non-iconifiableJInternalFrame
with the specified title, resizability, and closability.JInternalFrame
(String title, boolean resizable, boolean closable, boolean maximizable) Creates a non-iconifiableJInternalFrame
with the specified title, resizability, closability, and maximizability.JInternalFrame
(String title, boolean resizable, boolean closable, boolean maximizable, boolean iconifiable) Creates aJInternalFrame
with the specified title, resizability, closability, maximizability, and iconifiability. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Adds the specified childComponent
.void
Adds the specified listener to receive internal frame events from this internal frame.protected JRootPane
Called by the constructor to set up theJRootPane
.void
dispose()
Makes this internal frame invisible, unselected, and closed.void
Fires anINTERNAL_FRAME_CLOSING
event and then performs the action specified by the internal frame's default close operation.protected void
fireInternalFrameEvent
(int id) Fires an internal frame event.Gets theAccessibleContext
associated with thisJInternalFrame
.Returns the content pane for this internal frame.int
Returns the default operation that occurs when the user initiates a "close" on this internal frame.Returns theJDesktopIcon
used when thisJInternalFrame
is iconified.Convenience method that searches the ancestor hierarchy for aJDesktop
instance.final Container
Always returnsnull
becauseJInternalFrame
s must always be roots of a focus traversal cycle.If thisJInternalFrame
is active, returns the child that has focus.Returns the image displayed in the title bar of this internal frame (usually in the top-left corner).Returns the glass pane for this internal frame.Returns an array of all theInternalFrameListener
s added to thisJInternalFrame
withaddInternalFrameListener
.Returns the currentJMenuBar
for thisJInternalFrame
, ornull
if no menu bar has been set.Returns the lastCursor
that was set by thesetCursor
method that is not a resizableCursor
.int
getLayer()
Convenience method for getting the layer attribute of this component.Returns the layered pane for this internal frame.Deprecated.Returns the child component of thisJInternalFrame
that will receive the focus when thisJInternalFrame
is selected.If theJInternalFrame
is not in maximized state, returnsgetBounds()
; otherwise, returns the bounds that theJInternalFrame
would be restored to.Returns therootPane
object for this internal frame.getTitle()
Returns the title of theJInternalFrame
.getUI()
Returns the look-and-feel object that renders this component.Returns the name of the look-and-feel class that renders this component.final String
Deprecated, for removal: This API element is subject to removal in a future version.since JDK 24void
hide()
boolean
Returns whether thisJInternalFrame
can be closed by some user action.boolean
isClosed()
Returns whether thisJInternalFrame
is currently closed.final boolean
Always returnstrue
because allJInternalFrame
s must be roots of a focus traversal cycle.boolean
isIcon()
Returns whether theJInternalFrame
is currently iconified.boolean
Gets theiconable
property, which by default isfalse
.boolean
Gets the value of themaximizable
property.boolean
Returns whether theJInternalFrame
is currently maximized.boolean
Returns whether theJInternalFrame
can be resized by some user action.protected boolean
Returns whether calls toadd
andsetLayout
are forwarded to thecontentPane
.boolean
Returns whether theJInternalFrame
is the currently "selected" or active frame.void
Convenience method that moves this component to position -1 if its parent is aJLayeredPane
.void
Convenience method that moves this component to position 0 if its parent is aJLayeredPane
.void
pack()
Causes subcomponents of thisJInternalFrame
to be laid out at their preferred size.protected void
Overridden to allow optimized painting when the internal frame is being dragged.protected String
Returns a string representation of thisJInternalFrame
.void
Removes the specified component from the container.void
Removes the specified internal frame listener so that it no longer receives internal frame events from this internal frame.void
reshape
(int x, int y, int width, int height) Moves and resizes this component.void
Requests the internal frame to restore focus to the last subcomponent that had focus.void
setClosable
(boolean b) Sets whether thisJInternalFrame
can be closed by some user action.void
setClosed
(boolean b) Closes this internal frame if the argument istrue
.void
Sets thisJInternalFrame
'scontentPane
property.void
Sets the cursor image to the specified cursor.void
setDefaultCloseOperation
(int operation) Sets the operation that will happen by default when the user initiates a "close" on this internal frame.void
Sets theJDesktopIcon
associated with thisJInternalFrame
.final void
setFocusCycleRoot
(boolean focusCycleRoot) Does nothing becauseJInternalFrame
s must always be roots of a focus traversal cycle.void
setFrameIcon
(Icon icon) Sets an image to be displayed in the titlebar of this internal frame (usually in the top-left corner).void
setGlassPane
(Component glass) Sets thisJInternalFrame
'sglassPane
property.void
setIcon
(boolean b) Iconifies or de-iconifies this internal frame, if the look and feel supports iconification.void
setIconifiable
(boolean b) Sets theiconable
property, which must betrue
for the user to be able to make theJInternalFrame
an icon.void
Sets themenuBar
property for thisJInternalFrame
.void
setLayer
(int layer) Convenience method for setting the layer attribute of this component.void
Convenience method for setting the layer attribute of this component.void
setLayeredPane
(JLayeredPane layered) Sets thisJInternalFrame
'slayeredPane
property.void
setLayout
(LayoutManager manager) Ensures that, by default, the layout of this component cannot be set.void
setMaximizable
(boolean b) Sets themaximizable
property, which determines whether theJInternalFrame
can be maximized by some user action.void
setMaximum
(boolean b) Maximizes and restores this internal frame.void
Deprecated.As of Swing version 1.0.3 replaced bysetJMenuBar(JMenuBar m)
.void
Sets the normal bounds for this internal frame, the bounds that this internal frame would be restored to from its maximized state.void
setResizable
(boolean b) Sets whether theJInternalFrame
can be resized by some user action.protected void
setRootPane
(JRootPane root) Sets therootPane
property for thisJInternalFrame
.protected void
setRootPaneCheckingEnabled
(boolean enabled) Sets whether calls toadd
andsetLayout
are forwarded to thecontentPane
.void
setSelected
(boolean selected) Selects or deselects the internal frame if it's showing.void
Sets theJInternalFrame
title.void
setUI
(InternalFrameUI ui) Sets the UI delegate for thisJInternalFrame
.void
show()
If the internal frame is not visible, brings the internal frame to the front, makes it visible, and attempts to select it.void
toBack()
Sends this internal frame to the back.void
toFront()
Brings this internal frame to the front.void
updateUI()
Notification from theUIManager
that the look and feel has changed.Methods declared in class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible,
getJMenuBar()
.