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.
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.
For overviews, tutorials, examples, guides, and other documentation, please see:
@serial exclude
|
Java Source File Name | Type | Comment |
AbstractAction.java | Class | This class provides default implementations for the JFC Action
interface. |
AbstractButton.java | Class | Defines common behaviors for buttons and menu items.
Buttons can be configured, and to some degree controlled, by
Action s. |
AbstractCellEditor.java | Class | 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.java | Class | 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.java | Class | This class provides the ChangeListener part of the
SpinnerModel interface that should be suitable for most concrete SpinnerModel
implementations. |
Action.java | Interface | 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.java | Class | ActionMap provides mappings from
Object s
(called keys or Action names)
to Action s.
An ActionMap is usually used with an InputMap
to locate a particular action
when a key is pressed. |
ActionPropertyChangeListener.java | Class | A package-private PropertyChangeListener which listens for
property changes on an Action and updates the properties
of an ActionEvent source. |
AncestorNotifier.java | Class | |
ArrayTable.java | Class | |
Autoscroller.java | Class | Autoscroller is responsible for generating synthetic mouse dragged
events. |
BorderFactory.java | Class | Factory class for vending standard Border objects. |
BoundedRangeModel.java | Interface | Defines the data model used by components like Slider s
and ProgressBar s.
Defines four interrelated integer properties: minimum, maximum, extent
and value. |
Box.java | Class | 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.java | Class | A layout manager that allows multiple components to be laid out either
vertically or horizontally. |
BufferStrategyPaintManager.java | Class | A PaintManager implementation that uses a BufferStrategy for
rendering. |
ButtonGroup.java | Class | This class is used to create a multiple-exclusion scope for
a set of buttons. |
ButtonModel.java | Interface | 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.java | Interface | This interface defines the methods any general editor should be able
to implement. |
CellRendererPane.java | Class | This class is inserted in between cell renderers and the components that
use them. |
ClientPropertyKey.java | enum | 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.java | Interface | The editor component used for JComboBox components. |
ComboBoxModel.java | Interface | A data model for a combo box. |
ComponentInputMap.java | Class | A ComponentInputMap is an InputMap
associated with a particular JComponent . |
DebugGraphics.java | Class | Graphics subclass supporting graphics debugging. |
DebugGraphicsFilter.java | Class | Color filter for DebugGraphics, used for images only. |
DebugGraphicsInfo.java | Class | Class used by DebugGraphics for maintaining information about how
to render graphics calls. |
DebugGraphicsObserver.java | Class | ImageObserver for DebugGraphics, used for images only. |
DefaultBoundedRangeModel.java | Class | A generic implementation of BoundedRangeModel.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. |
DefaultButtonModel.java | Class | 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.java | Class | The default editor for table and tree cells.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. |
DefaultComboBoxModel.java | Class | The default model for combo boxes. |
DefaultDesktopManager.java | Class | This is an implementation of the DesktopManager . |
DefaultFocusManager.java | Class | This class has been obsoleted by the 1.4 focus APIs. |
DefaultListCellRenderer.java | Class | 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.java | Class | 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 ListDataListener s when changes occur. |
DefaultListSelectionModel.java | Class | Default data model for list selections. |
DefaultRowSorter.java | Class | 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.java | Class | A generic implementation of SingleSelectionModel.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. |
DelegatingDefaultFocusManager.java | Class | Provides a javax.swing.DefaultFocusManager view onto an arbitrary
java.awt.KeyboardFocusManager. |
DesktopManager.java | Interface | DesktopManager objects are owned by a JDesktopPane object. |
DropMode.java | enum | Drop modes, used to determine the method by which a component
tracks and indicates a drop location during drag and drop. |
FocusManager.java | Class | This class has been obsoleted by the 1.4 focus APIs. |
GraphicsWrapper.java | Interface | |
GrayFilter.java | Class | An image filter that "disables" an image by turning
it into a grayscale image, and brightening the pixels
in the image. |
GroupLayout.java | Class | 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.java | Interface | A small fixed size picture, typically used to decorate components. |
ImageIcon.java | Class | An implementation of the Icon interface that paints Icons
from Images. |
InputMap.java | Class | InputMap provides a binding between an input event
(currently only KeyStroke s are used)
and an Object . |
InputVerifier.java | Class | The purpose of this class is to help clients support smooth focus
navigation through GUIs with text fields. |
InternalFrameFocusTraversalPolicy.java | Class | A FocusTraversalPolicy which can optionally provide an algorithm for
determining a JInternalFrame's initial Component. |
JApplet.java | Class | 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.java | Class | An implementation of a "push" button.
Buttons can be configured, and to some degree controlled, by
Action s. |
JCheckBox.java | Class | An implementation of a check box -- an item that can be selected or
deselected, and which displays its state to the user. |
JCheckBoxMenuItem.java | Class | A menu item that can be selected or deselected. |
JColorChooser.java | Class | 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:
- A static convenience method which shows a modal color-chooser
dialog and returns the color selected by the user.
- 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.
- The ability to create instances of
JColorChooser panes
directly (within any container). |
JComboBox.java | Class | 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.java | Class | 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.java | Class | A container used to create a multiple-document interface or a virtual desktop. |
JDialog.java | Class | The main class for creating a dialog window. |
JEditorPane.java | Class | 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.java | Class | 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.java | Class | JFormattedTextField extends JTextField adding
support for formatting arbitrary values, as well as retrieving a particular
object once the user has edited the text. |
JFrame.java | Class | 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.java | Class | 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 JInternalFrame s to a JDesktopPane . |
JLabel.java | Class | 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.java | Class | 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.
For convenience, JLayeredPane divides the depth-range
into several different layers. |
JList.java | Class | A component that displays a list of objects and allows the user to select
one or more items. |
JMenu.java | Class | An implementation of a menu -- a popup window containing
JMenuItem s that
is displayed when the user selects an item on the JMenuBar .
In addition to JMenuItem s, a JMenu can
also contain JSeparator s. |
JMenuBar.java | Class | An implementation of a menu bar. |
JMenuItem.java | Class | An implementation of an item in a menu. |
JOptionPane.java | Class | 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.java | Class | 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.java | Class | 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.java | Class | An implementation of a popup menu -- a small window that pops up
and displays a series of choices. |
JProgressBar.java | Class | A component that visually displays the progress of some task. |
JRadioButton.java | Class | 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.java | Class | 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.java | Class | 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. |
JScrollBar.java | Class | An implementation of a scrollbar. |
JScrollPane.java | Class | 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.java | Class | 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.
JSeparator s 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.java | Class | 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.java | Class | A single line input field that lets the user select a
number or an object value from an ordered sequence. |
JSplitPane.java | Class | JSplitPane is used to divide two (and only two)
Component s. |
JTabbedPane.java | Class | 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.java | Class | 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.java | Class | A JTextArea is a multi-line area that displays plain text. |
JTextField.java | Class | JTextField is a lightweight component that allows the editing
of a single line of text. |
JTextPane.java | Class | A text component that can be marked up with attributes that are
represented graphically. |
JToggleButton.java | Class | An implementation of a two-state button. |
JToolBar.java | Class | JToolBar provides a component that is useful for
displaying commonly used Action s 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.java | Class | Used to display a "Tip" for a Component. |
JTree.java | Class |
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.java | Class | The "viewport" or "porthole" through which you see the underlying
information. |
JWindow.java | Class | A JWindow is a container that can be displayed anywhere on the
user's desktop. |
KeyboardManager.java | Class | The KeyboardManager class is used to help dispatch keyboard actions for the
WHEN_IN_FOCUSED_WINDOW style actions. |
KeyStroke.java | Class | A KeyStroke represents a key action on the keyboard, or equivalent input
device. |
LayoutComparator.java | Class | Comparator which attempts to sort Components based on their size and
position. |
LayoutFocusTraversalPolicy.java | Class | A SortingFocusTraversalPolicy which sorts Components based on their size,
position, and orientation. |
LayoutStyle.java | Class | LayoutStyle provides information about how to position
components. |
LegacyGlueFocusTraversalPolicy.java | Class | A FocusTraversalPolicy which provides support for legacy applications which
handle focus traversal via JComponent.setNextFocusableComponent or by
installing a custom DefaultFocusManager. |
ListCellRenderer.java | Interface | Identifies components that can be used as "rubber stamps" to paint
the cells in a JList. |
ListModel.java | Interface | 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.java | Interface | This interface represents the current state of the
selection for any of the components that display a
list of values with stable indices. |
LookAndFeel.java | Class | LookAndFeel , as the name implies, encapsulates a look and
feel. |
MenuElement.java | Interface | Any component that can be placed into a menu should implement this interface. |
MenuSelectionManager.java | Class | A MenuSelectionManager owns the selection in menu hierarchy. |
MultiUIDefaults.java | Class | |
MutableComboBoxModel.java | Interface | A mutable version of ComboBoxModel . |
OverlayLayout.java | Class | A layout manager to arrange components over the top
of each other. |
Popup.java | Class | Popups are used to display a Component to the user, typically
on top of all the other Component s in a particular containment
hierarchy. |
PopupFactory.java | Class | PopupFactory , as the name implies, is used to obtain
instances of Popup s. |
ProgressMonitor.java | Class | A class to monitor the progress of some operation. |
ProgressMonitorInputStream.java | Class | Monitors the progress of reading from some InputStream. |
Renderer.java | Interface | Defines the requirements for an object responsible for
"rendering" (displaying) a value. |
RepaintManager.java | Class | 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.java | Interface | 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.java | Class | RowFilter is used to filter out entries from the
model so that they are not shown in the view. |
RowSorter.java | Class | RowSorter provides the basis for sorting and filtering.
Beyond creating and installing a RowSorter , you very rarely
need to interact with one directly. |
Scrollable.java | Interface | An interface that provides information to a scrolling container
like JScrollPane. |
ScrollPaneConstants.java | Interface | Constants used with the JScrollPane component. |
ScrollPaneLayout.java | Class | The layout manager used by JScrollPane . |
SingleSelectionModel.java | Interface | A model that supports at most one indexed selection. |
SizeRequirements.java | Class | 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.java | Class | A SizeSequence object
efficiently maintains an ordered list
of sizes and corresponding positions. |
SortingFocusTraversalPolicy.java | Class | A FocusTraversalPolicy that determines traversal order by sorting the
Components of a focus traversal cycle based on a given Comparator. |
SortOrder.java | enum | SortOrder is an enumeration of the possible sort orderings. |
SpinnerDateModel.java | Class | A SpinnerModel for sequences of Date s. |
SpinnerListModel.java | Class | 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.java | Interface | A model for a potentially unbounded sequence of object values. |
SpinnerNumberModel.java | Class | A SpinnerModel for sequences of numbers. |
Spring.java | Class | An instance of the Spring class holds three properties that
characterize its behavior: the minimum, preferred, and
maximum values. |
SpringLayout.java | Class | 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.java | Interface | A collection of constants generally used for positioning and orienting
components on the screen. |
SwingHeavyWeight.java | Interface | An interface used to tag heavy weight components that we want processed
by Swing's RepaintManager. |
SwingPaintEventDispatcher.java | Class | Swing's PaintEventDispatcher. |
SwingUtilities.java | Class | A collection of utility methods for Swing. |
SwingWorker.java | Class | 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.java | Class | An implementation of Printable for printing
JTable s.
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.java | Class | Fires one or more
ActionEvent s at specified
intervals. |
TimerQueue.java | Class | Internal class to manage all Timers using one thread.
TimerQueue manages a queue of Timers. |
ToolTipManager.java | Class | 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.java | Class | This class is used to handle the transfer of a Transferable
to and from Swing components. |
UIDefaults.java | Class | A table of defaults for Swing components. |
UIManager.java | Class | 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.java | Class | 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.java | Class | The default layout manager for JViewport . |
WindowConstants.java | Interface | Constants used to control the window-closing operation. |