Methods Summary |
---|
protected void | addImpl(java.awt.Component comp, java.lang.Object constraints, int index)Adds the specified child Component .
This method is overridden to conditionally forward calls to the
contentPane .
By default, children are added to the contentPane instead
of the frame, refer to {@link javax.swing.RootPaneContainer} for
details.
if(isRootPaneCheckingEnabled()) {
getContentPane().add(comp, constraints, index);
}
else {
super.addImpl(comp, constraints, index);
}
|
protected javax.swing.JRootPane | createRootPane()Called by the constructor methods to create the default
rootPane .
JRootPane rp = new JRootPane();
// NOTE: this uses setOpaque vs LookAndFeel.installProperty as there
// is NO reason for the RootPane not to be opaque. For painting to
// work the contentPane must be opaque, therefor the RootPane can
// also be opaque.
rp.setOpaque(true);
return rp;
|
protected void | frameInit()Called by the constructors to init the JFrame properly.
enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.WINDOW_EVENT_MASK);
setLocale( JComponent.getDefaultLocale() );
setRootPane(createRootPane());
setBackground(UIManager.getColor("control"));
setRootPaneCheckingEnabled(true);
if (JFrame.isDefaultLookAndFeelDecorated()) {
boolean supportsWindowDecorations =
UIManager.getLookAndFeel().getSupportsWindowDecorations();
if (supportsWindowDecorations) {
setUndecorated(true);
getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
}
}
sun.awt.SunToolkit.checkAndSetPolicy(this, true);
|
public javax.accessibility.AccessibleContext | getAccessibleContext()Gets the AccessibleContext associated with this JFrame.
For JFrames, the AccessibleContext takes the form of an
AccessibleJFrame.
A new AccessibleJFrame instance is created if necessary.
if (accessibleContext == null) {
accessibleContext = new AccessibleJFrame();
}
return accessibleContext;
|
public java.awt.Container | getContentPane()Returns the contentPane object for this frame.
return getRootPane().getContentPane();
|
public int | getDefaultCloseOperation()Returns the operation that occurs when the user
initiates a "close" on this frame.
return defaultCloseOperation;
|
public java.awt.Component | getGlassPane()Returns the glassPane object for this frame.
return getRootPane().getGlassPane();
|
public java.awt.Graphics | getGraphics(){@inheritDoc}
JComponent.getGraphicsInvoked(this);
return super.getGraphics();
|
public javax.swing.JMenuBar | getJMenuBar()Returns the menubar set on this frame.
return getRootPane().getMenuBar();
|
public javax.swing.JLayeredPane | getLayeredPane()Returns the layeredPane object for this frame.
return getRootPane().getLayeredPane();
|
public javax.swing.JRootPane | getRootPane()Returns the rootPane object for this frame.
return rootPane;
|
public javax.swing.TransferHandler | getTransferHandler()Gets the transferHandler property.
return transferHandler;
|
public static boolean | isDefaultLookAndFeelDecorated()Returns true if newly created JFrame s should have their
Window decorations provided by the current look and feel. This is only
a hint, as certain look and feels may not support this feature.
Boolean defaultLookAndFeelDecorated =
(Boolean) SwingUtilities.appContextGet(defaultLookAndFeelDecoratedKey);
if (defaultLookAndFeelDecorated == null) {
defaultLookAndFeelDecorated = Boolean.FALSE;
}
return defaultLookAndFeelDecorated.booleanValue();
|
protected boolean | isRootPaneCheckingEnabled()Returns whether calls to add and
setLayout are forwarded to the contentPane .
return rootPaneCheckingEnabled;
|
protected java.lang.String | paramString()Returns a string representation of this JFrame .
This method
is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not
be null .
String defaultCloseOperationString;
if (defaultCloseOperation == HIDE_ON_CLOSE) {
defaultCloseOperationString = "HIDE_ON_CLOSE";
} else if (defaultCloseOperation == DISPOSE_ON_CLOSE) {
defaultCloseOperationString = "DISPOSE_ON_CLOSE";
} else if (defaultCloseOperation == DO_NOTHING_ON_CLOSE) {
defaultCloseOperationString = "DO_NOTHING_ON_CLOSE";
} else if (defaultCloseOperation == 3) {
defaultCloseOperationString = "EXIT_ON_CLOSE";
} else defaultCloseOperationString = "";
String rootPaneString = (rootPane != null ?
rootPane.toString() : "");
String rootPaneCheckingEnabledString = (rootPaneCheckingEnabled ?
"true" : "false");
return super.paramString() +
",defaultCloseOperation=" + defaultCloseOperationString +
",rootPane=" + rootPaneString +
",rootPaneCheckingEnabled=" + rootPaneCheckingEnabledString;
|
protected void | processWindowEvent(java.awt.event.WindowEvent e)Processes window events occurring on this component.
Hides the window or disposes of it, as specified by the setting
of the defaultCloseOperation property.
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
switch(defaultCloseOperation) {
case HIDE_ON_CLOSE:
setVisible(false);
break;
case DISPOSE_ON_CLOSE:
dispose();
break;
case DO_NOTHING_ON_CLOSE:
default:
break;
case EXIT_ON_CLOSE:
// This needs to match the checkExit call in
// setDefaultCloseOperation
System.exit(0);
break;
}
}
|
public void | remove(java.awt.Component comp)Removes the specified component from the container. If
comp is not the rootPane , this will forward
the call to the contentPane . This will do nothing if
comp is not a child of the JFrame or
contentPane .
if (comp == rootPane) {
super.remove(comp);
} else {
getContentPane().remove(comp);
}
|
public void | repaint(long time, int x, int y, int width, int height)Repaints the specified rectangle of this component within
time milliseconds. Refer to RepaintManager
for details on how the repaint is handled.
if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
RepaintManager.currentManager(this).addDirtyRegion(
this, x, y, width, height);
}
else {
super.repaint(time, x, y, width, height);
}
|
public void | setContentPane(java.awt.Container contentPane)Sets the contentPane property.
This method is called by the constructor.
Swing's painting architecture requires an opaque JComponent
in the containment hiearchy. This is typically provided by the
content pane. If you replace the content pane it is recommended you
replace it with an opaque JComponent .
getRootPane().setContentPane(contentPane);
|
public void | setDefaultCloseOperation(int operation)Sets the operation that will happen by default when
the user initiates a "close" on this frame.
You must specify one of the following choices:
DO_NOTHING_ON_CLOSE
(defined in WindowConstants ):
Don't do anything; require the
program to handle the operation in the windowClosing
method of a registered WindowListener object.
HIDE_ON_CLOSE
(defined in WindowConstants ):
Automatically hide the frame after
invoking any registered WindowListener
objects.
DISPOSE_ON_CLOSE
(defined in WindowConstants ):
Automatically hide and dispose the
frame after invoking any registered WindowListener
objects.
EXIT_ON_CLOSE
(defined in JFrame ):
Exit the application using the System
exit method. Use this only in applications.
The value is set to HIDE_ON_CLOSE by default. Changes
to the value of this property cause the firing of a property
change event, with property name "defaultCloseOperation".
Note: When the last displayable window within the
Java virtual machine (VM) is disposed of, the VM may
terminate. See
AWT Threading Issues for more information.
if (operation != DO_NOTHING_ON_CLOSE &&
operation != HIDE_ON_CLOSE &&
operation != DISPOSE_ON_CLOSE &&
operation != EXIT_ON_CLOSE) {
throw new IllegalArgumentException("defaultCloseOperation must be one of: DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, DISPOSE_ON_CLOSE, or EXIT_ON_CLOSE");
}
if (this.defaultCloseOperation != operation) {
if (operation == EXIT_ON_CLOSE) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkExit(0);
}
}
int oldValue = this.defaultCloseOperation;
this.defaultCloseOperation = operation;
firePropertyChange("defaultCloseOperation", oldValue, operation);
}
|
public static void | setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated)Provides a hint as to whether or not newly created JFrame s
should have their Window decorations (such as borders, widgets to
close the window, title...) provided by the current look
and feel. If defaultLookAndFeelDecorated is true,
the current LookAndFeel supports providing window
decorations, and the current window manager supports undecorated
windows, then newly created JFrame s will have their
Window decorations provided by the current LookAndFeel .
Otherwise, newly created JFrame s will have their
Window decorations provided by the current window manager.
You can get the same effect on a single JFrame by doing the following:
JFrame frame = new JFrame();
frame.setUndecorated(true);
frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
if (defaultLookAndFeelDecorated) {
SwingUtilities.appContextPut(defaultLookAndFeelDecoratedKey, Boolean.TRUE);
} else {
SwingUtilities.appContextPut(defaultLookAndFeelDecoratedKey, Boolean.FALSE);
}
|
public void | setGlassPane(java.awt.Component glassPane)Sets the glassPane property.
This method is called by the constructor.
getRootPane().setGlassPane(glassPane);
|
public void | setIconImage(java.awt.Image image){@inheritDoc}
super.setIconImage(image);
|
public void | setJMenuBar(javax.swing.JMenuBar menubar)Sets the menubar for this frame.
getRootPane().setMenuBar(menubar);
|
public void | setLayeredPane(javax.swing.JLayeredPane layeredPane)Sets the layeredPane property.
This method is called by the constructor.
getRootPane().setLayeredPane(layeredPane);
|
public void | setLayout(java.awt.LayoutManager manager)Sets the LayoutManager .
Overridden to conditionally forward the call to the
contentPane .
Refer to {@link javax.swing.RootPaneContainer} for
more information.
if(isRootPaneCheckingEnabled()) {
getContentPane().setLayout(manager);
}
else {
super.setLayout(manager);
}
|
protected void | setRootPane(javax.swing.JRootPane root)Sets the rootPane property.
This method is called by the constructor.
if(rootPane != null) {
remove(rootPane);
}
rootPane = root;
if(rootPane != null) {
boolean checkingEnabled = isRootPaneCheckingEnabled();
try {
setRootPaneCheckingEnabled(false);
add(rootPane, BorderLayout.CENTER);
}
finally {
setRootPaneCheckingEnabled(checkingEnabled);
}
}
|
protected void | setRootPaneCheckingEnabled(boolean enabled)Sets whether calls to add and
setLayout are forwarded to the contentPane .
rootPaneCheckingEnabled = enabled;
|
public void | setTransferHandler(javax.swing.TransferHandler newHandler)Sets the {@code transferHandler} property, which is a mechanism to
support transfer of data into this component. Use {@code null}
if the component does not support data transfer operations.
If the system property {@code suppressSwingDropSupport} is {@code false}
(the default) and the current drop target on this component is either
{@code null} or not a user-set drop target, this method will change the
drop target as follows: If {@code newHandler} is {@code null} it will
clear the drop target. If not {@code null} it will install a new
{@code DropTarget}.
Note: When used with {@code JFrame}, {@code TransferHandler} only
provides data import capability, as the data export related methods
are currently typed to {@code JComponent}.
Please see
How to Use Drag and Drop and Data Transfer, a section in
The Java Tutorial, for more information.
TransferHandler oldHandler = transferHandler;
transferHandler = newHandler;
SwingUtilities.installSwingDropTargetAsNecessary(this, transferHandler);
firePropertyChange("transferHandler", oldHandler, newHandler);
|
public void | update(java.awt.Graphics g)Just calls paint(g) . This method was overridden to
prevent an unnecessary call to clear the background.
paint(g);
|