javax.swing

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » swing » javax.swing 
javax.swing
swing package

Provides a set of "lightweight" (all-Java language) components that, to the maximum degree possible, work the same on all platforms. For a programmer's guide to using these components, see Creating a GUI with JFC/Swing, a trail in The Java Tutorial. For other resources, see Related Documentation.

Swing's Threading Policy

In general Swing is not thread safe. All Swing components and related classes, unless otherwise documented, must be accessed on the event dispatching thread.

Typical Swing applications do processing in response to an event generated from a user gesture. For example, clicking on a {@code JButton} notifies all {@code ActionListeners} added to the {@code JButton}. As all events generated from a user gesture are dispatched on the event dispatching thread, most developers are not impacted by the restriction.

Where the impact lies, however, is in constructing and showing a Swing application. Calls to an application's {@code main} method, or methods in {@code Applet}, are not invoked on the event dispatching thread. As such, care must be taken to transfer control to the event dispatching thread when constructing and showing an application or applet. The preferred way to transfer control and begin working with Swing is to use {@code invokeLater}. The {@code invokeLater} method schedules a {@code Runnable} to be processed on the event dispatching thread. The following two examples work equally well for transferring control and starting up a Swing application:

public class MyApp implements Runnable {
    public void run() {
        // Invoked on the event dispatching thread.
        // Construct and show GUI.
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new MyApp(args));
    }
}
Or:
public class MyApp {
    MyApp(String[] args) {
        // Invoked on the event dispatching thread. Do any initialization
        // here.
    }

    public void show() {
        // Show the UI.
    }

    public static void main(final String[] args) {
        // Schedule a job for the event-dispatching thread:
        // creating and showing this application's GUI.
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new MyApp(args).show();
            }
        });
    }
}
This restriction also applies to models attached to Swing components. For example, if a {@code TableModel} is attached to a {@code JTable}, the {@code TableModel} should only be modified on the event dispatching thread. If you modify the model on a separate thread you run the risk of exceptions and possible display corruption.

As all events are delivered on the event dispatching thread, care must be taken in event processing. In particular, a long running task, such as network io or computational intensive processing, executed on the event dispatching thread blocks the event dispatching thread from dispatching any other events. While the event dispatching thread is blocked the application is completely unresponsive to user input. Refer to {@link SwingWorker} for the preferred way to do such processing when working with Swing.

More information on this topic can be found in the Swing tutorial, in particular the section on How to Use Threads.

Related Documentation

For overviews, tutorials, examples, guides, and other documentation, please see:

@serial exclude
Java Source File NameTypeComment
AbstractAction.javaClass This class provides default implementations for the JFC Action interface.
AbstractButton.javaClass Defines common behaviors for buttons and menu items.

Buttons can be configured, and to some degree controlled, by Actions.

AbstractCellEditor.javaClass
version:
   1.19 05/05/07
version:
   A base class for CellEditors, providing default
version:
   implementations for the methods in the CellEditor
version:
   interface except getCellEditorValue().
AbstractListModel.javaClass The abstract definition for the data model that provides a List with its contents.

Warning: Serialized objects of this class will not be compatible with future Swing releases.

AbstractSpinnerModel.javaClass This class provides the ChangeListener part of the SpinnerModel interface that should be suitable for most concrete SpinnerModel implementations.
Action.javaInterface The Action interface provides a useful extension to the ActionListener interface in cases where the same functionality may be accessed by several controls.

In addition to the actionPerformed method defined by the ActionListener interface, this interface allows the application to define, in a single place:

  • One or more text strings that describe the function.
ActionMap.javaClass ActionMap provides mappings from Objects (called keys or Action names) to Actions. An ActionMap is usually used with an InputMap to locate a particular action when a key is pressed.
ActionPropertyChangeListener.javaClass A package-private PropertyChangeListener which listens for property changes on an Action and updates the properties of an ActionEvent source.
AncestorNotifier.javaClass
ArrayTable.javaClass
Autoscroller.javaClass Autoscroller is responsible for generating synthetic mouse dragged events.
BorderFactory.javaClass Factory class for vending standard Border objects.
BoundedRangeModel.javaInterface Defines the data model used by components like Sliders and ProgressBars. Defines four interrelated integer properties: minimum, maximum, extent and value.
Box.javaClass A lightweight container that uses a BoxLayout object as its layout manager. Box provides several class methods that are useful for containers using BoxLayout -- even non-Box containers.

The Box class can create several kinds of invisible components that affect layout: glue, struts, and rigid areas. If all the components your Box contains have a fixed size, you might want to use a glue component (returned by createGlue) to control the components' positions. If you need a fixed amount of space between two components, try using a strut (createHorizontalStrut or createVerticalStrut). If you need an invisible component that always takes up the same amount of space, get it by invoking createRigidArea.

If you are implementing a BoxLayout you can find further information and examples in How to Use BoxLayout, a section in The Java Tutorial.

Warning: Serialized objects of this class will not be compatible with future Swing releases.

BoxLayout.javaClass A layout manager that allows multiple components to be laid out either vertically or horizontally.
BufferStrategyPaintManager.javaClass A PaintManager implementation that uses a BufferStrategy for rendering.
ButtonGroup.javaClass This class is used to create a multiple-exclusion scope for a set of buttons.
ButtonModel.javaInterface State model for buttons.

This model is used for regular buttons, as well as check boxes and radio buttons, which are special kinds of buttons.

CellEditor.javaInterface This interface defines the methods any general editor should be able to implement.
CellRendererPane.javaClass This class is inserted in between cell renderers and the components that use them.
ClientPropertyKey.javaenum An enumeration for keys used as client properties within the Swing implementation.

This enum holds only a small subset of the keys currently used within Swing, but we may move more of them here in the future.

Adding an item to, and using, this class instead of String for client properties protects against conflicts with developer-set client properties.

ComboBoxEditor.javaInterface The editor component used for JComboBox components.
ComboBoxModel.javaInterface A data model for a combo box.
ComponentInputMap.javaClass A ComponentInputMap is an InputMap associated with a particular JComponent.
DebugGraphics.javaClass Graphics subclass supporting graphics debugging.
DebugGraphicsFilter.javaClass Color filter for DebugGraphics, used for images only.
DebugGraphicsInfo.javaClass Class used by DebugGraphics for maintaining information about how to render graphics calls.
DebugGraphicsObserver.javaClass ImageObserver for DebugGraphics, used for images only.
DefaultBoundedRangeModel.javaClass A generic implementation of BoundedRangeModel.

Warning: Serialized objects of this class will not be compatible with future Swing releases.

DefaultButtonModel.javaClass The default implementation of a Button component's data model.

Warning: Serialized objects of this class will not be compatible with future Swing releases.

DefaultCellEditor.javaClass The default editor for table and tree cells.

Warning: Serialized objects of this class will not be compatible with future Swing releases.

DefaultComboBoxModel.javaClass The default model for combo boxes.
DefaultDesktopManager.javaClass This is an implementation of the DesktopManager.
DefaultFocusManager.javaClass This class has been obsoleted by the 1.4 focus APIs.
DefaultListCellRenderer.javaClass Renders an item in a list.

Implementation Note: This class overrides invalidate, validate, revalidate, repaint, isOpaque, and firePropertyChange solely to improve performance. If not overridden, these frequently called methods would execute code paths that are unnecessary for the default list cell renderer. If you write your own renderer, take care to weigh the benefits and drawbacks of overriding these methods.

Warning: Serialized objects of this class will not be compatible with future Swing releases.

DefaultListModel.javaClass This class loosely implements the java.util.Vector API, in that it implements the 1.1.x version of java.util.Vector, has no collection class support, and notifies the ListDataListeners when changes occur.
DefaultListSelectionModel.javaClass Default data model for list selections.
DefaultRowSorter.javaClass An implementation of RowSorter that provides sorting and filtering around a grid-based data model. Beyond creating and installing a RowSorter, you very rarely need to interact with one directly.
DefaultSingleSelectionModel.javaClass A generic implementation of SingleSelectionModel.

Warning: Serialized objects of this class will not be compatible with future Swing releases.

DelegatingDefaultFocusManager.javaClass Provides a javax.swing.DefaultFocusManager view onto an arbitrary java.awt.KeyboardFocusManager.
DesktopManager.javaInterface DesktopManager objects are owned by a JDesktopPane object.
DropMode.javaenum Drop modes, used to determine the method by which a component tracks and indicates a drop location during drag and drop.
FocusManager.javaClass This class has been obsoleted by the 1.4 focus APIs.
GraphicsWrapper.javaInterface
GrayFilter.javaClass An image filter that "disables" an image by turning it into a grayscale image, and brightening the pixels in the image.
GroupLayout.javaClass GroupLayout is a LayoutManager that hierarchically groups components in order to position them in a Container . GroupLayout is intended for use by builders, but may be hand-coded as well. Grouping is done by instances of the Group Group class.
Icon.javaInterface A small fixed size picture, typically used to decorate components.
ImageIcon.javaClass An implementation of the Icon interface that paints Icons from Images.
InputMap.javaClass InputMap provides a binding between an input event (currently only KeyStrokes are used) and an Object.
InputVerifier.javaClass The purpose of this class is to help clients support smooth focus navigation through GUIs with text fields.
InternalFrameFocusTraversalPolicy.javaClass A FocusTraversalPolicy which can optionally provide an algorithm for determining a JInternalFrame's initial Component.
JApplet.javaClass An extended version of java.applet.Applet that adds support for the JFC/Swing component architecture. You can find task-oriented documentation about using JApplet in The Java Tutorial, in the section How to Make Applets.

The JApplet class is slightly incompatible with java.applet.Applet.

JButton.javaClass An implementation of a "push" button.

Buttons can be configured, and to some degree controlled, by Actions.

JCheckBox.javaClass An implementation of a check box -- an item that can be selected or deselected, and which displays its state to the user.
JCheckBoxMenuItem.javaClass A menu item that can be selected or deselected.
JColorChooser.javaClass 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).
JComboBox.javaClass 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.
JComponent.javaClass The base class for all Swing components except top-level containers. To use a component that inherits from JComponent, you must place the component in a containment hierarchy whose root is a top-level Swing container. Top-level Swing containers -- such as JFrame, JDialog, and JApplet -- are specialized components that provide a place for other Swing components to paint themselves. For an explanation of containment hierarchies, see Swing Components and the Containment Hierarchy, a section in The Java Tutorial.

The JComponent class provides:

  • The base class for both standard and custom components that use the Swing architecture.
  • A "pluggable look and feel" (L&F) that can be specified by the programmer or (optionally) selected by the user at runtime. The look and feel for each component is provided by a UI delegate -- an object that descends from javax.swing.plaf.ComponentUI . See How to Set the Look and Feel in The Java Tutorial for more information.
  • Comprehensive keystroke handling. See the document Keyboard Bindings in Swing, an article in The Swing Connection, for more information.
  • Support for tool tips -- short descriptions that pop up when the cursor lingers over a component. See How to Use Tool Tips in The Java Tutorial for more information.
  • Support for accessibility. JComponent contains all of the methods in the Accessible interface, but it doesn't actually implement the interface.
JDesktopPane.javaClass A container used to create a multiple-document interface or a virtual desktop.
JDialog.javaClass The main class for creating a dialog window.
JEditorPane.javaClass 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.

JFileChooser.javaClass 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();
 FileNameExtensionFilter filter = new FileNameExtensionFilter(
 "JPG & GIF Images", "jpg", "gif");
 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());
 }
 

Warning: Swing is not thread safe.

JFormattedTextField.javaClass JFormattedTextField extends JTextField adding support for formatting arbitrary values, as well as retrieving a particular object once the user has edited the text.
JFrame.javaClass 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.

JInternalFrame.javaClass 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.

JLabel.javaClass 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.

JLayeredPane.javaClass JLayeredPane adds depth to a JFC/Swing container, allowing components to overlap each other when needed. An Integer object specifies each component's depth in the container, where higher-numbered components sit "on top" of other components. For task-oriented documentation and examples of using layered panes see How to Use a Layered Pane, a section in The Java Tutorial.

The following text describes this image.

For convenience, JLayeredPane divides the depth-range into several different layers.

JList.javaClass A component that displays a list of objects and allows the user to select one or more items.
JMenu.javaClass 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.
JMenuBar.javaClass An implementation of a menu bar.
JMenuItem.javaClass An implementation of an item in a menu.
JOptionPane.javaClass JOptionPane makes it easy to pop up a standard dialog box that prompts users for a value or informs them of something. For information about using JOptionPane, see How to Make Dialogs, a section in The Java Tutorial.

While the JOptionPane class may appear complex because of the large number of methods, almost all uses of this class are one-line calls to one of the static showXxxDialog methods shown below:

Method Name Description
showConfirmDialog Asks a confirming question, like yes/no/cancel.
showInputDialog Prompt for some input.
showMessageDialog Tell the user about something that has happened.
showOptionDialog The Grand Unification of the above three.
Each of these methods also comes in a showInternalXXX flavor, which uses an internal frame to hold the dialog box (see JInternalFrame ). Multiple convenience methods have also been defined -- overloaded versions of the basic methods that use different parameter lists.

All dialogs are modal.

JPanel.javaClass JPanel is a generic lightweight container. For examples and task-oriented documentation for JPanel, see How to Use Panels, a section in The Java Tutorial.

Warning: Swing is not thread safe.

JPasswordField.javaClass JPasswordField is a lightweight component that allows the editing of a single line of text where the view indicates something was typed, but does not show the original characters.
JPopupMenu.javaClass An implementation of a popup menu -- a small window that pops up and displays a series of choices.
JProgressBar.javaClass A component that visually displays the progress of some task.
JRadioButton.javaClass An implementation of a radio button -- an item that can be selected or deselected, and which displays its state to the user. Used with a ButtonGroup object to create a group of buttons in which only one button at a time can be selected.
JRadioButtonMenuItem.javaClass An implementation of a radio button menu item. A JRadioButtonMenuItem is a menu item that is part of a group of menu items in which only one item in the group can be selected.
JRootPane.javaClass 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 following text describes this graphic.

The "heavyweight" components (those that delegate to a peer, or native component on the host system) are shown with a darker, heavier box.
JScrollBar.javaClass An implementation of a scrollbar.
JScrollPane.javaClass Provides a scrollable view of a lightweight component. A JScrollPane manages a viewport, optional vertical and horizontal scroll bars, and optional row and column heading viewports. You can find task-oriented documentation of JScrollPane in How to Use Scroll Panes, a section in The Java Tutorial.
JSeparator.javaClass JSeparator provides a general purpose component for implementing divider lines - most commonly used as a divider between menu items that breaks them up into logical groupings. Instead of using JSeparator directly, you can use the JMenu or JPopupMenu addSeparator method to create and add a separator. JSeparators may also be used elsewhere in a GUI wherever a visual divider is useful.

For more information and examples see How to Use Menus, a section in The Java Tutorial.

Warning: Swing is not thread safe.

JSlider.javaClass A component that lets the user graphically select a value by sliding a knob within a bounded interval.

The slider can show both major tick marks, and minor tick marks between the major ones.

JSpinner.javaClass A single line input field that lets the user select a number or an object value from an ordered sequence.
JSplitPane.javaClass JSplitPane is used to divide two (and only two) Components.
JTabbedPane.javaClass 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.

JTable.javaClass 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.

JTextArea.javaClass A JTextArea is a multi-line area that displays plain text.
JTextField.javaClass JTextField is a lightweight component that allows the editing of a single line of text.
JTextPane.javaClass A text component that can be marked up with attributes that are represented graphically.
JToggleButton.javaClass An implementation of a two-state button.
JToolBar.javaClass JToolBar provides a component that is useful for displaying commonly used Actions or controls. For examples and information on using tool bars see How to Use Tool Bars, a section in The Java Tutorial.

With most look and feels, the user can drag out a tool bar into a separate window (unless the floatable property is set to false). For drag-out to work correctly, it is recommended that you add JToolBar instances to one of the four "sides" of a container whose layout manager is a BorderLayout, and do not add children to any of the other four "sides".

Warning: Swing is not thread safe.

JToolTip.javaClass Used to display a "Tip" for a Component.
JTree.javaClass 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 a 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.

JViewport.javaClass The "viewport" or "porthole" through which you see the underlying information.
JWindow.javaClass A JWindow is a container that can be displayed anywhere on the user's desktop.
KeyboardManager.javaClass The KeyboardManager class is used to help dispatch keyboard actions for the WHEN_IN_FOCUSED_WINDOW style actions.
KeyStroke.javaClass A KeyStroke represents a key action on the keyboard, or equivalent input device.
LayoutComparator.javaClass Comparator which attempts to sort Components based on their size and position.
LayoutFocusTraversalPolicy.javaClass A SortingFocusTraversalPolicy which sorts Components based on their size, position, and orientation.
LayoutStyle.javaClass LayoutStyle provides information about how to position components.
LegacyGlueFocusTraversalPolicy.javaClass A FocusTraversalPolicy which provides support for legacy applications which handle focus traversal via JComponent.setNextFocusableComponent or by installing a custom DefaultFocusManager.
ListCellRenderer.javaInterface Identifies components that can be used as "rubber stamps" to paint the cells in a JList.
ListModel.javaInterface This interface defines the methods components like JList use to get the value of each cell in a list and the length of the list. Logically the model is a vector, indices vary from 0 to ListDataModel.getSize() - 1.
ListSelectionModel.javaInterface This interface represents the current state of the selection for any of the components that display a list of values with stable indices.
LookAndFeel.javaClass LookAndFeel , as the name implies, encapsulates a look and feel.
MenuElement.javaInterface Any component that can be placed into a menu should implement this interface.
MenuSelectionManager.javaClass A MenuSelectionManager owns the selection in menu hierarchy.
MultiUIDefaults.javaClass
MutableComboBoxModel.javaInterface A mutable version of ComboBoxModel.
OverlayLayout.javaClass A layout manager to arrange components over the top of each other.
Popup.javaClass Popups are used to display a Component to the user, typically on top of all the other Components in a particular containment hierarchy.
PopupFactory.javaClass PopupFactory, as the name implies, is used to obtain instances of Popups.
ProgressMonitor.javaClass A class to monitor the progress of some operation.
ProgressMonitorInputStream.javaClass Monitors the progress of reading from some InputStream.
Renderer.javaInterface Defines the requirements for an object responsible for "rendering" (displaying) a value.
RepaintManager.javaClass 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.

As of 1.6 RepaintManager handles repaint requests for Swing's top level components (JApplet, JWindow, JFrame and JDialog).

RootPaneContainer.javaInterface This interface is implemented by components that have a single JRootPane child: JDialog, JFrame, JWindow, JApplet, JInternalFrame. The methods in this interface are just covers for the JRootPane properties, e.g.
RowFilter.javaClass RowFilter is used to filter out entries from the model so that they are not shown in the view.
RowSorter.javaClass RowSorter provides the basis for sorting and filtering. Beyond creating and installing a RowSorter, you very rarely need to interact with one directly.
Scrollable.javaInterface An interface that provides information to a scrolling container like JScrollPane.
ScrollPaneConstants.javaInterface Constants used with the JScrollPane component.
ScrollPaneLayout.javaClass The layout manager used by JScrollPane.
SingleSelectionModel.javaInterface A model that supports at most one indexed selection.
SizeRequirements.javaClass 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.

SizeSequence.javaClass A SizeSequence object efficiently maintains an ordered list of sizes and corresponding positions.
SortingFocusTraversalPolicy.javaClass A FocusTraversalPolicy that determines traversal order by sorting the Components of a focus traversal cycle based on a given Comparator.
SortOrder.javaenum SortOrder is an enumeration of the possible sort orderings.
SpinnerDateModel.javaClass A SpinnerModel for sequences of Dates.
SpinnerListModel.javaClass A simple implementation of SpinnerModel whose values are defined by an array or a List. For example to create a model defined by an array of the names of the days of the week:
 String[] days = new DateFormatSymbols().getWeekdays();
 SpinnerModel model = new SpinnerListModel(Arrays.asList(days).subList(1, 8));
 
This class only stores a reference to the array or List so if an element of the underlying sequence changes, it's up to the application to notify the ChangeListeners by calling fireStateChanged.
SpinnerModel.javaInterface A model for a potentially unbounded sequence of object values.
SpinnerNumberModel.javaClass A SpinnerModel for sequences of numbers.
Spring.javaClass An instance of the Spring class holds three properties that characterize its behavior: the minimum, preferred, and maximum values.
SpringLayout.javaClass 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.

SwingConstants.javaInterface A collection of constants generally used for positioning and orienting components on the screen.
SwingHeavyWeight.javaInterface An interface used to tag heavy weight components that we want processed by Swing's RepaintManager.
SwingPaintEventDispatcher.javaClass Swing's PaintEventDispatcher.
SwingUtilities.javaClass A collection of utility methods for Swing.
SwingWorker.javaClass An abstract class to perform lengthy GUI-interacting tasks in a dedicated thread.

When writing a multi-threaded application using Swing, there are two constraints to keep in mind: (refer to How to Use Threads for more details):

  • Time-consuming tasks should not be run on the Event Dispatch Thread.
TablePrintable.javaClass An implementation of Printable for printing JTables.

This implementation spreads table rows naturally in sequence across multiple pages, fitting as many rows as possible per page. The distribution of columns, on the other hand, is controlled by a printing mode parameter passed to the constructor.

Timer.javaClass Fires one or more ActionEvent s at specified intervals.
TimerQueue.javaClass Internal class to manage all Timers using one thread. TimerQueue manages a queue of Timers.
ToolTipManager.javaClass 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.

TransferHandler.javaClass This class is used to handle the transfer of a Transferable to and from Swing components.
UIDefaults.javaClass A table of defaults for Swing components.
UIManager.javaClass UIManager manages the current look and feel, the set of available look and feels, PropertyChangeListeners that are notified when the look and feel changes, look and feel defaults, and convenience methods for obtaining various default values.

Specifying the look and feel

The look and feel can be specified in two distinct ways: by specifying the fully qualified name of the class for the look and feel, or by creating an instance of LookAndFeel and passing it to setLookAndFeel .
UnsupportedLookAndFeelException.javaClass An exception that indicates the requested look & feel management classes are not present on the user's system.

Warning: Serialized objects of this class will not be compatible with future Swing releases.

ViewportLayout.javaClass The default layout manager for JViewport.
WindowConstants.javaInterface Constants used to control the window-closing operation.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.