Generated by
JDiff

javax.swing Documentation Differences

This file contains all the changes in documentation in the package javax.swing as colored differences. Deletions are shown like this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

Class AbstractAction

This class provides default implementations for the JFC Action interface. Standard behaviors like the get and set methods for Action object properties (icon text and enabled) are defined here. The developer need only subclass this abstract class and define the actionPerformed method.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @version 1.46 1247 02/0311/0102 @author Georges Saab @see Action


Class AbstractButton

Defines common behaviors for buttons and menu items. For further information see How to Use Buttons Check Boxes and Radio Buttons a section in The Java Tutorial.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @version 1.153 12156 04/0305/0102 @author Jeff Dinkins

Class AbstractButton, void setMnemonic(int)

Sets the keyboard mnemonic on the current model. The mnemonic is the key which when combined with the look and feel's mouseless modifier (usually Alt) will activate this button if focus is contained somewhere within this button's ancestor window.

A mnemonic must correspond to a single key on the keyboard and should be specified using one of the VK_XXX keycodes defined in java.awt.event.KeyEvent. Mnemonics are case-insensitive therefore a key event with the corresponding keycode would cause the button to be activated whether or not the Shift modifier was pressed.

If the character defined by the mnemonic is found within the button's label string the first occurrence of it will be underlined to indicate the mnemonic to the user. If the corresponding character is not contained within the button's label then it will be displayed near the label in a look and feel dependent manner (commonly to the right surrounded by parenthesis). @param mnemonic the key code which represents the mnemonic @see java.awt.event.KeyEvent @see #setDisplayedMnemonicIndex @beaninfo bound: true attribute: visualUpdate true description: the keyboard character mnemonic


Class ButtonGroup

This class is used to create a multiple-exclusion scope for a set of buttons. Creating a set of buttons with the same ButtonGroup object means that turning "on" one of those buttons turns off all other buttons in the group.

A ButtonGroup can be used with any set of objects that inherit from AbstractButton. Typically a button group contains instances of JRadioButton JRadioButtonMenuItem or JToggleButton. It wouldn't make sense to put an instance of JButton or JMenuItem in a button group because JButton and JMenuItem don't implement the selected state.

Initially all buttons in the group are unselected. Once any button is selected one button is always selected in the group. There is no way to turn a button programmatically to "off" in order to clear the button group. To give the appearance of "none selected" add an invisible radio button to the group and then programmatically select that button to turn off all the displayed radio buttons. For example a normal button with the label "none" could be wired to select the invisible radio button.

For examples and further information on using button groups see How to Use Radio Buttons a section in The Java Tutorial.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @version 1.3233 12/0307/01 @author Jeff Dinkins

Class ButtonGroup, int getButtonCount()

Returns the number of buttons in the group. @return the button count @since 1.3

Class DefaultCellEditor

The default editor for table and tree cells.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @version 1.46 1247 02/0311/0102 @author Alan Chung @author Philip Milne


Class DefaultDesktopManager

This is an implementation of the DesktopManager. It currently implements the basic behaviors for managing JInternalFrames in an arbitrary parent. JInternalFrames that are not children of a JDesktop will use this component to handle their desktop-like actions.

This class provides a policy for the various JInternalFrame methods it is not meant to be called directly rather the various JInternalFrame methods will call into the DesktopManager.

@see JDesktopPane @see JInternalFrame @version 1.45 1246 04/0315/0102 @author David Kloba @author Steve Wilson

Class DefaultListSelectionModel

Default data model for list selections.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @version 1.65 1266 02/0313/0102 @author Philip Milne @author Hans Muller @see ListSelectionModel

Class DefaultListSelectionModel, void insertIndexInterval(int, int, boolean)

Insert length indices beginning before/after index. If the value at index is itself selected and the selection mode is not SINGLE_SELECTION set all of the newly inserted items otherwiseas selected. Otherwise leave them unselected. This method is typically called to sync the selection model with a corresponding change in the data model.

Class DesktopManager

DesktopManager objects are owned by a JDesktopPane object. They are responsible for implementing L&F specific behaviors for the JDesktopPane. JInternalFrame implementations should delegate specific behaviors to the DesktopManager. For instance if a JInternalFrame was asked to iconify it should try:
 getDesktopPane().getDesktopManager().iconifyFrame(frame); 
This delegation allows each L&F to provide custom behaviors for desktop-specific actions. (For example how and where the internal frame's icon would appear.)

This class provides a policy for the various JInternalFrame methods it is not meant to be called directly rather the various JInternalFrame methods will call into the DesktopManager.

@see JDesktopPane @see JInternalFrame @see JInternalFrame.JDesktopIcon @version 1.12 1213 04/0315/0102 @author David Kloba

Class JCheckBox

An implementation of a check box -- an item that can be selected or deselected and which displays its state to the user. By convention any number of check boxes in a group can be selected. See How to Use ButtoncButtons Check Boxes and Radio Buttons in The Java Tutorial for examples and information on using check boxes.

For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JCheckBox key assignments.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @see JRadioButton @beaninfo attribute: isContainer false description: A component which can be selected or deselected. @version 1.6869 12/03/0112/02 @author Jeff Dinkins


Class JColorChooser

JColorChooser provides a pane of controls designed to allow a user to manipulate and select a color. For information about using color choosers see How to Use Color Choosers a section in The Java Tutorial.

This class provides three levels of API:

  1. A static convenience method which shows a modal color-chooser dialog and returns the color selected by the user.
  2. A static convenience method for creating a color-chooser dialog where ActionListeners can be specified to be invoked when the user presses one of the dialog buttons.
  3. The ability to create instances of JColorChooser panes directly (within any container). PropertyChange listeners can be added to detect when the current "color" property changes.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @beaninfo attribute: isContainer false description: A component that supports selecting a Color. @version 1.4142 12/03/0120/02 @author James Gosling @author Amy Fowler @author Steve Wilson

Class JColorChooser, constructor JColorChooser(ColorSelectionModel)

Creates a color chooser pane with the specified ColorSelectionModel. @param initialColormodel the initial color setColorSelectionModel in the chooserto be used
Class JColorChooser, void setPreviewPanel(JComponent)

Sets the current preview panel. This will fire a PropertyChangeEvent for the property named "previewPanel". @param colorpreview the color to beJComponent set inwhich displays the colorcurrent choosercolor @see JComponent#addPropertyChangeListener @beaninfo bound: true hidden: true description: The UI component which displays the current color.

Class JComboBox

A component that combines a button or editable field and a drop-down list. The user can select a value from the drop-down list which appears at the user's request. If you make the combo box editable then the combo box includes an editable field into which the user can type a value.

For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JComboBox key assignments.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder

See How to Use Combo Boxes in The Java Tutorial for further information.

@see ComboBoxModel @see DefaultComboBoxModel @beaninfo attribute: isContainer false description: A combination of a text field and a drop-down list. @version 1.113 01114 02/2812/02 @author Arnaud Weber @author Mark Davidson


Class JComponent, void disable()

Overridden@deprecated to ensureAs of AccessibilityJDK support.version Please1.1 usereplaced {@alinkby java.awt.Component.setEnable(boolean)}.
Class JComponent, void enable()

Overridden@deprecated to ensureAs of AccessibilityJDK support.version Please1.1 usereplaced {@alinkby java.awt.Component.setEnable(boolean)}.
Class JComponent, TransferHandler getTransferHandler()

Gets the transferHandler property. @return the value of the transferHandler property @see TransferHandler @see #setTransferHandler @since 1.4
Class JComponent, boolean isMaximumSizeSet()

Returns true if the maximum size has been set to a non-null value otherwise returns false. @return true if maximumSize is non-null false otherwise @since 1.3
Class JComponent, boolean isMinimumSizeSet()

Returns true if the minimum size has been set to a non-null value otherwise returns false. @return true if minimumSize is non-null false otherwise @since 1.3
Class JComponent, boolean isPreferredSizeSet()

Returns true if the preferred size has been set to a non-null value otherwise returns false. @return true if preferredSize is non-null false otherwise @since 1.3
Class JComponent, void setTransferHandler(TransferHandler)

Sets the transferHandler property which is null if the component does not support data transfer operations.

If newHandler is not null and the system property suppressSwingDropSupport is not true this will install a DropTarget on the JComponent. The default for the system property is false so that a DropTarget will be added. @param newHandler mechanism for transfer of data to and from the component @see TransferHandler @see #getTransferHandler @since 1.4 @beaninfo bound: true hidden: true description: Mechanism for transfer of data to and from the component


Class JDialog

The main class for creating a dialog window. You can use this class to create a custom dialog or invoke the many class methods in JOptionPane to create a variety of standard dialogs. For information about creating dialogs see The Java Tutorial section How to Make Dialogs.

The JDialog component contains a JRootPane as its only child. The contentPane should be the parent of any children of the JDialog. From the older java.awt.Window object you would normally do something like this:

 dialog.add(child); 
Using JDialog the proper semantic is:
 dialog.getContentPane().add(child); 
The same principle holds true for setting layout managers removing components listing children etc. All these methods should normally be sent to the contentPane instead of to the JDialog. The contentPane is always non-null. Attempting to set it to null generates an exception. The default contentPane has a BorderLayout manager set on it.

Please see the JRootPane documentation for a complete description of the contentPane glassPane and layeredPane components.

In a multi-screen environment you can create a JDialog on a different screen device than its owner. See java.awt.Frame for more information.

For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JDialog key assignments.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @see JOptionPane @see JRootPane @beaninfo attribute: isContainer true attribute: containerDelegate getContentPane description: A toplevel window for creating dialog boxes. @version 1.6668 12/03/0120/02 @author David Kloba @author James Gosling @author Scott Violet

Class JDialog, void setContentPane(Container)

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. @see JRootPane @param contentPane the contentPane object for this dialog @exception java.awt.IllegalComponentStateException (a runtime exception) if the content pane parameter is null @see #getContentPane @see RootPaneContainer#setContentPane @beaninfo hidden: true description: The client area of the dialog where child components are normally inserted.

Class JDialog, void setDefaultLookAndFeelDecorated(boolean)

Provides a hint as to whether or not newly created JDialogs 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 JDialogs will have their Window decorations provided by the current LookAndFeel. Otherwise newly created JDialogs will have their Window decorations provided by the current window manager.

You can get the same effect on a single JDialog by doing the following:

 JDialog dialog = new JDialog(); dialog.setUndecorated(true); dialog.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG); 
@param defaultLookAndFeelDecorated A hint as to whether or not current look and feel should provide window decorations @see javax.swing.LookAndFeel.#getSupportsWindowDecorations @since 1.4

Class JEditorPane

A text component to edit various kinds of content. You can find how-to information and examples of using editor panes in Using Text Components a section in The Java Tutorial.

This component uses implementations of the EditorKit to accomplish its behavior. It effectively morphs into the proper kind of text editor for the kind of content it is given. The content type that editor is bound to at any given time is determined by the EditorKit currently installed. If the content is set to a new URL its type is used to determine the EditorKit that should be used to load the content.

By default the following types of content are known:

text/plain
Plain text which is the default the type given isn't recognized. The kit used in this case is an extension of DefaultEditorKit that produces a wrapped plain text view.
text/html
HTML text. The kit used in this case is the class javax.swing.text.html.HTMLEditorKit which provides HTML 3.2 support.
text/rtf
RTF text. The kit used in this case is the class javax.swing.text.rtf.RTFEditorKit which provides a limited support of the Rich Text Format.

There are several ways to load content into this component.

  1. The setText method can be used to initialize the component from a string. In this case the current EditorKit will be used and the content type will be expected to be of this type.
  2. The read method can be used to initialize the component from a Reader. Note that if the content type is HTML relative references (e.g. for things like images) can't be resolved unless the <base> tag is used or the Base property on HTMLDocument is set. In this case the current EditorKit will be used and the content type will be expected to be of this type.
  3. The setPage method can be used to initialize the component from a URL. In this case the content type will be determined from the URL and the registered EditorKit for that content type will be set.

For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JEditorPane key assignments.

Some kinds of content may provide hyperlink support by generating hyperlink events. The HTML EditorKit will generate hyperlink events if the JEditorPane is not editable (JEditorPane.setEditable(false); has been called). If HTML frames are embedded in the document the typical response would be to change a portion of the current document. The following code fragment is a possible hyperlink listener implementation that treats HTML frame events specially and simply displays any other activated hyperlinks.

   class Hyperactive implements HyperlinkListener {     public void hyperlinkUpdate(HyperlinkEvent e) {   if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {   JEditorPane pane = (JEditorPane) e.getSource();   if (e instanceof HTMLFrameHyperlinkEvent) {   HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent)e;   HTMLDocument doc = (HTMLDocument)pane.getDocument();   doc.processHTMLFrameHyperlinkEvent(evt);   } else {   try {   pane.setPage(e.getURL());   } catch (Throwable t) {   t.printStackTrace();   }   }   }   }   } 

Culturally dependent information in some documents is handled through a mechanism called character encoding. Character encoding is an unambiguous mapping of the members of a character set (letters ideographs digits symbols or control functions) to specific numeric code values. It represents the way the file is stored. Example character encodings are ISO-8859-1 ISO-8859-5 Shift-jis Euc-jp and UTF-8. When the file is passed to an user agent (JEditorPane) it is converted to the document character set (ISO-10646 aka Unicode).

There are multiple ways to get a character set mapping to happen with JEditorPane.

  1. One way is to specify the character set as a parameter of the MIME type. This will be established by a call to the setContentType method. If the content is loaded by the setPage method the content type will have been set according to the specification of the URL. It the file is loaded directly the content type would be expected to have been set prior to loading.
  2. Another way the character set can be specified is in the document itself. This requires reading the document prior to determining the character set that is desired. To handle this it is expected that the EditorKit.read operation throw a ChangedCharSetException which will be caught. The read is then restarted with a new Reader that uses the character set specified in the ChangedCharSetException (which is an IOException).

Newlines
For a discussion on how newlines are handled see DefaultEditorKit.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @beaninfo attribute: isContainer false description: A text component to edit various types of content. @author Timothy Prinzing @version 1.113 12115 04/03/0102


Class JFileChooser

JFileChooser provides a simple mechanism for the user to choose a file. For information about using JFileChooser see How to Use File Choosers a section in The Java Tutorial.

The following code pops up a file chooser for the user's home directory that sees only .jpg and .gif images:

 JFileChooser chooser = new JFileChooser(); // Note: source for ExampleFileFilter can be found in FileChooserDemo // under the demo/jfc directory in the Java 2 SDK Standard Edition. ExampleFileFilter filter = new ExampleFileFilter(); filter.addExtension("jpg"); filter.addExtension("gif"); filter.setDescription("JPG & GIF Images"); chooser.setFileFilter(filter); int returnVal = chooser.showOpenDialog(parent); if(returnVal == JFileChooser.APPROVE_OPTION) { System.out.println("You chose to open this file: " + chooser.getSelectedFile().getName()); } 
@beaninfo attribute: isContainer false description: A component which allows for the interactive selection of a file. @version 1.92 1296 04/0311/0102 @author Jeff Dinkins
Class JFileChooser, FileFilter getAcceptAllFileFilter()

Returns the AcceptAll file filter. For example on Win32Microsoft Windows this would be All Files (*.*).
Class JFileChooser, void setMultiSelectionEnabled(boolean)

Sets the file chooser to allow multiple file selections. NOTE: this functionality@param is not yet implemented in the currentb true if multiple files may be L&Fs.selected @beaninfo bound: true description: Sets multiple file selection mode. @see #isMultiSelectionEnabled

Class JFormattedTextField

JFormattedTextField extends JTextField adding support for formatting arbitrary values as well as retrieving a particular object once the user has edited the text. The following illustrates configuring a JFormattedTextField to edit dates:
 JFormattedTextField ftf = new JFormattedTextField(); ftf.setValue(new Date()); 

Once a JFormattedTextField has been created you can listen for editing changes by way of adding a PropertyChangeListener and listening for PropertyChangeEvents with the property name value.

JFormattedTextField allows configuring what action should be taken when focus is lost. The possible configurations are:
JFormattedTextField.REVERT Revert the display to match that of getValue possibly losing the current edit.
JFormattedTextField.COMMIT Commits the current value. If the value being edited isn't considered a legal value by the AbstractFormatter that is a ParseException is thrown then the value will not change and then edited value will persist.
JFormattedTextField.COMMIT_OR_REVERT Similar to COMMIT but if the value isn't legal behave like REVERT.
JFormattedTextField.PERSIST Do nothing don't obtain a new AbstractFormatter and don't update the value.
The default is JFormattedTextField.COMMIT_OR_REVERT refer to #setFocusLostBehavior for more information on this.

JFormattedTextField allows the focus to leave even if the currently edited value is invalid. To lock the focus down while the JFormattedTextField is an invalid edit state you can attach an InputVerifier. The following code snippet shows a potential implementation of such an InputVerifier:

 public class FormattedTextFieldVerifier extends InputVerifier { public boolean verify(JComponent input) { if (input instanceof JFormattedTextField) { JFormattedTextField ftf = (JFormattedTextField)input; AbstractFormatter formatter = ftf.getFormatter(); if (formatter = null) { String text = ftf.getText(); try { formatter.stringToValue(text); return true; } catch (ParseException pe) { return false; } } } return true; } public boolean shouldYieldFocus(JComponent input) { return verify(input); } } 

Alternatively you could invoke commitEdit which would also commit the value.

JFormattedTextField does not do the formatting it self rather formatting is done through an instance of JFormattedTextField.AbstractFormatter which is obtained from an instance of JFormattedTextField.AbstractFormatterFactory. Instances of JFormattedTextField.AbstractFormatter are notified when they become active by way of the install method at which point the JFormattedTextField.AbstractFormatter can install whatever it needs to typically a DocumentFilter. Similarly when JFormattedTextField no longer needs the AbstractFormatter it will invoke uninstall.

JFormattedTextField typically queries the AbstractFormatterFactory for an AbstractFormat when it gains or loses focus. Although this can change based on the focus lost policy. If the focus lost policy is JFormattedTextField.PERSIST and the JFormattedTextField has been edited the AbstractFormatterFactory will not be queried until the value has been commited. Similarly if the focus lost policy is JFormattedTextField.COMMIT and an exception is thrown from stringToValue the AbstractFormatterFactory will not be querired when focus is lost or gained.

JFormattedTextField.AbstractFormatter is also responsible for determining when values are commited to the JFormattedTextField. Some JFormattedTextField.AbstractFormatters will make new values available on every edit and others will never commit the value. You can force the current value to be obtained from the current JFormattedTextField.AbstractFormatter by way of invoking commitEdit. commitEdit will be invoked whenever return is pressed in the JFormattedTextField.

If an AbstractFormatterFactory has not been explicitly set one will be set based on the Class of the value type after setValue has been invoked (assuming value is non-null). For example in the following code an appropriate AbstractFormatterFactory and AbstractFormatter will be created to handle formatting of numbers:

 JFormattedTextField tf = new JFormattedTextField(); tf.setValue(new Number(100)); 

Warning: As the AbstractFormatter will typically install a DocumentFilter on the Document and a NavigationFilter on the JFormattedTextField you should not install your own. If you do you are likely to see odd behavior in that the editing policy of the AbstractFormatter will not be enforced.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @version 1.12 1213 02/0311/0102 @since 1.4


Class JFrame

An extended version of java.awt.Frame that adds support for the JFC/Swing component architecture. You can find task-oriented documentation about using JFrame in The Java Tutorial in the section How to Make Frames.

The JFrame class is slightly incompatible with Frame. Like all other JFC/Swing top-level containers a JFrame contains a JRootPane as its only child. The content pane provided by the root pane should as a rule contain all the non-menu components displayed by the JFrame. This is different from the AWT Frame case. For example to add a child to an AWT frame you'd write:

 frame.add(child); 
However using JFrame you need to add the child to the JFrame's content pane instead:
 frame.getContentPane().add(child); 
The same is true for setting layout managers removing components listing children and so on. All these methods should normally be sent to the content pane instead of the JFrame itself. The content pane will always be non-null. Attempting to set it to null will cause the JFrame to throw an exception. The default content pane will have a BorderLayout manager set on it.

Unlike a Frame a JFrame has some notion of how to respond when the user attempts to close the window. The default behavior is to simply hide the JFrame when the user closes the window. To change the default behavior you invoke the method #setDefaultCloseOperation To make the JFrame behave the same as a Frame instance use setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE).

For more information on content panes and other features that root panes provide see Using Top-Level Containers in The Java Tutorial.

In a multi-screen environment you can create a JFrame on a different screen device. See java.awt.Frame for more information.

For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JFrame key assignments.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @see JRootPane @see #setDefaultCloseOperation @see java.awt.event.WindowListener#windowClosing @beaninfo attribute: isContainer true attribute: containerDelegate getContentPane description: A toplevel window which can be minimized to an icon. @version 1.90 1293 04/0318/0102 @author Jeff Dinkins @author Georges Saab @author David Kloba

Class JFrame, void setContentPane(Container)

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. @param contentPane the contentPane object for this frame @exception java.awt.IllegalComponentStateException (a runtime exception) if the content pane parameter is null @see #getContentPane @see RootPaneContainer#setContentPane @see JRootPane @beaninfo hidden: true description: The client area of the frame where child components are normally inserted.

Class JFrame, void setDefaultCloseOperation(int)

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:

The value is set to HIDE_ON_CLOSE by default. @param operation the operation which should be performed when the user closes the frame @exception IllegalArgumentException if defaultCloseOperation value isn't one of the above valid values @see #addWindowListener @see #getDefaultCloseOperation @see WindowConstants @throws SecurityException If EXIT_ON_CLOSE has been specified and the SecurityManager will not allow the caller to invoke System.exit. @see java.lang.Runtime#exit(int) @beaninfo preferred: true bound: true enum: DO_NOTHING_ON_CLOSE WindowConstants.DO_NOTHING_ON_CLOSE HIDE_ON_CLOSE WindowConstants.HIDE_ON_CLOSE DISPOSE_ON_CLOSE WindowConstants.DISPOSE_ON_CLOSE EXIT_ON_CLOSE WindowConstants.EXIT_ON_CLOSE description: The frame's default close operation.

Class JFrame, void setDefaultLookAndFeelDecorated(boolean)

Provides a hint as to whether or not newly created JFrames 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 JFrames will have their Window decorations provided by the current LookAndFeel. Otherwise newly created JFrames 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); 
@param defaultLookAndFeelDecorated A hint as to whether or not current look and feel should provide window decorations @see javax.swing.LookAndFeel.#getSupportsWindowDecorations @since 1.4

Class JInternalFrame

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. So to create a JInternalFrame that has a number of buttons arranged with the content pane's default BorderLayout object you might do something like this:

 JComponent c = (JComponent) internalFrame.getContentPane(); c.add(new JButton() BorderLayout.NORTH); c.add(new JButton() BorderLayout.CENTER); 
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.

For the keyboard keys used by this component in the standard look and feel renditions see the JInternalFrame key assignments.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @see InternalFrameEvent @see JDesktopPane @see DesktopManager @see JInternalFrame.JDesktopIcon @see JRootPane @version 1.135137 12/0310/01 @author David Kloba @author Rich Schiavi @beaninfo attribute: isContainer true attribute: containerDelegate getContentPane description: A frame container which is contained within another window.

Class JInternalFrame, void pack()

Causes subcomponents of this JInternalFrame to be laid out at their preferred size. Internal frames that are iconized or maximized are first restored and then packed. If the internal frame is unable to be restored its state is not changed and will not be packed. @see java.awt.Window#pack

Class JLabel

A display area for a short text string or an image or both. A label does not react to input events. As a result it cannot get the keyboard focus. A label can however display a keyboard alternative as a convenience for a nearby component that has a keyboard alternative but can't display it.

A JLabel object can display either text an image or both. You can specify where in the label's display area the label's contents are aligned by setting the vertical and horizontal alignment. By default labels are vertically centered in their display area. Text-only labels are leading edge aligned by default; image-only labels are horizontally centered by default.

You can also specify the position of the text relative to the image. By default text is on the trailing edge of the image with the text and image vertically aligned.

A label's leading and trailing edge are determined from the value of its java.awt.ComponentOrientation property. At present the default ComponentOrientation setting maps the leading edge to left and the trailing edge to right.

Finally you can use the setIconTextGap method to specify how many pixels should appear between the text and the image. The default is 4 pixels.

See How to Use Labels in The Java Tutorial for further documentation.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @beaninfo attribute: isContainer false description: A component that displays a short string and an icon. @version 1.110 12111 04/0312/0102 @author Hans Muller


Class JList

A component that allows the user to select one or more objects from a list. A separate model ListModel represents the contents of the list. It's easy to display an array or vector of objects using a JList constructor that builds a ListModel instance for you:
 // Create a JList that displays the strings in data[] String[] data = {"one" "two" "three" "four"}; JList dataList = new JList(data); // The value of the JList model property is an object that provides // a read-only view of the data. It was constructed automatically. for(int i = 0; i  

JList doesn't support scrolling directly. To create a scrolling list you make the JList the viewport view of a JScrollPane. For example:

 JScrollPane scrollPane = new JScrollPane(dataList); // Or in two steps: JScrollPane scrollPane = new JScrollPane(); scrollPane.getViewport().setView(dataList); 

By default the JList selection model allows any combination of items to be selected at a time using the constant MULTIPLE_INTERVAL_SELECTION. The selection state is actually managed by a separate delegate object an instance of ListSelectionModel. However JList provides convenient properties for managing the selection.

 String[] data = {"one" "two" "three" "four"}; JList dataList = new JList(data); dataList.setSelectedIndex(1); // select "two" dataList.getSelectedValue(); // returns "two" 

The contents of a JList can be dynamic in other words the list elements can change value and the size of the list can change after the JList has been created. The JList observes changes in its model with a swing.event.ListDataListener implementation. A correct implementation of ListModel notifies it's listeners each time a change occurs. The changes are characterized by a swing.event.ListDataEvent which identifies the range of list indices that have been modified added or removed. Simple dynamic-content JList applications can use the DefaultListModel class to store list elements. This class implements the ListModel interface and provides the java.util.Vector API as well. Applications that need to provide custom ListModel implementations can subclass AbstractListModel which provides basic ListDataListener support. For example:

 // This list model has about 2^16 elements. Enjoy scrolling.  ListModel bigData = new AbstractListModel() { public int getSize() { return Short.MAX_VALUE; } public Object getElementAt(int index) { return "Index " + index; } }; JList bigDataList = new JList(bigData); // We don't want the JList implementation to compute the width // or height of all of the list cells so we give it a string // that's as big as we'll need for any cell. It uses this to // compute values for the fixedCellWidth and fixedCellHeight // properties. bigDataList.setPrototypeCellValue("Index 1234567890"); 

JList uses a java.awt.Component provided by a delegate called the cellRendererer to paint the visible cells in the list. The cell renderer component is used like a "rubber stamp" to paint each visible row. Each time the JList needs to paint a cell it asks the cell renderer for the component moves it into place using setBounds() and then draws it by calling its paint method. The default cell renderer uses a JLabel component to render the string value of each component. You can substitute your own cell renderer using code like this:

 // Display an icon and a string for each object in the list.  class MyCellRenderer extends JLabel implements ListCellRenderer { final static ImageIcon longIcon = new ImageIcon("long.gif"); final static ImageIcon shortIcon = new ImageIcon("short.gif"); // This is the only method defined by ListCellRenderer. // We just reconfigure the JLabel each time we're called. public Component getListCellRendererComponent( JList list Object value // value to display int index // cell index boolean isSelected // is the cell selected boolean cellHasFocus) // the list and the cell have the focus { String s = value.toString(); setText(s); setIcon((s.length() > 10) longIcon : shortIcon); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } setEnabled(list.isEnabled()); setFont(list.getFont()); setOpaque(true); return this; } } String[] data = {"one" "two" "three" "four"}; JList dataList = new JList(data); dataList.setCellRenderer(new MyCellRenderer()); 

JList doesn't provide any special support for handling double or triple (or N) mouse clicks however it's easy to handle them using a MouseListener. Use the JList method locationToIndex() to determine what cell was clicked. For example:

 final JList list = new JList(dataModel); MouseListener mouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { int index = list.locationToIndex(e.getPoint()); System.out.println("Double clicked on Item " + index); } } }; list.addMouseListener(mouseListener); 
Note that in this example the dataList is final because it's referred to by the anonymous MouseListener class.

For the keyboard keys used by this component in the standard look and feel (L&F) renditions see the JList key assignments.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder

See How to Use Lists in The Java Tutorial for further documentation. Also see the article Advanced JList Programming in The Swing Connection.

@see ListModel @see AbstractListModel @see DefaultListModel @see ListSelectionModel @see DefaultListSelectionModel @see ListCellRenderer @beaninfo attribute: isContainer false description: A component which allows for the selection of one or more objects from a list. @version 1.101 12103 02/0311/0102 @author Hans Muller

Class JList, void addListSelectionListener(ListSelectionListener)

Adds a listener to the list that's notified each time a change to the selection occurs. Listeners added directly to the JList will have their ListSelectionEvent.getSource() == this JList (instead of the ListSelectionModel). @param listener the ListSelectionListener to add @see #getSelectionModel @see #getListSelectionListeners
Class JList, ListSelectionListener[] getListSelectionListeners()

Returns an array of all the ListSelectionListeners added to this JList with addListSelectionListener(). @return all of the ListSelectionListeners added or an empty array if no listeners have been added @see #addListSelectionListener @since 1.4

Class JMenu

An implementation of a menu -- a popup window containing JMenuItems that is displayed when the user selects an item on the JMenuBar. In addition to JMenuItems a JMenu can also contain JSeparators.

In essence a menu is a button with an associated JPopupMenu. When the "button" is pressed the JPopupMenu appears. If the "button" is on the JMenuBar the menu is a top-level window. If the "button" is another menu item then the JPopupMenu is "pull-right" menu.

For information and examples of using menus see How to Use Menus a section in The Java Tutorial. For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JMenu key assignments.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @beaninfo attribute: isContainer true description: A popup window containing menu items displayed in a menu bar. @version 1.164 12166 04/0318/0102 @author Georges Saab @author David Karlton @author Arnaud Weber @see JMenuItem @see JSeparator @see JMenuBar @see JPopupMenu


Class JMenuItem

An implementation of an item in a menu. A menu item is essentially a button sitting in a list. When the user selects the "button" the action associated with the menu item is performed. A JMenuItem contained in a JPopupMenu performs exactly that function.

For further documentation and for examples see How to Use Menus in The Java Tutorial. For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JMenuItem key assignments.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @beaninfo attribute: isContainer false description: An item which can be selected in a menu. @version 1.106 12107 02/0311/0102 @author Georges Saab @author David Karlton @see JPopupMenu @see JMenu @see JCheckBoxMenuItem @see JRadioButtonMenuItem


Class JPopupMenu

An implementation of a popup menu -- a small window that pops up and displays a series of choices. A JPopupMenu is used for the menu that appears when the user selects an item on the menu bar. It is also used for "pull-right" menu that appears when the selects a menu item that activates it. Finally a JPopupMenu can also be used anywhere else you want a menu to appear. For example when the user right-clicks in a specified area.

For information and examples of using popup menus see How to Use Menus in The Java Tutorial. For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JPopupMenu key assignments.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @beaninfo attribute: isContainer false description: A small window that pops up and displays a series of choices. @version 1.169176 12/05/0107/02 @author Georges Saab @author David Karlton @author Arnaud Weber

Class JPopupMenu, void setLightWeightPopupEnabled(boolean)

Sets the value of the lightWeightPopupEnabled property which by default is true. By default when a look and feel displays a popup it can choose to use a lightweight (all-Java) popup. Lightweight popup windows are more efficient than heavyweight (native peer) windows but lightweight and heavyweight components do not mix well in a GUI. If your application mixes lightweight and heavyweight components you should disable lightweight popups. Some look and feels might always use heavyweight popups no matter what the value of this property. @param aFlag false to disable lightweight popups @beaninfo description: Determines whether lightweight popups are used when possible expert: true @see #isLightWeightPopupEnabled

Class JProgressBar

A component that by default displays an integer value within a bounded interval. A progress bar typically communicates the progress of some work by displaying its percentage of completion and possibly a textual display of this percentage.

To indicate that a task of unknown length is executing you can put a progress bar into indeterminate mode. While the bar is in indeterminate mode it animates constantly to show that work is occurring. As soon as you can determine the task's length and amount of progress you should update the progress bar's value and switch it back to determinate mode.

Here is an example of creating a progress bar where task is an object that returns information about the progress of some work:

 progressBar = new JProgressBar(0 task.getLengthOfTask()); progressBar.setValue(0); progressBar.setStringPainted(true); 
Here is an example of updating the value of the progress bar:
 progressBar.setValue(task.getCurrent()); 
Here is an example of putting a progress bar into indeterminate mode and then switching back to determinate mode once the length of the task is known:
 progressBar = new JProgressBar(); ...//when the task of (initially) unknown length begins: progressBar.setIndeterminate(true); ...//do some work; get length of task... progressBar.setMaximum(newLength); progressBar.setValue(newValue); progressBar.setIndeterminate(false); 

For complete examples and further documentation see How to Monitor Progress a section in The Java Tutorial.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @see javax.swing.plaf.basic.BasicProgressBarUI @beaninfo attribute: isContainer false description: A component that displays an integer value. @version 1.8990 12/03/0112/02 @author Michael C. Albers @author Kathy Walrath

Class JProgressBar, void setIndeterminate(boolean)

Sets the indeterminate property of the progress bar which determines whether the progress bar is in determinate or indeterminate mode. By default the progress bar is determinate and this method returns false. An indeterminate progress bar continuously displays animation indicating that an operation of unknown length is occurring. By default this property is false. Some look and feels might not support indeterminate progress bars; they will ignore this property.

See How to Monitor Progress for examples of using indeterminate progress bars. @param newValue true if the progress bar should change to indeterminate mode; false if it should revert to normal. @see #isIndeterminate @see javax.swing.plaf.basic.BasicProgressBarUI @since 1.4 @beaninfo bound: true attribute: visualUpdate true description: Set whether the progress bar is indeterminate (true) or normal (false).


Class JRootPane

A lightweight container used behind the scenes by JFrame JDialog JWindow JApplet and JInternalFrame. For task-oriented information on functionality provided by root panes see How to Use Root Panes a section in The Java Tutorial.

The following image shows the relationships between the classes that use root panes.

The "heavyweight" components (those that delegate to a peer or native component on the host system) are shown with a darker heavier box. The four heavyweight JFC/Swing containers (JFrame JDialog JWindow and JApplet) are shown in relation to the AWT classes they extend. These four components are the only heavyweight containers in the Swing library. The lightweight container JRootPaneJInternalPane is also shown. All five of these JFC/Swing containers implement the RootPaneContainer interface and they all delegate their operations to a JRootPane (shown with a little "handle" on top).
Note: The JComponent method getRootPane can be used to obtain the JRootPane that contains a given component.
The diagram at right shows the structure of a JRootPane. A JRootpane is made up of a glassPane an optional menuBar and a contentPane. (The JLayeredPane manages the menuBar and the contentPane.) The glassPane sits over the top of everything where it is in a position to intercept mouse movements. Since the glassPane (like the contentPane) can be an arbitrary component it is also possible to set up the glassPane for drawing. Lines and images on the glassPane can then range over the frames underneath without being limited by their boundaries.

Although the menuBar component is optional the layeredPane contentPane and glassPane always exist. Attempting to set them to null generates an exception.

To add components to the JRootPane (other than the optional menu bar) you add the object to the contentPane of the JRootPane like this:

 rootPane.getContentPane().add(child); 
The same principle holds true for setting layout managers removing components listing children etc. All these methods are invoked on the contentPane instead of on the JRootPane.
Note: The default layout manager for the contentPane is a BorderLayout manager. However the JRootPane uses a custom LayoutManager. So when you want to change the layout manager for the components you added to a JRootPane be sure to use code like this:
 rootPane.getContentPane().setLayout(new BoxLayout()); 
If a JMenuBar component is set on the JRootPane it is positioned along the upper edge of the frame. The contentPane is adjusted in location and size to fill the remaining area. (The JMenuBar and the contentPane are added to the layeredPane component at the JLayeredPane.FRAME_CONTENT_LAYER layer.)

The layeredPane is the parent of all children in the JRootPane -- both as the direct parent of the menu and the grandparent of all components added to the contentPane. It is an instance of JLayeredPane which provides the ability to add components at several layers. This capability is very useful when working with menu popups dialog boxes and dragging -- situations in which you need to place a component on top of all other components in the pane.

The glassPane sits on top of all other components in the JRootPane. That provides a convenient place to draw above all other components and makes it possible to intercept mouse events which is useful both for dragging and for drawing. Developers can use setVisible on the glassPane to control when the glassPane displays over the other children. By default the glassPane is not visible.

The custom LayoutManager used by JRootPane ensures that:

  1. The glassPane fills the entire viewable area of the JRootPane (bounds - insets).
  2. The layeredPane fills the entire viewable area of the JRootPane. (bounds - insets)
  3. The menuBar is positioned at the upper edge of the layeredPane.
  4. The contentPane fills the entire viewable area minus the menuBar if present.
Any other views in the JRootPane view hierarchy are ignored.

If you replace the LayoutManager of the JRootPane you are responsible for managing all of these views. So ordinarily you will want to be sure that you change the layout manager for the contentPane rather than for the JRootPane itself

The painting architecture of Swing requires an opaque JComponent to exist in the containment hieararchy above all other components. This is typically provided by way of the content pane. If you replace the content pane it is recommended that you make the content pane opaque by way of setOpaque(true). Additionally if the content pane overrides paintComponent it will need to completely fill in the background in an opaque color in paintComponent.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @see JLayeredPane @see JMenuBar @see JWindow @see JFrame @see JDialog @see JApplet @see JInternalFrame @see JComponent @see BoxLayout @see Mixing Heavy and Light Components @version 1.7780 12/03/0120/02 @author David Kloba

Class JRootPane, void setContentPane(Container)

Sets the content pane -- the container that holds the components parented by the root pane.

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. @param content the Container to use for component-contents @exception java.awt.IllegalComponentStateException (a runtime exception) if the content pane parameter is null


Class JSpinner

A single line input field that lets the user select a number or an object value from an ordered sequence. Spinners typically provide a pair of tiny arrow buttons for stepping through the elements of the sequence. The keyboard up/down arrow keys also cycle through the elements. The user may also be allowed to type a (legal) value directly into the spinner. Although combo boxes provide similar functionality spinners are sometimes preferred because they don't require a drop down list that can obscure important data.

A JSpinner's sequence value is defined by its SpinnerModel. The model can be specified as a constructor argument and changed with the model property. SpinnerModel classes for some common types are provided: SpinnerListModel SpinnerNumberModel and SpinnerDateModel.

A JSpinner has a single child component that's responsible for displaying and potentially changing the current element or value of the model which is called the editor. The editor is created by the JSpinner's constructor and can be changed with the editor property. The JSpinner's editor stays in sync with the model by listening for ChangeEvents.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @beaninfo attribute: isContainer false description: A single line input field that lets the user select a number or an object value from an ordered set. @see SpinnerModel @see AbstractSpinnerModel @see SpinnerListModel @see SpinnerNumberModel @see SpinnerDateModel @see JFormattedTextField @version 1.22 1226 04/0318/0102 @author Hans Muller @since 1.4

Class JSpinner, JComponent createEditor(SpinnerModel)

This method is called by the constructors to create the JComponent that displays the current value of the sequence. The editor may also allow the user to enter an element of the sequence directly. An editor must listen for ChangeEvents on the model and keep the value it displays in sync with the value of the model.

Subclasses may override this method to add support for new SpinnerModel classes. Alternatively one can just replace the editor created here with the setEditor method. The default mapping from model type to editor is:

@return a component that displays the current value of the sequence @param model the value of getModel @see #getModel @see #setEditor
Class JSpinner, void fireStateChanged()

Sends a ChangeEvent whose source is this JSpinner to each ChangeListener. When a ChangeListener has been added to the spinner this method method is called each time a ChangeEvent is received from the model. @see #addChangeListener @see #removeChangeListener @see EventListenerList

Class JTabbedPane

A component that lets the user switch between a group of components by clicking on a tab with a given title and/or icon. For examples and information on using tabbed panes see How to Use Tabbed Panes a section in The Java Tutorial.

Tabs/components are added to a TabbedPane object by using the addTab and insertTab methods. A tab is represented by an index corresponding to the position it was added in where the first tab has an index equal to 0 and the last tab has an index equal to the tab count minus 1.

The TabbedPane uses a SingleSelectionModel to represent the set of tab indices and the currently selected index. If the tab count is greater than 0 then there will always be a selected index which by default will be initialized to the first tab. If the tab count is 0 then the selected index will be -1.

For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JTabbedPane key assignments.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @beaninfo attribute: isContainer true description: A component which provides a tab folder metaphor for displaying one component from a set of components. @version 1.124 12127 07/0322/0102 @author Dave Moore @author Philip Milne @author Amy Fowler @see SingleSelectionModel

Class JTabbedPane, constructor JTabbedPane()

Creates an empty TabbedPane with a default tab placement of JTabbedPane.TOP and default tab layout policy of JTabbedPane.WRAP_TAB_LAYOUT. @see #addTab
Class JTabbedPane, constructor JTabbedPane(int)

Creates an empty TabbedPane with the specified tab placement of either: JTabbedPane.TOP JTabbedPane.BOTTOM JTabbedPane.LEFT or JTabbedPane.RIGHT and a default tab layout policy of JTabbedPane.WRAP_TAB_LAYOUT. @param tabPlacement the placement for the tabs relative to the content @see #addTab
Class JTabbedPane, void setTabLayoutPolicy(int)

Sets the policy which the tabbedpane will use in laying out the tabs when all the tabs will not fit within a single run. Possible values are: The default value if not set by the UI is JTabbedPane.WRAP_TAB_LAYOUT.

Some look and feels might only support a subset of the possible layout policies in which case the value of this property may be ignored. @param layoutPolicy the policy used to layout the tabs @exception IllegalArgumentException if layoutPolicy value isn't one of the above valid values @see #getTabLayoutPolicy @since 1.4 @beaninfo preferred: true bound: true attribute: visualUpdate true enum: WRAP_TAB_LAYOUT JTabbedPane.WRAP_TAB_LAYOUT SCROLL_TAB_LAYOUT JTabbedPane.SCROLL_TAB_LAYOUT description: The tabbedpane's policy for laying out the tabs

Class JTabbedPane, int SCROLL_TAB_LAYOUT

TheTab tab layout policy for providing a scrollable regionsubset of available tabs when all the tabs will not fit within a single run. AIf pair ofall scroll buttons are provided for the user to controlthe tabs do not fit within a single run the scrolling. The placementlook of the scroll buttons is determined by the look and feeland feel will provide a way to navigate to hidden tabs.

Class JTable

The JTable is used to display and edit regular two-dimensional tables of cells. See How to Use Tables in The Java Tutorial for task-oriented documentation and examples of using JTable.

The JTable has many facilities that make it possible to customize its rendering and editing but provides defaults for these features so that simple tables can be set up easily. For example to set up a table with 10 rows and 10 columns of numbers:

 TableModel dataModel = new AbstractTableModel() { public int getColumnCount() { return 10; } public int getRowCount() { return 10;} public Object getValueAt(int row int col) { return new Integer(row*col); } }; JTable table = new JTable(dataModel); JScrollPane scrollpane = new JScrollPane(table); 

Note that if you wish to use a JTable in a standalone view (outside of a JScrollPane) and want the header displayed you can get it using #getTableHeader and display it separately.

When designing applications that use the JTable it is worth paying close attention to the data structures that will represent the table's data. The DefaultTableModel is a model implementation that uses a Vector of Vectors of Objects to store the cell values. As well as copying the data from an application into the DefaultTableModel it is also possible to wrap the data in the methods of the TableModel interface so that the data can be passed to the JTable directly as in the example above. This often results in more efficient applications because the model is free to choose the internal representation that best suits the data. A good rule of thumb for deciding whether to use the AbstractTableModel or the DefaultTableModel is to use the AbstractTableModel as the base class for creating subclasses and the DefaultTableModel when subclassing is not required.

The "TableExample" directory in the demo area of the source distribution gives a number of complete examples of JTable usage covering how the JTable can be used to provide an editable view of data taken from a database and how to modify the columns in the display to use specialized renderers and editors.

The JTable uses integers exclusively to refer to both the rows and the columns of the model that it displays. The JTable simply takes a tabular range of cells and uses getValueAt(int int) to retrieve the values from the model during painting.

By default columns may be rearranged in the JTable so that the view's columns appear in a different order to the columns in the model. This does not affect the implementation of the model at all: when the columns are reordered the JTable maintains the new order of the columns internally and converts its column indices before querying the model.

So when writing a TableModel it is not necessary to listen for column reordering events as the model will be queried in its own coordinate system regardless of what is happening in the view. In the examples area there is a demonstration of a sorting algorithm making use of exactly this technique to interpose yet another coordinate system where the order of the rows is changed rather than the order of the columns.

As for all JComponent classes you can use InputMap and ActionMap to associate an Action object with a KeyStroke and execute the action under specified conditions.

For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JTable key assignments.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @beaninfo attribute: isContainer false description: A component which displays data in a two dimensional grid. @version 1.197 12202 07/0315/0102 @author Philip Milne

Class JTable, Rectangle getCellRect(int, int, boolean)

Returns a rectangle for the cell that lies at the intersection of row and column. If includeSpacing is true then the value returned has the full height and width of the row and column specified. If it is false the returned rectangle is inset by the intercell spacing to return the true bounds of the rendering or editing component as it will be set during rendering.

If the column index is valid but the row index is less than zero the method returns a rectangle with the y and height values set appropriately and the x and width values both set to zero. In general when either the row or column indices indicate a cell outside the appropriate range the method returns a rectangle depicting the closest edge of the closest cell that is within the table's range. When both row and column indices are out of range the returned rectangle covers the closest point of the closest cell.

In all cases calculations that use this method to calculate results along one axis will not fail because of anomalies in calculations along the other axis. When the cell is not valid the includeSpacing parameter is ignored. @param row the row index where the desired cell is located @param column the column index where the desired cell is located in the display; this is not necessarily the same as the column index in the data model for the table; the #convertColumnIndexToView(int) method may be used to convert a data model column index to a display column index @param includeSpacing if false return the true cell bounds - computed by subtracting the intercell spacing from the height and widths of the column and row models @return the rectangle containing the cell at location row column


Class JTextArea

A JTextArea is a multi-line area that displays plain text. It is intended to be a lightweight component that provides source compatibility with the java.awt.TextArea class where it can reasonably do so. You can find information and examples of using all the text components in Using Text Components a section in The Java Tutorial.

This component has capabilities not found in the java.awt.TextArea class. The superclass should be consulted for additional capabilities. Alternative multi-line text classes with more capabilities are JTextPane and JEditorPane.

The java.awt.TextArea internally handles scrolling. JTextArea is different in that it doesn't manage scrolling but implements the swing Scrollable interface. This allows it to be placed inside a JScrollPane if scrolling behavior is desired and used directly if scrolling is not desired.

The java.awt.TextArea has the ability to do line wrapping. This was controlled by the horizontal scrolling policy. Since scrolling is not done by JTextArea directly backward compatibility must be provided another way. JTextArea has a bound property for line wrapping that controls whether or not it will wrap lines. By default the line wrapping property is set to false (not wrapped).

java.awt.TextArea has two properties rows and columns that are used to determine the preferred size. JTextArea uses these properties to indicate the preferred size of the viewport when placed inside a JScrollPane to match the functionality provided by java.awt.TextArea. JTextArea has a preferred size of what is needed to display all of the text so that it functions properly inside of a JScrollPane. If the value for rows or columns is equal to zero the preferred size along that axis is used for the viewport preferred size along the same axis.

The java.awt.TextArea could be monitored for changes by adding a TextListener for TextEvents. In the JTextComponent based components changes are broadcasted from the model via a DocumentEvent to DocumentListeners. The DocumentEvent gives the location of the change and the kind of change if desired. The code fragment might look something like:

 DocumentListener myListener = ; JTextArea myArea = ; myArea.getDocument().addDocumentListener(myListener); 

For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JTextArea key assignments.

Newlines
For a discussion on how newlines are handled see DefaultEditorKit.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @beaninfo attribute: isContainer false description: A multi-line area that displays plain text. @author Timothy Prinzing @version 1.83 1284 04/03/01/02 @see JTextPane @see JEditorPane


Class JTree

A control that displays a set of hierarchical data as an outline. You can find task-oriented documentation and examples of using trees in How to Use Trees a section in The Java Tutorial.

A specific node in a tree can be identified either by a TreePath (an object that encapsulates a node and all of its ancestors) or by its display row where each row in the display area displays one node. An expanded node is onea non-leaf node (as identified by TreeModel.isLeaf(node) returning false) that will displays its children when all its ancestors are expanded. A collapsed node is one which hides them. A hidden node is one which is under a collapsed ancestor. All of a viewable nodes parents are expanded but may or may not be displayed. A displayed node is both viewable and in the display area where it can be seen.

The following JTree methods use "visible" to mean "displayed":

The next group of JTree methods use "visible" to mean "viewable" (under an expanded parent):

If you are interested in knowing when the selection changes implement the TreeSelectionListener interface and add the instance using the method addTreeSelectionListener. valueChanged will be invoked when the selection changes that is if the user clicks twice on the same node valueChanged will only be invoked once.

If you are interested in detecting either double-click events or when a user clicks on a node regardless of whether or not it was selected we recommend you do the following:

 final JTree tree = ...; MouseListener ml = new MouseAdapter() { public void mousePressed(MouseEvent e) { int selRow = tree.getRowForLocation(e.getX() e.getY()); TreePath selPath = tree.getPathForLocation(e.getX() e.getY()); if(selRow = -1) { if(e.getClickCount() == 1) { mySingleClick(selRow selPath); } else if(e.getClickCount() == 2) { myDoubleClick(selRow selPath); } } } }; tree.addMouseListener(ml); 
NOTE: This example obtains both the path and row but you only need to get the one you're interested in.

To use JTree to display compound nodes (for example nodes containing both a graphic icon and text) subclass TreeCellRenderer and use #setCellRenderer to tell the tree to use it. To edit such nodes subclass TreeCellEditor and use #setCellEditor

Like all JComponent classes you can use InputMap and ActionMap to associate an Action object with a KeyStroke and execute the action under specified conditions.

For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JTree key assignments.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @beaninfo attribute: isContainer false description: A component that displays a set of hierarchical data as an outline. @version 1.159 03161 05/0803/02 @author Rob Davis @author Ray Ryan @author Scott Violet

Class JTree, void expandPath(TreePath)

Ensures that the node identified by the specified path is expanded and viewable. If the last item in the path is a leaf this will have no effect. @param path the TreePath identifying a node

Class JViewport

The "viewport" or "porthole" through which you see the underlying information. When you scroll what moves is the viewport. It is like peering through a camera's viewfinder. Moving the viewfinder upwards brings new things into view at the top of the picture and loses things that were at the bottom.

By default JViewport is opaque. To change this use the setOpaque method.

NOTE:We have implemented a faster scrolling algorithm that does not require a buffer to draw in. The algorithm works as follows:

  1. The view and parent view and checked to see if they are JComponents if they aren't stop and repaint the whole viewport.
  2. If the viewport is obscured by an ancestor stop and repaint the whole viewport.
  3. Compute the region that will become visible if it is as big as the viewport stop and repaint the whole view region.
  4. Obtain the ancestor Window's graphics and do a copyArea on the scrolled region.
  5. Message the view to repaint the newly visible region.
  6. The next time paint is invoked on the viewport if the clip region is smaller than the viewport size a timer is kicked off to repaint the whole region.
In general this approach is much faster. Compared to the backing store approach this avoids the overhead of maintaining an offscreen buffer and having to do two copyAreas. Compared to the non backing store case this approach will greatly reduce the painted region.

This approach can cause slower times than the backing store approach when the viewport is obscured by another window or partially offscreen. When another window obscures the viewport the copyArea will copy garbage and a paint event will be generated by the system to inform us we need to paint the newly exposed region. The only way to handle this is to repaint the whole viewport which can cause slower performance than the backing store case. In most applications very rarely will the user be scrolling while the viewport is obscured by another window or offscreen so this optimization is usually worth the performance hit when obscured.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @version 1.102104 12/03/0120/02 @author Hans Muller @author Philip Milne @see JScrollPane


Class Popup

Popups are used to display a Component to the user typically on top of all the other Components in a particular containment hierarchy. Popups have a very small life cycle. Once you have obtained a Popup and hidden it (invoked the hide method) you should no longer invoke any methods on it. This allows the PopupFactory to cache Popups for later use.

The general contract is that if you need to change the size of the Component or location of the Popup you should obtain a new Popup.

Popup does not descend from Component rather implementations of Popup are responsible for creating and maintaining their own Components to render the requested Component to the user.

You typically do not explicitly create an instance of Popup instead obtain one from a PopupFactory. @see PopupFactory @version 1.11 12 04/0302/0102 @since 1.4


Class PopupFactory

PopupFactory as the name implies is used to obtain instances of Popups. Popups are used to display a Component above all other Components in a particular containment hierarchy. The general contract is that once you have obtained a Popup from a PopupFactory you must invoke hide on the Popup. The typical usage is:
 PopupFactory factory = PopupFactory.getSharedInstance(); Popup popup = factory.getPopup(owner contents x y); popup.show(); ... popup.hide(); 
@see Popup @version 1.14 1215 04/0311/0102 @since 1.4

Class RepaintManager

This class manages repaint requests allowing the number of repaints to be minimized for example by collapsing multiple requests into a single repaint for members of a component tree. @version 1.49 1251 04/0318/0102 @author Arnaud Weber

Class ScrollPaneLayout

The layout manager used by JScrollPane. JScrollPaneLayout is responsible for nine components: a viewport two scrollbars a row header a column header and four "corner" components.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @see JScrollPane @see JViewport @version 1.5455 12/0307/01 @author Hans Muller


Class SizeRequirements

For the convenience of layout managers calculates information about the size and position of components. All size and position calculation methods are class methods that take arrays of SizeRequirements as arguments. The SizeRequirements class supports two types of layout:
tiled
The components are placed end-to-end starting either at coordinate 0 (the leftmost or topmost position) or at the coordinate representing the end of the allocated span (the rightmost or bottommost position).
aligned
The components are aligned as specified by each component's X or Y alignment value.

Each SizeRequirements object contains information about either the width (and X alignment) or height (and Y alignment) of a single component or a group of components:

minimum
The smallest reasonable width/height of the component or component group in pixels.
preferred
The natural width/height of the component or component group in pixels.
maximum
The largest reasonable width/height of the component or component group in pixels.
alignment
The X/Y alignment of the component or component group.

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 JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder @see Component#getMinimumSize @see Component#getPreferredSize @see Component#getMaximumSize @see Component#getAlignmentX @see Component#getAlignmentY @version 1.29 1230 04/0317/0102 @author Timothy Prinzing


Class SpinnerModel

A model for a potentially unbounded sequence of object values. This model is similar to ListModel however there are some important differences:

A SpinnerModel has three properties only the first is read/write.

value
The current element of the sequence.
nextValue
The following element or null if value is the last element of the sequence.
previousValue
The preceeding element or null if value is the first element of the sequence.
When the the value property changes ChangeListeners are notified. SpinnerModel may choose to notify the ChangeListeners under other circumstances. @see JSpinner @see AbstractSpinnerModel @see SpinnerListodelSpinnerListModel @see SpinnerNumberModel @see SpinnerDateModel @version 1.34 12/03/0120/02 @author Hans Muller @since 1.4

Class Spring

An instance of the Spring class holds three properties that characterize its behavior: the minimum preferred and maximum values. Each of these properties may be involved in defining its fourth value property based on a series of rules.

An instance of the Spring class can be visualized as a mechanical spring that provides a corrective force as the spring is compressed or stretched away from its preferred value. This force is modelled as linear function of the distance from the preferred value but with two different constants -- one for the compressional force and one for the tensional one. Those constants are specified by the minimum and maximum values of the spring such that a spring at its minimum value produces an equal and opposite force to that which is created when it is at its maximum value. The difference between the preferred and minimum values therefore represents the ease with which the spring can be compressed and the difference between its maximum and preferred values indicates the ease with which the Spring can be extended. See the #sum method for details.

By defining simple arithmetic operations on Springs the behavior of a collection of Springs can be reduced to that of an ordinary (non-compound) Spring. We define the "+" "-" max and min operators on Springs so that in each case the result is a Spring whose characteristics bear a useful mathematical relationship to its constituent springs.

A Spring can be treated as a pair of intervals with a single common point: the preferred value. The following rules define some of the arithmetic operators that can be applied to intervals ([a b] refers to the interval from a to b where a <= b).

 [a1 b1] + [a2 b2] = [a1 + a2 b1 + b2] -[a b] = [-b -a] max([a1 b1] [a2 b2]) = [max(a1 a2) max(b1 b2)] 

If we denote Springs as [a b c] where a <= b <= c we can define the same arithmetic operators on Springs:

 [a1 b1 c1] + [a2 b2 c2] = [a1 + a2 b1 + b2 c1 + c2] -[a b c] = [-c -b -a] max([a1 b1 c1] [a2 b2 c2]) = [max(a1 a2) max(b1 b2) max(c1 c2)] 

With both intervals and Springs we can define "-" and min in terms of negation:

 X - Y = X + (-Y) min(X Y) = -max(-X -Y) 

For the static methods in this class that embody the arithmetic operators we do not actually perform the operation in question as that would snapshot the values of the properties of the method's arguments at the time the static method is called. Instead the static methods create a new Spring instance containing references to the method's arguments so that the characteristics of the new spring track the potentially changing characteristics of the springs from which it was made. This is a little like the idea of a lazy value in a functional language. @see SpringLayout @see SpringLayout.Constraints @version 1.4 015 02/1012/02 @author Philip Milne @since 1.4


Class SpringLayout

A SpringLayout lays out the children of its associated container according to a set of constraints. See How to Use SpringLayout in The Java Tutorial for examples of using SpringLayout.

Each constraint represented by a Spring object controls the vertical or horizontal distance between two component edges. The edges can belong to any child of the container or to the container itself. For example the allowable width of a component can be expressed using a constraint that controls the distance between the west (left) and east (right) edges of the component. The allowable y coordinates for a component can be expressed by constraining the distance between the north (top) edge of the component and the north edge of its container.

Every child of a SpringLayout-controlled container as well as the container itself has exactly one set of constraints associated with it. These constraints are represented by a SpringLayout.Constraints object. By default SpringLayout creates constraints that make their associated component have the minimum preferred and maximum sizes returned by the component's java.awt.Component#getMinimumSize java.awt.Component#getPreferredSize and java.awt.Component#getMaximumSize methods. The x and y positions are initially not constrained so that until you constrain them the Component will be positioned at 0 0 relative to the Insets of the parent Container.

You can change a component's constraints in several ways. You can use one of the putConstraint methods to establish a spring linking the edges of two components within the same container. Or you can get the appropriate SpringLayout.Constraints object using getConstraints and then modify one or more of its springs. Or you can get the spring for a particular edge of a component using getConstraint and modify it. You can also associate your own SpringLayout.Constraints object with a component by specifying the constraints object when you add the component to its container (using Object)})

The Spring object representing each constraint has a minimum preferred maximum and current value. The current value of the spring is somewhere between the minimum and maximum values according to the formula given in the Spring#sum method description. When the minimum preferred and maximum values are the same the current value is always equal to them; this inflexible spring is called a strut. You can create struts using the factory method Spring#constant(int) The Spring class also provides factory methods for creating other kinds of springs including springs that depend on other springs.

In a SpringLayout the position of each edge is dependent on the position of just one other edge. If a constraint is subsequently added to create a new binding for an edge the previous binding is discarded and the edge remains dependent on a single edge. Springs should only be attached between edges of the container and its immediate children; the behavior of the SpringLayout when presented with constraints linking the edges of components from different containers (either internal or external) is undefined.

SpringLayout vs. Other Layout Managers


Note: Unlike many layout managers SpringLayout doesn't automatically set the location of the components it manages. If you hand-code a GUI that uses SpringLayout remember to initialize component locations by constraining the west/east and north/south locations.

Depending on the constraints you use you may also need to set the size of the container explicitly.


Despite the simplicity of SpringLayout it can emulate the behavior of most other layout managers. For some features such as the line breaking provided by FlowLayout you'll need to create a special-purpose subclass of the Spring class.

SpringLayout also provides a way to solve many of the difficult layout problems that cannot be solved by nesting combinations of Boxes. That said SpringLayout honors the LayoutManager2 contract correctly and so can be nested with other layout managers -- a technique that can be preferable to creating the constraints implied by the other layout managers.

The asymptotic complexity of the layout operation of a SpringLayout is linear in the number of constraints (and/or components). @see Spring @see SpringLayout.Constraints @version 1.10 12 01/0330/0102 @author Philip Milne @author Joe Winchester @since 1.4


Class SwingUtilities

A collection of utility methods for Swing. @version 1.114116 12/03/0118/02 @author unknown
Class SwingUtilities, Rectangle computeUnion(int, int, int, int, Rectangle)

Convenience to calculatemethod that calculates the union of two rectangles without allocating a new rectangle. @param x the x-coordinate of the first rectangle @param y the y-coordinate of the first rectangle @param width the width of the first rectangle @param height the height of the first rectangle @param dest the coordinates of the second rectangle; the union of the two rectangles is returned in this rectangle @return Returnthe dest Rectangle
Class SwingUtilities, void paintComponent(Graphics, Component, Container, Rectangle)

Paints a component c on an arbitrary graphics g in the specified rectangle specifying a Rectangle object. The component is reparented to a private container (whose parent becomes p) which prevents c.validate() and c.repaint() calls from propagating up the tree. The intermediate container has no other effect.

The component should either descend from JComponent or be another kind of lightweight component. A lightweight component is one whose "lightweight" property (returned by the Component isLightweight method) is true. If the Component is not lightweight bad things map happen: crashes exceptions painting problems...

@param g the Graphics object to draw on @param c the Component to draw @param p the intermediate Container @param r the Rectangle to draw in @see java.awt.Component#isLightweight

Class SwingUtilities, void paintComponent(Graphics, Component, Container, int, int, int, int)

Paints a component c on an arbitrary graphics g in the specified rectangle specifying the rectangle's upper left corner and size. The component is reparented to a private container (whose parent becomes p) which prevents c.validate() and c.repaint() calls from propagating up the tree. The intermediate container has no other effect.

The component should either descend from JComponent or be another kind of lightweight component. A lightweight component is one whose "lightweight" property (returned by the Component isLightweight method) is true. If the Component is not lightweight bad things map happen: crashes exceptions painting problems...

@param g the Graphics object to draw on @param c the Component to draw @param p the intermediate Container @param x an int specifying the left side of the area draw in in pixels measured from the left edge of the graphics context @param y an int specifying the top of the area to draw in in pixels measured down from the top edge of the graphics context @param w an int specifying the width of the area draw in in pixels @param h an int specifying the height of the area draw in in pixels @see java.awt.Component#isLightweight


Class ToolTipManager

Manages all the ToolTips in the system.

ToolTipManager contains numerous properties for configuring how long it will take for the tooltips to become visible and how long till they hide. Consider a component that has a different tooltip based on where the mouse is such as JTree. When the mouse moves into the JTree and over a region that has a valid tooltip the tooltip will become visibile after initialDelay milliseconds. After dismissDelay milliseconds the tooltip will be hidden. If the mouse is over a region that has a valid tooltip and the tooltip is currently visible when the mouse moves to a region that doesn't have a valid tooltip the tooltip will be hidden. If the mouse then moves back into a region that has a valid tooltip within reshowDelay milliseconds the tooltip will immediately be shown otherwise the tooltip will be shown again after initialDelay milliseconds. @see JComponent#createToolTip @version 1.44 0663 04/0123/9902 @author Dave Moore @author Rich Schiavi


Class WindowConstants

Constants used to control the window-closing operation. The setDefaultCloseOperation and getDefaultCloseOperation methods provided by JFrame JInternalFrame and JDialog use these constants. For examples of setting the default window-closing operation see Responding to Window-Closing Events a section in The Java Tutorial. @version 1.15 1216 04/0318/0102 @author Amy Fowler
Class WindowConstants, int EXIT_ON_CLOSE

The exit application default window close operation. IfAttempting a windowto hasset this set ason the close operation and is closedWindows that support this such as inJFrame an appletmay throw a SecurityException maybased on bethe thrownSecurityManager. It is recommended you only use this in an application. @since 1.4 @see JFrame#setDefaultCloseOperation