This large package contains the most important classes and interfaces of Swing. Swing is a core part of Java 1.2 and is also available as a standard extension to Java 1.1. The GUI component classes are at the heart of Swing. These classes have names that begin with the letter J. Figure 23-1 shows the hierarchy of Swing components in javax.swing. Note that this diagram does not show the fact that all the Swing components implement javax.accessibility.Accessible; see the individual class synopses for this information.

Most Swing components rely on a model object to hold their state information. Various interfaces define the methods that these state objects must implement, and various abstract and concrete classes implement these interfaces. These model interfaces and classes are recognizable by the word "Model" in their names. Figure 23-2 shows the model objects and layout managers in javax.swing.
Classes with the word "Manager" in their names typically manage some important part of the Swing user-interface or application environment. Other important classes and interfaces defined by this package include: Action, Icon, KeyStroke, Timer, and SwingUtilities. Figure 23-3 shows the rest of the classes and interfaces in javax.swing.
All Swing components are accessible, which means that they implement the javax.accessiblity.Accessible interface and define getAccessibleContext() methods. This method returns a javax.accessibility.AccessibleContext object that provides support to accessibility tools, such as screen readers for the vision impaired. Each accessible component has its own specific subclass of AccessibleContext, which is typically defined as a protected inner class of the component. These AccessibleContext inner classes have been omitted from this chapter and from Figure 23-1 because they contain little useful information and they detract from other, more important classes. Practically everything you need to know about an AccessibleContext subclass can be found in the single-line inner class synopsis that appears in the containing class, the accessible flag of the containing class, and in Chapter 22, "The javax.accessibility Package".
See Chapter 2, "Swing and AWTArchitecture", for an overview of GUI programming in Java, and see Chapter 3, "Swing Programming Topics", for detailed explanations of many important Swing components and capabilities.


| AbstractAction | Java 1.2 | |
|
|
||
| javax.swing | cloneable serializable | |
This class implements all the methods of the Action interface except for the crucial actionPerformed() method that provides the substance of the action. Subclassing AbstractAction is one of the easiest ways to define Action objects for your application. Note the one- and two-argument constructors. These constructors automatically define name and icon attributes for the action and are simpler than using putValue().
| public abstract class AbstractAction implements Action, Cloneable, Serializable { | ||
| // | Public Constructors | |
| public AbstractAction (); | ||
| public AbstractAction (String name); | ||
| public AbstractAction (String name, Icon icon); | ||
| // | Event Registration Methods (by event name) | |
| public void addPropertyChangeListener (java.beans.PropertyChangeListener listener); | Implements:Action synchronized | |
| public void removePropertyChangeListener (java.beans.PropertyChangeListener listener); | Implements:Action synchronized | |
| // | Methods Implementing Action | |
| public void addPropertyChangeListener (java.beans.PropertyChangeListener listener); | synchronized | |
| public Object getValue (String key); | ||
| public boolean isEnabled (); | ||
| public void putValue (String key, Object newValue); | synchronized | |
| public void removePropertyChangeListener (java.beans.PropertyChangeListener listener); | synchronized | |
| public void setEnabled (boolean newValue); | synchronized | |
| // | Methods Implementing ActionListener | |
| public abstract void actionPerformed (java.awt.event.ActionEvent e); | ||
| // | Protected Methods Overriding Object | |
| protected Object clone () throws CloneNotSupportedException; | ||
| // | Protected Instance Methods | |
| protected void firePropertyChange (String propertyName, Object oldValue, Object newValue); | ||
| // | Protected Instance Fields | |
| protected javax.swing.event.SwingPropertyChangeSupport changeSupport ; | ||
| protected boolean enabled ; | ||
| } | ||
Hierarchy: Object-->AbstractAction(Action(java.awt.event.ActionListener(java.util.EventListener)),Cloneable,Serializable)
Subclasses: javax.swing.text.TextAction
| AbstractButton | Java 1.2 | |
|
|
||
| javax.swing | serializable swing component | |
This class serves as the superclass for Swing components with buttonlike behavior. Because it is a general-purpose class, it defines a large number of properties. Like Swing labels, Swing buttons can display text and/or an icon, and several properties specify the relative positioning of the text and icon. (See JLabel for details on these positioning properties.) Swing buttons can display different icons when in different states. In addition to the default icon, AbstractButton has properties that specify icons to be displayed when the button is pressed, selected, disabled, disabled and selected, rolled over, and rolled over and selected. If the rolloverIcon property is specified and if the rolloverEnabled property is true, the rolloverIcon is displayed when the mouse is over the button.
By default, an AbstractButton displays a single line of text in a single font. However, as of Swing 1.1.1 and Java 1.2.2, if the text property begins with "<html>", the button text is formatted as HTML and may contain multiple fonts and multiple lines.
A Swing button may be enabled and disabled with setEnabled(). Disabled buttons are typically displayed with grayed-out graphics, although some other disabled icon can also be specified. A mnemonic can be specified with setMnemonic(). This causes the mnemonic character to be underlined in the button's text and allows the button to be operated via the keyboard.
Swing buttons generate three types of events. A java.awt.event.ActionEvent is generated when any button is pushed. A java.awt.event.ItemEvent is generated when a toggle-type button is selected or deselected. And a javax.swing.event.ChangeEvent is generated when the button's internal state changes--for example, when the mouse pointer enters the button or when the user arms the button by pressing the mouse button.
| public abstract class AbstractButton extends JComponent implements java.awt.ItemSelectable, SwingConstants { | ||
| // | Public Constructors | |
| public AbstractButton (); | ||
| // | Public Constants | |
| public static final String BORDER_PAINTED_CHANGED_PROPERTY ; | ="borderPainted" | |
| public static final String CONTENT_AREA_FILLED_CHANGED_PROPERTY ; | ="contentAreaFilled" | |
| public static final String DISABLED_ICON_CHANGED_PROPERTY ; | ="disabledIcon" | |
| public static final String DISABLED_SELECTED_ICON_CHANGED_PROPERTY ; | ="disabledSelectedIcon" | |
| public static final String FOCUS_PAINTED_CHANGED_PROPERTY ; | ="focusPainted" | |
| public static final String HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY ; | ="horizontalAlignment" | |
| public static final String HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY ; | ="horizontalTextPosition" | |
| public static final String ICON_CHANGED_PROPERTY ; | ="icon" | |
| public static final String MARGIN_CHANGED_PROPERTY ; | ="margin" | |
| public static final String MNEMONIC_CHANGED_PROPERTY ; | ="mnemonic" | |
| public static final String MODEL_CHANGED_PROPERTY ; | ="model" | |
| public static final String PRESSED_ICON_CHANGED_PROPERTY ; | ="pressedIcon" | |
| public static final String ROLLOVER_ENABLED_CHANGED_PROPERTY ; | ="rolloverEnabled" | |
| public static final String ROLLOVER_ICON_CHANGED_PROPERTY ; | ="rolloverIcon" | |
| public static final String ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY ; | ="rolloverSelectedIcon" | |
| public static final String SELECTED_ICON_CHANGED_PROPERTY ; | ="selectedIcon" | |
| public static final String TEXT_CHANGED_PROPERTY ; | ="text" | |
| public static final String VERTICAL_ALIGNMENT_CHANGED_PROPERTY ; | ="verticalAlignment" | |
| public static final String VERTICAL_TEXT_POSITION_CHANGED_PROPERTY ; | ="verticalTextPosition" | |
| // | Inner Classes | |
| ; | ||
| ; | ||
| // | Event Registration Methods (by event name) | |
| public void addActionListener (java.awt.event.ActionListener l); | ||
| public void removeActionListener (java.awt.event.ActionListener l); | ||
| public void addChangeListener (javax.swing.event.ChangeListener l); | ||
| public void removeChangeListener (javax.swing.event.ChangeListener l); | ||
| public void addItemListener (java.awt.event.ItemListener l); | Implements:ItemSelectable | |
| public void removeItemListener (java.awt.event.ItemListener l); | Implements:ItemSelectable | |
| // | Property Accessor Methods (by property name) | |
| public String getActionCommand (); | ||
| public void setActionCommand (String actionCommand); | ||
| public boolean isBorderPainted (); | ||
| public void setBorderPainted (boolean b); | bound | |
| public boolean isContentAreaFilled (); | ||
| public void setContentAreaFilled (boolean b); | bound | |
| public Icon getDisabledIcon (); | ||
| public void setDisabledIcon (Icon disabledIcon); | bound | |
| public Icon getDisabledSelectedIcon (); | ||
| public void setDisabledSelectedIcon (Icon disabledSelectedIcon); | ||
| public boolean isFocusPainted (); | ||
| public void setFocusPainted (boolean b); | bound | |
| public int getHorizontalAlignment (); | ||
| public void setHorizontalAlignment (int alignment); | bound | |
| public int getHorizontalTextPosition (); | ||
| public void setHorizontalTextPosition (int textPosition); | bound | |
| public Icon getIcon (); | ||
| public void setIcon (Icon defaultIcon); | bound | |
| public java.awt.Insets getMargin (); | ||
| public void setMargin (java.awt.Insets m); | bound | |
| public int getMnemonic (); | ||
| public void setMnemonic (int mnemonic); | bound | |
| public void setMnemonic (char mnemonic); | ||
| public ButtonModel getModel (); | ||
| public void setModel (ButtonModel newModel); | bound | |
| public Icon getPressedIcon (); | ||
| public void setPressedIcon (Icon pressedIcon); | bound | |
| public boolean isRolloverEnabled (); | ||
| public void setRolloverEnabled (boolean b); | bound | |
| public Icon getRolloverIcon (); | ||
| public void setRolloverIcon (Icon rolloverIcon); | bound | |
| public Icon getRolloverSelectedIcon (); | ||
| public void setRolloverSelectedIcon (Icon rolloverSelectedIcon); | bound | |
| public boolean isSelected (); | ||
| public void setSelected (boolean b); | ||
| public Icon getSelectedIcon (); | ||
| public void setSelectedIcon (Icon selectedIcon); | bound | |
| public Object[ ] getSelectedObjects (); | Implements:ItemSelectable synchronized | |
| public String getText (); | ||
| public void setText (String text); | bound preferred | |
| public javax.swing.plaf.ButtonUI getUI (); | ||
| public void setUI (javax.swing.plaf.ButtonUI ui); | ||
| public int getVerticalAlignment (); | ||
| public void setVerticalAlignment (int alignment); | bound | |
| public int getVerticalTextPosition (); | ||
| public void setVerticalTextPosition (int textPosition); | bound | |
| // | Public Instance Methods | |
| public void doClick (); | ||
| public void doClick (int pressTime); | ||
| // | Methods Implementing ItemSelectable | |
| public void addItemListener (java.awt.event.ItemListener l); | ||
| public Object[ ] getSelectedObjects (); | synchronized | |
| public void removeItemListener (java.awt.event.ItemListener l); | ||
| // | Public Methods Overriding JComponent | |
| public void setEnabled (boolean b); | ||
| public void updateUI (); | empty | |
| // | Protected Methods Overriding JComponent | |
| protected void paintBorder (java.awt.Graphics g); | ||
| protected String paramString (); | ||
| // | Protected Instance Methods | |
| protected int checkHorizontalKey (int key, String exception); | ||
| protected int checkVerticalKey (int key, String exception); | ||
| protected java.awt.event.ActionListener createActionListener (); | ||
| protected javax.swing.event.ChangeListener createChangeListener (); | ||
| protected java.awt.event.ItemListener createItemListener (); | ||
| protected void fireActionPerformed (java.awt.event.ActionEvent event); | ||
| protected void fireItemStateChanged (java.awt.event.ItemEvent event); | ||
| protected void fireStateChanged (); | ||
| protected void init (String text, Icon icon); | ||
| // | Protected Instance Fields | |
| protected java.awt.event.ActionListener actionListener ; | ||
| protected transient javax.swing.event.ChangeEvent changeEvent ; | ||
| protected javax.swing.event.ChangeListener changeListener ; | ||
| protected java.awt.event.ItemListener itemListener ; | ||
| protected ButtonModel model ; | ||
| // | Deprecated Public Methods | |
| # | public String getLabel (); | |
| # | public void setLabel (String label); | bound |
| } | ||
Hierarchy: Object-->Component(java.awt.image.ImageObserver,java.awt.MenuContainer,Serializable)-->Container-->JComponent(Serializable)-->AbstractButton(java.awt.ItemSelectable,SwingConstants)
Subclasses: JButton, JMenuItem, JToggleButton
Passed To: ButtonGroup.{add(), remove()}
| AbstractButton.ButtonChangeListener | Java 1.2 | |
|
|
||
| javax.swing | serializable | |
This protected inner class is a simple Serializable implementation of javax.swing. event.ChangeListener that AbstractButton uses internally to receive change notifications from its ButtonModel. Application-level code never needs to use this class.
| protected class AbstractButton.ButtonChangeListener implements javax.swing.event.ChangeListener, Serializable { | ||
| // | No Constructor | |
| // | Methods Implementing ChangeListener | |
| public void stateChanged (javax.swing.event.ChangeEvent e); | ||
| } | ||
| AbstractListModel | Java 1.2 | |
|
|
||
| javax.swing | serializable model | |
This abstract class provides a partial implementation of the ListModel interface. Subclassing AbstractListModel is usually easier than implementing ListModel from scratch. Note, however, that the DefaultListModel class is a usually an adequate ListModel implementation, so you shouldn't need to subclass AbstractListModel very often. Furthermore, the JList component provides convenience methods that often make it unnecessary to work with any kind of ListModel at all.
| public abstract class AbstractListModel implements ListModel, Serializable { | ||
| // | Public Constructors | |
| public AbstractListModel (); | ||
| // | Event Registration Methods (by event name) | |
| public void addListDataListener (javax.swing.event.ListDataListener l); | Implements:ListModel | |
| public void removeListDataListener (javax.swing.event.ListDataListener l); | Implements:ListModel | |
| // | Methods Implementing ListModel | |
| public void addListDataListener (javax.swing.event.ListDataListener l); | ||
| public abstract Object getElementAt (int index); | ||
| public abstract int getSize (); | ||
| public void removeListDataListener (javax.swing.event.ListDataListener l); | ||
| // | Protected Instance Methods | |
| protected void fireContentsChanged (Object source, int index0, int index1); | ||
| protected void fireIntervalAdded (Object source, int index0, int index1); | ||
| protected void fireIntervalRemoved (Object source, int index0, int index1); | ||
| // | Protected Instance Fields | |
| protected javax.swing.event.EventListenerList listenerList ; | ||
| } | ||
Hierarchy: Object-->AbstractListModel(ListModel,Serializable)
Subclasses: DefaultComboBoxModel, DefaultListModel
| Action | Java 1.2 | |
|
|
||
| javax.swing | event listener | |
An action is a single piece of application functionality, such as saving a file or printing a document. The actions performed by an application may be made available to the user in several different ways: in a pulldown or popup menu, in a toolbar, and from a keyboard binding, for example.
The Action interface extends java.awt.event.ActionListener and adds the ability to enable or disable the action. If an editor contains an empty document, its print action probably should not be enabled, for example. setEnabled() specifies whether the action is enabled. When an action is enabled or disabled, this change is broadcast by a java.beans.PropertyChangeEvent.
The Action interface also defines methods that associate attributes with an action. The putValue() method maps an arbitrary attribute name to an arbitrary attribute value. The getValue() method queries an attribute value. The constants defined by the Action interface specify predefined names for commonly used attributes. NAME and SMALL_ICON are the most commonly used. Finally, the actionPerformed() method, inherited from ActionListener, is responsible for performing the action.
JMenu, JPopupMenu, and JToolBar define methods that allow Action objects to be added to them. These methods query the action for its name and an icon that represents the action and use this information to present the action to the user. If the action is enabled, the component allows the user to invoke it. The JTextComponent and Keymap classes from the javax.swing.text package additionally provide techniques for mapping keystrokes to Action objects.
AbstractAction provides a useful starting point for defining your own Action classes.
| public abstract interface Action extends java.awt.event.ActionListener { | ||
| // | Public Constants | |
| public static final String DEFAULT ; | ="Default" | |
| public static final String LONG_DESCRIPTION ; | ="LongDescription" | |
| public static final String NAME ; | ="Name" | |
| public static final String SHORT_DESCRIPTION ; | ="ShortDescription" | |
| public static final String SMALL_ICON ; | ="SmallIcon" | |
| // | Event Registration Methods (by event name) | |
| public abstract void addPropertyChangeListener (java.beans.PropertyChangeListener listener); | ||
| public abstract void removePropertyChangeListener (java.beans.PropertyChangeListener listener); | ||
| // | Public Instance Methods | |
| public abstract Object getValue (String key); | ||
| public abstract boolean isEnabled (); | ||
| public abstract void putValue (String key, Object value); | ||
| public abstract void setEnabled (boolean b); | ||
| } | ||
Hierarchy: (Action(java.awt.event.ActionListener(java.util.EventListener)))
Implementations: AbstractAction
Passed To: JMenu.{add(), insert()}, JPopupMenu.{add(), insert()}, JToolBar.add(), javax.swing.text.JTextComponent.loadKeymap(), javax.swing.text.Keymap.{addActionForKeyStroke(), getKeyStrokesForAction(), setDefaultAction()}, javax.swing.text.TextAction.augmentList()
Returned By: JTextField.getActions(), javax.swing.text.DefaultEditorKit.getActions(), javax.swing.text.EditorKit.getActions(), javax.swing.text.JTextComponent.getActions(), javax.swing.text.Keymap.{getAction(), getBoundActions(), getDefaultAction()}, javax.swing.text.StyledEditorKit.getActions(), javax.swing.text.TextAction.augmentList(), javax.swing.text.html.HTMLEditorKit.getActions()
| BorderFactory | Java 1.2 | |
|
|
||
| javax.swing | ||
The static methods of this class return various types of Border objects. These methods may return previously created shared objects, making their use more memory-efficient than creating unshared Border objects with the new operator. See the various classes of the javax.swing.border package for more information on the types of borders supported by Swing.
| public class BorderFactory { | ||
| // | No Constructor | |
| // | Public Class Methods | |
| public static javax.swing.border.Border createBevelBorder (int type); | ||
| public static javax.swing.border.Border createBevelBorder (int type, java.awt.Color highlight, java.awt.Color shadow); | ||
| public static javax.swing.border.Border createBevelBorder (int type, java.awt.Color highlightOuter, java.awt.Color highlightInner, java.awt.Color shadowOuter, java.awt.Color shadowInner); | ||
| public static javax.swing.border.CompoundBorder createCompoundBorder (); | ||
| public static javax.swing.border.CompoundBorder createCompoundBorder (javax.swing.border.Border outsideBorder, javax.swing.border.Border insideBorder); | ||
| public static javax.swing.border.Border createEmptyBorder (); | ||
| public static javax.swing.border.Border createEmptyBorder (int top, int left, int bottom, int right); | ||
| public static javax.swing.border.Border createEtchedBorder (); | ||
| public static javax.swing.border.Border createEtchedBorder (java.awt.Color highlight, java.awt.Color shadow); | ||
| public static javax.swing.border.Border createLineBorder (java.awt.Color color); | ||
| public static javax.swing.border.Border createLineBorder (java.awt.Color color, int thickness); | ||
| public static javax.swing.border.Border createLoweredBevelBorder (); | ||
| public static javax.swing.border.MatteBorder createMatteBorder (int top, int left, int bottom, int right, Icon tileIcon); | ||
| public static javax.swing.border.MatteBorder createMatteBorder (int top, int left, int bottom, int right, java.awt.Color color); | ||
| public static javax.swing.border.Border createRaisedBevelBorder (); | ||
| public static javax.swing.border.TitledBorder createTitledBorder (javax.swing.border.Border border); | ||
| public static javax.swing.border.TitledBorder createTitledBorder (String title); | ||
| public static javax.swing.border.TitledBorder createTitledBorder (javax.swing.border.Border border, String title); | ||
| public static javax.swing.border.TitledBorder createTitledBorder (javax.swing.border.Border border, String title, int titleJustification, int titlePosition); | ||
| public static javax.swing.border.TitledBorder createTitledBorder (javax.swing.border.Border border, String title, int titleJustification, int titlePosition, java.awt.Font titleFont); | ||
| public static javax.swing.border.TitledBorder createTitledBorder (javax.swing.border.Border border, String title, int titleJustification, int titlePosition, java.awt.Font titleFont, java.awt.Color titleColor); | ||
| } | ||
| BoundedRangeModel | Java 1.2 | |
|
|
||
| javax.swing | model | |
This interface defines the data model used by the JScrollBar, JSlider, and JProgressBar components. The model is defined by four integer properties that obey the following relationship:
minimum <= value <= value+extent <= maximum
The value property specifies the value currently displayed by the component. It must be between the values specified by the minimum and maximum properties. The extent property specifies the amount of data displayed. For JScrollBar components, this property specifies the size of the scrollbar thumb, or knob. Note the convenience method setRangeProperties() that sets all properties of the model at once.
When any value changes, interested listeners are notified with a javax.swing.event.ChangeEvent. One additional property defined by this interface is valueIsAdjusting. If this property is true, it means that a series of rapid property changes (such as those caused when the user drags the scrollbar) is in progress. This property is false for the last change in the series, so listeners can therefore choose to ignore transient changes that have this property set to true.
DefaultBoundedRangeModel is an implementation of this interface appropriate for most uses.
| public abstract interface BoundedRangeModel { | ||
| // | Event Registration Methods (by event name) | |
| public abstract void addChangeListener (javax.swing.event.ChangeListener x); | ||
| public abstract void removeChangeListener (javax.swing.event.ChangeListener x); | ||
| // | Property Accessor Methods (by property name) | |
| public abstract int getExtent (); | ||
| public abstract void setExtent (int newExtent); | ||
| public abstract int getMaximum (); | ||
| public abstract void setMaximum (int newMaximum); | ||
| public abstract int getMinimum (); | ||
| public abstract void setMinimum (int newMinimum); | ||
| public abstract int getValue (); | ||
| public abstract void setValue (int newValue); | ||
| public abstract boolean getValueIsAdjusting (); | ||
| public abstract void setValueIsAdjusting (boolean b); | ||
| // | Public Instance Methods | |
| public abstract void setRangeProperties (int value, int extent, int min, int max, boolean adjusting); | ||
| } | ||
Implementations: DefaultBoundedRangeModel
Passed To: JProgressBar.{JProgressBar(), setModel()}, JScrollBar.setModel(), JSlider.{JSlider(), setModel()}
Returned By: JProgressBar.getModel(), JScrollBar.getModel(), JSlider.getModel(), JTextField.getHorizontalVisibility()
Type Of: JProgressBar.model, JScrollBar.model, JSlider.sliderModel
| Box | Java 1.2 | |
|
|
||
| javax.swing | serializable accessible swing component | |
This class is a container that uses the BoxLayout layout manager to arrange its children in a row or a column. Pass one of the constants BoxLayout.X_AXIS or BoxLayout.Y_AXIS to the constructor to create a horizontal or vertical box or use the static methods createHorizontalBox() and createVerticalBox(). A horizontal box attempts to lay out its children from left to right, one next to the other, at their preferred widths and tries to make each child as tall as the tallest child. A vertical box does the opposite: it lays out its children from top to bottom, trying both to maintain the preferred height of each child and to make all children as wide as the widest child.
The arrangement of children in a Box is often improved with the use of struts and glue: invisible components that exist only to improve the appearance of a layout. A horizontal strut has 0 height and has a specified value as its minimum, preferred, and maximum width. A vertical strut has 0 width and a fixed height. Struts are useful for inserting fixed amounts of space between components in a Box. Use createHorizontalStrut() and createVerticalStrut() to create struts.
Glue is a component with a preferred width or height of 0 but with an infinite maximum width or height. Glue is used to specify where extra space in a layout should go. For example, if you have three fixed-sized JButton components in a row that is wider than the sum of the button widths, placing glue between them forces them to be evenly spaced. Use createHorizontalGlue() and createVerticalGlue() to create glue components.
| public class Box extends Container implements Accessible { | ||
| // | Public Constructors | |
| public Box (int axis); | ||
| // | Inner Classes | |
| ; | ||
| ; | ||
| // | Public Class Methods | |
| public static Component createGlue (); | ||
| public static Box createHorizontalBox (); | ||
| public static Component createHorizontalGlue (); | ||
| public static Component createHorizontalStrut (int width); | ||
| public static Component createRigidArea (java.awt.Dimension d); | ||
| public static Box createVerticalBox (); | ||
| public static Component createVerticalGlue (); | ||
| public static Component createVerticalStrut (int height); | ||
| // | Property Accessor Methods (by property name) | |
| public AccessibleContext getAccessibleContext (); | Implements:Accessible | |
| public void setLayout (java.awt.LayoutManager l); | Overrides:Container | |
| // | Methods Implementing Accessible | |
| public AccessibleContext getAccessibleContext (); | ||
| // | Protected Instance Fields | |
| protected AccessibleContext accessibleContext ; | ||
| } | ||
Hierarchy: Object-->Component(java.awt.image.ImageObserver,java.awt.MenuContainer,Serializable)-->Container-->Box(Accessible)
Returned By: Box.{createHorizontalBox(), createVerticalBox()}
| Box.Filler | Java 1.2 | |
|
|
||
| javax.swing | serializable accessible swing component | |
This class implements the invisible component used to create struts and glue for use with the Box container. It allows you to create an invisible component with any specified minimum, preferred, and maximum sizes.
| public static class Box.Filler extends Component implements Accessible { | ||
| // | Public Constructors | |
| public Filler (java.awt.Dimension min, java.awt.Dimension pref, java.awt.Dimension max); | ||
| // | Inner Classes | |
| ; | ||
| // | Property Accessor Methods (by property name) | |
| public AccessibleContext getAccessibleContext (); | Implements:Accessible | |
| public java.awt.Dimension getMaximumSize (); | Overrides:Component | |
| public java.awt.Dimension getMinimumSize (); | Overrides:Component | |
| public java.awt.Dimension getPreferredSize (); | Overrides:Component | |
| // | Public Instance Methods | |
| public void changeShape (java.awt.Dimension min, java.awt.Dimension pref, java.awt.Dimension max); | ||
| // | Methods Implementing Accessible | |
| public AccessibleContext getAccessibleContext (); | ||
| // | Protected Instance Fields | |
| protected AccessibleContext accessibleContext ; | ||
| } | ||
| BoxLayout | Java 1.2 | |
|
|
||
| javax.swing | serializable layout manager | |
This class is a layout manager that arranges its children into a row or a column. It is the layout manager used by the Box container. See Box for details.
| public class BoxLayout implements java.awt.LayoutManager2, Serializable { | ||
| // | Public Constructors | |
| public BoxLayout (Container target, int axis); | ||
| // | Public Constants | |
| public static final int X_AXIS ; | =0 | |
| public static final int Y_AXIS ; | =1 | |
| // | Methods Implementing LayoutManager | |
| public void addLayoutComponent (String name, Component comp); | empty | |
| public void layoutContainer (Container target); | ||
| public java.awt.Dimension minimumLayoutSize (Container target); | ||
| public java.awt.Dimension preferredLayoutSize (Container target); | ||
| public void removeLayoutComponent (Component comp); | empty | |
| // | Methods Implementing LayoutManager2 | |
| public void addLayoutComponent (Component comp, Object constraints); | empty | |
| public float getLayoutAlignmentX (Container target); | ||
| public float getLayoutAlignmentY (Container target); | ||
| public void invalidateLayout (Container target); | ||
| public java.awt.Dimension maximumLayoutSize (Container target); | ||
| } | ||
Hierarchy: Object-->BoxLayout(java.awt.LayoutManager2(java.awt.LayoutManager),Serializable)
| ButtonGroup | Java 1.2 | |
|
|
||
| javax.swing | serializable | |
This class enforces mutual exclusion (radio behavior) for a group of toggle buttons. Once buttons are added to a ButtonGroup with the add() method, mutual exclusion is automatic, and no further action is necessary.
| public class ButtonGroup implements Serializable { | ||
| // | Public Constructors | |
| public ButtonGroup (); | ||
| // | Property Accessor Methods (by property name) | |
| public java.util.Enumeration getElements (); | ||
| public ButtonModel getSelection (); | default:null | |
| // | Public Instance Methods | |
| public void add (AbstractButton b); | ||
| public boolean isSelected (ButtonModel m); | ||
| public void remove (AbstractButton b); | ||
| public void setSelected (ButtonModel m, boolean b); | ||
| // | Protected Instance Fields | |
| protected java.util.Vector buttons ; | ||
| } | ||
Hierarchy: Object-->ButtonGroup(Serializable)
Passed To: ButtonModel.setGroup(), DefaultButtonModel.setGroup()
Type Of: DefaultButtonModel.group
| ButtonModel | Java 1.2 | |
|
|
||
| javax.swing | model | |
This interface defines the model for Swing buttons. This model consists of five boolean properties that specify the current selection state of the button and three other properties that specify an optional mnemonic, ButtonGroup, and action command (a string passed with a java.awt.event.ActionEvent) for the button.
| public abstract interface ButtonModel extends java.awt.ItemSelectable { | ||
| // | Event Registration Methods (by event name) | |
| public abstract void addActionListener (java.awt.event.ActionListener l); | ||
| public abstract void removeActionListener (java.awt.event.ActionListener l); | ||
| public abstract void addChangeListener (javax.swing.event.ChangeListener l); | ||
| public abstract void removeChangeListener (javax.swing.event.ChangeListener l); | ||
| public abstract void addItemListener (java.awt.event.ItemListener l); | ||
| public abstract void removeItemListener (java.awt.event.ItemListener l); | ||
| // | Property Accessor Methods (by property name) | |
| public abstract String getActionCommand (); | ||
| public abstract void setActionCommand (String s); | ||
| public abstract boolean isArmed (); | ||
| public abstract void setArmed (boolean b); | ||
| public abstract boolean isEnabled (); | ||
| public abstract void setEnabled (boolean b); | ||
| public abstract int getMnemonic (); | ||
| public abstract void setMnemonic (int key); | ||
| public abstract boolean isPressed (); | ||
| public abstract void setPressed (boolean b); | ||
| public abstract boolean isRollover (); | ||
| public abstract void setRollover (boolean b); | ||
| public abstract boolean isSelected (); | ||
| public abstract void setSelected (boolean b); | ||
| // | Public Instance Methods | |
| public abstract void setGroup (ButtonGroup group); | ||
| } | ||
Hierarchy: (ButtonModel(java.awt.ItemSelectable))
Implementations: DefaultButtonModel
Passed To: AbstractButton.setModel(), ButtonGroup.{isSelected(), setSelected()}, JMenu.setModel()
Returned By: AbstractButton.getModel(), ButtonGroup.getSelection()
Type Of: AbstractButton.model
| CellEditor | Java 1.2 | |
|
|
||
| javax.swing | ||
This interface defines general methods that must be implemented by any cell editor object. isCellEditable() should return true if the cell is editable and if the specified event is an appropriate event to trigger an edit. (For example, some programs might require a double-click to edit a cell.) shouldSelectCell() should return true if the given event should cause the cell to become selected or false otherwise. However, this is only a minor secondary purpose of the method. Despite its name, the primary purpose of shouldSelectCell() is to cause the cell editor to begin editing the cell. The editor can use the specified event to set the initial state (e.g., cursor position) of the editor.
getCellEditorValue() returns the value being edited. cancelCellEditing() cancels an edit. stopCellEditing() instructs the editor to stop editing and accept a partially edited value. An editor may return false if it cannot accept the current value (because the partial value is not valid, for example). If the editor stops or cancels editing itself, it sends a javax.swing.event.ChangeEvent to any registered javax.swing.event.CellEditorListener objects.
javax.swing.table.TableCellEditor and javax.swing.tree.TreeCellEditor are table- and tree-specific cell editor interfaces; DefaultCellEditor is an implementation of both those interfaces.
| public abstract interface CellEditor { | ||
| // | Event Registration Methods (by event name) | |
| public abstract void addCellEditorListener (javax.swing.event.CellEditorListener l); | ||
| public abstract void removeCellEditorListener (javax.swing.event.CellEditorListener l); | ||
| // | Public Instance Methods | |
| public abstract void cancelCellEditing (); | ||
| public abstract Object getCellEditorValue (); | ||
| public abstract boolean isCellEditable (java.util.EventObject anEvent); | ||
| public abstract boolean shouldSelectCell (java.util.EventObject anEvent); | ||
| public abstract boolean stopCellEditing (); | ||
| } | ||
Implementations: javax.swing.table.TableCellEditor, javax.swing.tree.TreeCellEditor
| CellRendererPane | Java 1.2 | |
|
|
||
| javax.swing | serializable accessible swing component | |
This class is used by Swing components that rely on cell renderer interfaces, such as ListCellRenderer, javax.swing.table.TableCellRenderer, and javax.swing.tree.TreeCellRenderer. The methods of this class are used to paint a single cell renderer component at various specified locations within a container.
| public class CellRendererPane extends Container implements Accessible { | ||
| // | Public Constructors | |
| public CellRendererPane (); | ||
| // | Inner Classes | |
| ; | ||
| // | Property Accessor Methods (by property name) | |
| public AccessibleContext getAccessibleContext (); | Implements:Accessible default:AccessibleCellRendererPane | |
| // | Public Instance Methods | |
| public void paintComponent (java.awt.Graphics g, Component c, Container p, java.awt.Rectangle r); | ||
| public void paintComponent (java.awt.Graphics g, Component c, Container p, int x, int y, int w, int h); | ||
| public void paintComponent (java.awt.Graphics g, Component c, Container p, int x, int y, int w, int h, boolean shouldValidate); | ||
| // | Methods Implementing Accessible | |
| public AccessibleContext getAccessibleContext (); | default:AccessibleCellRendererPane | |
| // | Public Methods Overriding Container | |
| public void invalidate (); | empty | |
| public void paint (java.awt.Graphics g); | empty | |
| public void update (java.awt.Graphics g); | empty | |
| // | Protected Methods Overriding Container | |
| protected void addImpl (Component x, Object constraints, int index); | ||
| // | Protected Instance Fields | |
| protected AccessibleContext accessibleContext ; | ||
| } | ||
Hierarchy: Object-->Component(java.awt.image.ImageObserver,java.awt.MenuContainer,Serializable)-->Container-->CellRendererPane(Accessible)
| ComboBoxEditor | Java 1.2 | |
|
|
||
| javax.swing | ||
This interface defines the methods that must be implemented by an object that wishes to serve as the editor object for a JComboBox component. It is typically implemented as part of a pluggable look-and-feel and is not normally used by application programmers.
| public abstract interface ComboBoxEditor { | ||
| // | Event Registration Methods (by event name) | |
| public abstract void addActionListener (java.awt.event.ActionListener l); | ||
| public abstract void removeActionListener (java.awt.event.ActionListener l); | ||
| // | Public Instance Methods | |
| public abstract Component getEditorComponent (); | ||
| public abstract Object getItem (); | ||
| public abstract void selectAll (); | ||
| public abstract void setItem (Object anObject); | ||
| } | ||
Passed To: JComboBox.{configureEditor(), setEditor()}
Returned By: JComboBox.getEditor()
Type Of: JComboBox.editor
| ComboBoxModel | Java 1.2 | |
|
|
||
| javax.swing | model | |
This interface defines the basic model used by the JComboBox component. The JComboBox allows the user to select a value from a list or type a value directly. Therefore, ComboBoxModel extends ListModel to add support for a selected item, in addition to the list of items that ListModel already supports. See also MutableComboBoxModel and DefaultComboBoxModel.
| public abstract interface ComboBoxModel extends ListModel { | ||
| // | Public Instance Methods | |
| public abstract Object getSelectedItem (); | ||
| public abstract void setSelectedItem (Object anItem); | ||
| } | ||
Hierarchy: (ComboBoxModel(ListModel))
Implementations: MutableComboBoxModel
Passed To: JComboBox.{JComboBox(), setModel()}, JComboBox.KeySelectionManager.selectionForKey()
Returned By: JComboBox.getModel()
Type Of: JComboBox.dataModel
| DebugGraphics | Java 1.2 | |
|
|
||
| javax.swing | ||
This subclass of java.awt.Graphics reimplements most of the methods of its superclass to facilitate debugging of drawing operations. Instances of this class are rarely used directly; programs can enable graphics debugging by calling setDebugGraphicsOptions() on any Swing component.
| public class DebugGraphics extends java.awt.Graphics { | ||
| // | Public Constructors | |
| public DebugGraphics (); | ||
| public DebugGraphics (java.awt.Graphics graphics); | ||
| public DebugGraphics (java.awt.Graphics graphics, JComponent component); | ||
| // | Public Constants | |
| public static final int BUFFERED_OPTION ; | =4 | |
| public static final int FLASH_OPTION ; | =2 | |
| public static final int LOG_OPTION ; | =1 | |
| public static final int NONE_OPTION ; | =-1 | |
| // | Public Class Methods | |
| public static java.awt.Color flashColor (); | ||
| public static int flashCount (); | ||
| public static int flashTime (); | ||
| public static java.io.PrintStream logStream (); | ||
| public static void setFlashColor (java.awt.Color flashColor); | ||
| public static void setFlashCount (int flashCount); | ||
| public static void setFlashTime (int flashTime); | ||
| public static void setLogStream (java.io.PrintStream stream); | ||
| // | Property Accessor Methods (by property name) | |
| public java.awt.Shape getClip (); | Overrides:Graphics | |
| public void setClip (java.awt.Shape clip); | Overrides:Graphics | |
| public void setClip (int x, int y, int width, int height); | Overrides:Graphics | |
| public java.awt.Rectangle getClipBounds (); | Overrides:Graphics | |
| public java.awt.Color getColor (); | Overrides:Graphics | |
| public void setColor (java.awt.Color aColor); | Overrides:Graphics | |
| public int getDebugOptions (); | default:0 | |
| public void setDebugOptions (int options); | ||
| public boolean isDrawingBuffer (); | default:false | |
| public java.awt.Font getFont (); | Overrides:Graphics | |
| public void setFont (java.awt.Font aFont); | Overrides:Graphics | |
| public java.awt.FontMetrics getFontMetrics (); | Overrides:Graphics | |
| public java.awt.FontMetrics getFontMetrics (java.awt.Font f); | Overrides:Graphics | |
| // | Public Methods Overriding Graphics | |
| public void clearRect (int x, int y, int width, int height); | ||
| public void clipRect (int x, int y, int width, int height); | ||
| public void copyArea (int x, int y, int width, int height, int destX, int destY); | ||
| public java.awt.Graphics create (); | ||
| public java.awt.Graphics create (int x, int y, int width, int height); | ||
| public void dispose (); | ||
| public void draw3DRect (int x, int y, int width, int height, boolean raised); | ||
| public void drawArc (int x, int y, int width, int height, int startAngle, int arcAngle); | ||
| public void drawBytes (byte[ ] data, int offset, int length, int x, int y); | ||
| public void drawChars (char[ ] data, int offset, int length, int x, int y); | ||
| public boolean drawImage (java.awt.Image img, int x, int y, java.awt.image.ImageObserver observer); | ||
| public boolean drawImage (java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver observer); | ||
| public boolean drawImage (java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer); | ||
| public boolean drawImage (java.awt.Image img, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.ImageObserver observer); | ||
| public boolean drawImage (java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver observer); | ||
| public boolean drawImage (java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgcolor, java.awt.image.ImageObserver observer); | ||
| public void drawLine (int x1, int y1, int x2, int y2); | ||
| public void drawOval (int x, int y, int width, int height); | ||
| public void drawPolygon (int[ ] xPoints, int[ ] yPoints, int nPoints); | ||
| public void drawPolyline (int[ ] xPoints, int[ ] yPoints, int nPoints); | ||
| public void drawRect (int x, int y, int width, int height); | ||
| public void drawRoundRect (int x, int y, int width, int height, int arcWidth, int arcHeight); | ||
| public void drawString (java.text.AttributedCharacterIterator iterator, int x, int y); | ||
| public void drawString (String aString, int x, int y); | ||
| public void fill3DRect (int x, int y, int width, int height, boolean raised); | ||
| public void fillArc (int x, int y, int width, int height, int startAngle, int arcAngle); | ||
| public void fillOval (int x, int y, int width, int height); | ||
| public void fillPolygon (int[ ] xPoints, int[ ] yPoints, int nPoints); | ||
| public void fillRect (int x, int y, int width, int height); | ||
| public void fillRoundRect (int x, int y, int width, int height, int arcWidth, int arcHeight); | ||
| public void setPaintMode (); | ||
| public void setXORMode (java.awt.Color aColor); | ||
| public void translate (int x, int y); | ||
| } | ||
Hierarchy: Object-->java.awt.Graphics-->DebugGraphics
| DefaultBoundedRangeModel | Java 1.2 | |
|
|
||
| javax.swing | serializable model | |
This class is an implementation of the BoundedRangeModel appropriate for most uses. See BoundedRangeModel for details.
| public class DefaultBoundedRangeModel implements BoundedRangeModel, Serializable { | ||
| // | Public Constructors | |
| public DefaultBoundedRangeModel (); | ||
| public DefaultBoundedRangeModel (int value, int extent, int min, int max); | ||
| // | Event Registration Methods (by event name) | |
| public void addChangeListener (javax.swing.event.ChangeListener l); | Implements:BoundedRangeModel | |
| public void removeChangeListener (javax.swing.event.ChangeListener l); | Implements:BoundedRangeModel | |
| // | Methods Implementing BoundedRangeModel | |
| public void addChangeListener (javax.swing.event.ChangeListener l); | ||
| public int getExtent (); | default:0 | |
| public int getMaximum (); | default:100 | |
| public int getMinimum (); | default:0 | |
| public int getValue (); | default:0 | |
| public boolean getValueIsAdjusting (); | default:false | |
| public void removeChangeListener (javax.swing.event.ChangeListener l); | ||
| public void setExtent (int n); | ||
| public void setMaximum (int n); | ||
| public void setMinimum (int n); | ||
| public void setRangeProperties (int newValue, int newExtent, int newMin, int newMax, boolean adjusting); | ||
| public void setValue (int n); | ||
| public void setValueIsAdjusting (boolean b); | ||
| // | Public Methods Overriding Object | |
| public String toString (); | ||
| // | Protected Instance Methods | |
| protected void fireStateChanged (); | ||
| // | Protected Instance Fields | |
| protected transient javax.swing.event.ChangeEvent changeEvent ; | ||
| protected javax.swing.event.EventListenerList listenerList ; | ||
| } | ||
Hierarchy: Object-->DefaultBoundedRangeModel(BoundedRangeModel,Serializable)
| Defau |