| Constructor: |
public JFrame() throws HeadlessException {
frameInit();
}
Constructs a new frame with an empty title which is initially invisible. Throws:
HeadlessException - - when GraphicsEnvironment.isHeadless()
returns true
|
public JFrame(String title) throws HeadlessException {
super(title);
frameInit();
}
Constructs a new frame with the specified title which is initially
invisible. Parameters:
title - - title of the frame; if title is null, an empty title
is assumed
Throws:
HeadlessException - - when GraphicsEnvironment.isHeadless()
returns true
|
public JFrame(GraphicsConfiguration gc) {
super(gc);
frameInit();
}
Constructs a new frame in the specified GraphicsConfiguration and
an empty title. Parameters:
gc - - the GraphicsConfiguration to construct the frame;
if gc is null, the system default GraphicsConfiguration is assumed
|
public JFrame(String title,
GraphicsConfiguration gc) {
super(title, gc);
frameInit();
}
Constructs a new frame in the specified GraphicsConfiguration and
the specified title. Parameters:
title - - title of the frame; if title is null, an empty title
is assumed
gc - - the GraphicsConfiguration to construct the frame;
if gc is null, the system default GraphicsConfiguration is assumed
|
| Methods from java.awt.Component: |
|---|
|
action, add, addAWTComponentListener, addAWTFocusListener, addAWTInputMethodListener, addAWTKeyListener, addAWTMouseListener, addAWTMouseMotionListener, addAWTMouseWheelListener, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNewEvent, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, autoName, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createAccessibleContext, createBehavior, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, finishChildrenHierarchyChange, finishHierarchyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getCursorAncestor, getDefaultBackground, getDefaultForeground, getDefaultMinimumSize, getDefaultPreferredSize, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHWAncestor, getHWSurface, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getIndentStr, getInputContext, getInputMethodListeners, getInputMethodRequests, getInsets, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getNativeInsets, getNativeWindow, getObscuredRegion, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRealCursor, getRealParent, getRedrawManager, getRelativeEvent, getSize, getSize, getTextFieldKit, getTextKit, getToolkit, getTreeLock, getWidth, getWindowAncestor, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, initGraphics, inside, invalidate, isBackgroundSet, isCoalescer, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isEventEnabled, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFocusabilityExplicitlySet, isFocusable, isFontSet, isForegroundSet, isIndirectlyEnabled, isKeyEnabled, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isMouseEventEnabled, isMouseExitedExpected, isOpaque, isPeerFocusable, isPreferredSizeSet, isPrepainter, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, mapToDisplay, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, moveFocus, moveFocusOnHide, nativeWindowCreated, nextFocus, notifyInputMethod, onDrawImage, paint, paintAll, paramString, postEvent, postEvent, postHierarchyBoundsEvents, postprocessEvent, preferredSize, prepaint, prepare4HierarchyChange, prepareChildren4HierarchyChange, prepareImage, prepareImage, preprocessFocusEvent, preprocessKeyEvent, preprocessMouseEvent, preprocessMouseMotionEvent, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, propagateFont, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNextEvent, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeRelativeEvent, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusImpl, requestFocusInWindow, requestFocusInWindow, resetDefaultSize, reshape, resize, resize, setBackground, setBounds, setBounds, setBounds, setCaretPos, setCaretPosImpl, setComponentOrientation, setCursor, setCursor, setDropTarget, setEnabled, setEnabledImpl, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFocusable, setFont, setFontImpl, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMouseExitedExpected, setName, setParent, setPreferredSize, setRedrawManager, setSize, setSize, setTextFieldKit, setTextKit, setVisible, show, show, size, spreadHierarchyBoundsEvents, toString, transferFocus, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate, validateImpl |
| Method from javax.swing.JFrame Detail: |
protected void addImpl(Component comp,
Object constraints,
int index) {
if (isRootPaneCheckingEnabled()) {
getContentPane().add(comp, constraints, index);
return;
}
super.addImpl(comp, constraints, index);
}
|
protected JRootPane createRootPane() {
return new JRootPane();
}
Called by the constructors to create the default rootPane property. |
protected void frameInit() {
setRootPaneCheckingEnabled(true);
setRootPane(createRootPane());
setLocale(JComponent.getDefaultLocale());
// check isDefaultLookAndFeelDecorated()
if (isDefaultLookAndFeelDecorated()) {
setUndecorated(Utilities.lookAndFeelSupportsWindowDecorations());
getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
}
setBackground(getContentPane().getBackground());
// enable events
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
enableEvents(AWTEvent.KEY_EVENT_MASK);
setFocusTraversalPolicy(KeyboardFocusManager.getCurrentKeyboardFocusManager()
.getDefaultFocusTraversalPolicy());
}
Called by the constructors to init JFrame |
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJFrame();
}
return accessibleContext;
}
Returns the accessible context for the frame. |
public Container getContentPane() {
return getRootPane().getContentPane();
}
Returns the contentPane property. |
public int getDefaultCloseOperation() {
return defaultCloseOperation;
}
Returns defaultCloseOperation value. |
public Component getGlassPane() {
return getRootPane().getGlassPane();
}
Returns glassPane property. |
public JMenuBar getJMenuBar() {
return getRootPane().getJMenuBar();
}
Returns the menu bar for the frame |
public JLayeredPane getLayeredPane() {
return getRootPane().getLayeredPane();
}
Returns layeredPane property. |
public JRootPane getRootPane() {
return rootPane;
}
|
static Frame getSharedOwner() {
if (sharedFrame == null) {
sharedFrame = new Frame();
}
return sharedFrame;
}
Returns the frame that is used as a default shared owner for
JDialog and JWindow. |
public static boolean isDefaultLookAndFeelDecorated() {
return defaultLookAndFeelDecorated;
}
|
protected boolean isRootPaneCheckingEnabled() {
return rootPaneCheckingEnabled;
}
Returns rootPaneCheckingEnabled value. |
protected String paramString() {
String result = super.paramString();
if (getRootPane() != null) {
result += ",rootPane=" + getRootPane().toString();
} else {
result += ",rootPane=null";
}
return result;
}
Returns string representation of this frame. |
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
switch (getDefaultCloseOperation()) {
case DISPOSE_ON_CLOSE: // dispose
dispose();
break;
case HIDE_ON_CLOSE: // hide
setVisible(false);
break;
case DO_NOTHING_ON_CLOSE: // do nothing
break;
case EXIT_ON_CLOSE: // exit
System.exit(0);
break;
}
}
}
Implements actions depending on defaultCloseOperation property. |
public void remove(Component comp) {
// Note: differs from JInternalFrame's behavior,
// how titlePane is removed?
if (comp == getRootPane()) {
// remove directly from JDialog
super.remove(comp);
} else {
getContentPane().remove(comp);
}
}
|
public void setContentPane(Container contentPane) {
getRootPane().setContentPane(contentPane);
}
Sets contentPane property. |
public void setDefaultCloseOperation(int operation) {
int oldOperation = getDefaultCloseOperation();
switch (operation) {
case DO_NOTHING_ON_CLOSE:
case HIDE_ON_CLOSE:
case DISPOSE_ON_CLOSE:
defaultCloseOperation = operation;
break;
case EXIT_ON_CLOSE:
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkExit(0);
}
defaultCloseOperation = operation;
break;
default:
throw new IllegalArgumentException(
Messages.getString("swing.B2","defaultCloseOperation", //$NON-NLS-1$ //$NON-NLS-2$
"DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, DISPOSE_ON_CLOSE, EXIT_ON_CLOSE")); //$NON-NLS-1$
}
firePropertyChange("defaultCloseOperation", oldOperation, operation);
}
Sets defaultCloseOperation property. This is a bound property. |
public static void setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated) {
JFrame.defaultLookAndFeelDecorated = defaultLookAndFeelDecorated;
}
|
public void setGlassPane(Component glassPane) {
getRootPane().setGlassPane(glassPane);
}
|
public void setIconImage(Image image) {
Image oldValue = getIconImage();
super.setIconImage(image);
firePropertyChange(StringConstants.ICON_IMAGE_PROPERTY, oldValue, image);
}
|
public void setJMenuBar(JMenuBar menuBar) {
getRootPane().setJMenuBar(menuBar);
}
Sets the menu bar for the frame. |
public void setLayeredPane(JLayeredPane layeredPane) {
getRootPane().setLayeredPane(layeredPane);
}
Sets layeredPane property. |
public void setLayout(LayoutManager layout) {
if (isRootPaneCheckingEnabled()) {
getContentPane().setLayout(layout);
} else {
super.setLayout(layout);
}
}
|
protected void setRootPane(JRootPane root) {
if (rootPane != null) {
remove(rootPane);
}
rootPane = root;
if (root != null) {
super.addImpl(root, null, 0);
}
}
|
protected void setRootPaneCheckingEnabled(boolean enabled) {
rootPaneCheckingEnabled = enabled;
}
Sets rootPaneCheckingEnabled. |
public void update(Graphics g) {
paint(g);
}
Just calls paint(g). This method was overridden to prevent
an unnecessary call to clear the background. |