Book Home Java Enterprise in a Nutshell Search this book

Chapter 28. The javax.swing.plaf Package

This package contains classes and interfaces used in the definition of a pluggable look-and-feel (hence the acronym "plaf"). It defines abstract UI delegate classes for Swing components. Typically, only look-and-feel developers and advanced component developers need to use this package. Figure 28-1 shows the class hierarchy of this package. See Chapter 3, "Swing Programming Topics", for further discussion of Swing's pluggable look-and-feel architecture.

The javax.swing.plaf.basic package contains classes that extend the UI delegate classes of this package to create a basic pluggable look-and-feel UI framework. The classes in javax.swing.plaf.metal extend the classes of javax.swing.plaf.basic to implement the default Java look-and-feel. The classes in javax.swing.plaf.multi also extend the abstract classes of javax.swing.plaf to produce a multiplexing look-and-feel that combines a primary look-and-feel with one or more auxiliary look-and-feel implementations. These various subpackages of javax.swing.plaf are not documented in this book because they are very infrequently used and because they are straightforward implementations of the classes in this package that do not define any new public APIs.

figure

Figure 28-1. The javax.swing.plaf package

BorderUIResourceJava 1.2
javax.swing.plafserializable

This class implements the UIResource marker interface and serves as a wrapper around an existing javax.swing.border.Border object. It differs from other UIResource implementations in this package, in that it does not subclass an existing resource type. In addition, this class includes inner classes that provide UIResource versions of the standard Swing border classes. Several static methods exist for obtaining shared instances of commonly used UIResource borders.

public class BorderUIResource implements javax.swing.border.Border, Serializable, UIResource {
// Public Constructors
public BorderUIResource (javax.swing.border.Border delegate);
// Inner Classes
;
;
;
;
;
;
;
// Public Class Methods
public static javax.swing.border.Border getBlackLineBorderUIResource ();
public static javax.swing.border.Border getEtchedBorderUIResource ();
public static javax.swing.border.Border getLoweredBevelBorderUIResource ();
public static javax.swing.border.Border getRaisedBevelBorderUIResource ();
// Methods Implementing Border
public java.awt.Insets getBorderInsets (Component c);
public boolean isBorderOpaque ();
public void paintBorder (Component c, java.awt.Graphics g, int x, int y, int width, int height);
}
BorderUIResource.BevelBorderUIResourceJava 1.2
javax.swing.plafserializable

A trivial subclass of BevelBorder that implements the UIResource marker interface.

public static class BorderUIResource.BevelBorderUIResource extends javax.swing.border.BevelBorder implements UIResource {
// Public Constructors
public BevelBorderUIResource (int bevelType);
public BevelBorderUIResource (int bevelType, java.awt.Color highlight, java.awt.Color shadow);
public BevelBorderUIResource (int bevelType, java.awt.Color highlightOuter, java.awt.Color highlightInner, java.awt.Color shadowOuter, java.awt.Color shadowInner);
}
BorderUIResource.CompoundBorderUIResourceJava 1.2
javax.swing.plafserializable

A trivial subclass of CompoundBorder that implements the UIResource marker interface.

public static class BorderUIResource.CompoundBorderUIResource extends javax.swing.border.CompoundBorder implements UIResource {
// Public Constructors
public CompoundBorderUIResource (javax.swing.border.Border outsideBorder, javax.swing.border.Border insideBorder);
}
BorderUIResource.EmptyBorderUIResourceJava 1.2
javax.swing.plafserializable

A trivial subclass of EmptyBorder that implements the UIResource marker interface.

public static class BorderUIResource.EmptyBorderUIResource extends javax.swing.border.EmptyBorder implements UIResource {
// Public Constructors
public EmptyBorderUIResource (java.awt.Insets insets);
public EmptyBorderUIResource (int top, int left, int bottom, int right);
}
BorderUIResource.EtchedBorderUIResourceJava 1.2
javax.swing.plafserializable

A trivial subclass of EtchedBorder that implements the UIResource marker interface.

public static class BorderUIResource.EtchedBorderUIResource extends javax.swing.border.EtchedBorder implements UIResource {
// Public Constructors
public EtchedBorderUIResource ();
public EtchedBorderUIResource (int etchType);
public EtchedBorderUIResource (java.awt.Color highlight, java.awt.Color shadow);
public EtchedBorderUIResource (int etchType, java.awt.Color highlight, java.awt.Color shadow);
}
BorderUIResource.LineBorderUIResourceJava 1.2
javax.swing.plafserializable

A trivial subclass of LineBorder that implements the UIResource marker interface.

public static class BorderUIResource.LineBorderUIResource extends javax.swing.border.LineBorder implements UIResource {
// Public Constructors
public LineBorderUIResource (java.awt.Color color);
public LineBorderUIResource (java.awt.Color color, int thickness);
}
BorderUIResource.MatteBorderUIResourceJava 1.2
javax.swing.plafserializable

A trivial subclass of MatteBorder that implements the UIResource marker interface.

public static class BorderUIResource.MatteBorderUIResource extends javax.swing.border.MatteBorder implements UIResource {
// Public Constructors
public MatteBorderUIResource (Icon tileIcon);
public MatteBorderUIResource (int top, int left, int bottom, int right, Icon tileIcon);
public MatteBorderUIResource (int top, int left, int bottom, int right, java.awt.Color color);
}
BorderUIResource.TitledBorderUIResourceJava 1.2
javax.swing.plafserializable

A trivial subclass of TitledBorder that implements the UIResource marker interface.

public static class BorderUIResource.TitledBorderUIResource extends javax.swing.border.TitledBorder implements UIResource {
// Public Constructors
public TitledBorderUIResource (javax.swing.border.Border border);
public TitledBorderUIResource (String title);
public TitledBorderUIResource (javax.swing.border.Border border, String title);
public TitledBorderUIResource (javax.swing.border.Border border, String title, int titleJustification, int titlePosition);
public TitledBorderUIResource (javax.swing.border.Border border, String title, int titleJustification, int titlePosition, java.awt.Font titleFont);
public TitledBorderUIResource (javax.swing.border.Border border, String title, int titleJustification, int titlePosition, java.awt.Font titleFont, java.awt.Color titleColor);
}
ButtonUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JButton.

public abstract class ButtonUI extends ComponentUI {
// Public Constructors
public ButtonUI ();
}

Subclasses: MenuItemUI

Passed To: AbstractButton.setUI()

Returned By: AbstractButton.getUI()

ColorChooserUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JColorChooser.

public abstract class ColorChooserUI extends ComponentUI {
// Public Constructors
public ColorChooserUI ();
}

Passed To: JColorChooser.setUI()

Returned By: JColorChooser.getUI()

ColorUIResourceJava 1.2
javax.swing.plafserializable

A trivial subclass of java.awt.Color that implements the UIResource marker interface.

public class ColorUIResource extends java.awt.Color implements UIResource {
// Public Constructors
public ColorUIResource (java.awt.Color c);
public ColorUIResource (int rgb);
public ColorUIResource (float r, float g, float b);
public ColorUIResource (int r, int g, int b);
}
ComboBoxUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JComboBox.

public abstract class ComboBoxUI extends ComponentUI {
// Public Constructors
public ComboBoxUI ();
// Public Instance Methods
public abstract boolean isFocusTraversable (JComboBox c);
public abstract boolean isPopupVisible (JComboBox c);
public abstract void setPopupVisible (JComboBox c, boolean v);
}

Passed To: JComboBox.setUI()

Returned By: JComboBox.getUI()

ComponentUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JComponent.

public abstract class ComponentUI {
// Public Constructors
public ComponentUI ();
// Public Class Methods
public static ComponentUI createUI (JComponent c);
// Public Instance Methods
public boolean contains (JComponent c, int x, int y);
public Accessible getAccessibleChild (JComponent c, int i);
public int getAccessibleChildrenCount (JComponent c);
public java.awt.Dimension getMaximumSize (JComponent c);
public java.awt.Dimension getMinimumSize (JComponent c);
public java.awt.Dimension getPreferredSize (JComponent c); constant
public void installUI (JComponent c); empty
public void paint (java.awt.Graphics g, JComponent c); empty
public void uninstallUI (JComponent c); empty
public void update (java.awt.Graphics g, JComponent c);
}

Subclasses: Too many classes to list.

Passed To: JComponent.setUI()

Returned By: UIDefaults.getUI(), UIManager.getUI(), ComponentUI.createUI()

Type Of: JComponent.ui

DesktopIconUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JDesktopIcon.

public abstract class DesktopIconUI extends ComponentUI {
// Public Constructors
public DesktopIconUI ();
}

Passed To: JInternalFrame.JDesktopIcon.setUI()

Returned By: JInternalFrame.JDesktopIcon.getUI()

DesktopPaneUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JDesktopPane.

public abstract class DesktopPaneUI extends ComponentUI {
// Public Constructors
public DesktopPaneUI ();
}

Passed To: JDesktopPane.setUI()

Returned By: JDesktopPane.getUI()

DimensionUIResourceJava 1.2
javax.swing.plafcloneable serializable

A trivial subclass of java.awt.Dimension that implements the UIResource marker interface.

public class DimensionUIResource extends java.awt.Dimension implements UIResource {
// Public Constructors
public DimensionUIResource (int width, int height);
}
FileChooserUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JFileChooser.

public abstract class FileChooserUI extends ComponentUI {
// Public Constructors
public FileChooserUI ();
// Public Instance Methods
public abstract void ensureFileIsVisible (JFileChooser fc, java.io.File f);
public abstract javax.swing.filechooser.FileFilter getAcceptAllFileFilter (JFileChooser fc);
public abstract String getApproveButtonText (JFileChooser fc);
public abstract String getDialogTitle (JFileChooser fc);
public abstract javax.swing.filechooser.FileView getFileView (JFileChooser fc);
public abstract void rescanCurrentDirectory (JFileChooser fc);
}

Returned By: JFileChooser.getUI()

FontUIResourceJava 1.2
javax.swing.plafserializable

A trivial subclass of java.awt.Font that implements the UIResource marker interface.

public class FontUIResource extends java.awt.Font implements UIResource {
// Public Constructors
public FontUIResource (java.awt.Font font);
public FontUIResource (String name, int style, int size);
}
IconUIResourceJava 1.2
javax.swing.plafserializable

A trivial subclass of javax.swing.Icon that implements the UIResource marker interface.

public class IconUIResource implements Icon, Serializable, UIResource {
// Public Constructors
public IconUIResource (Icon delegate);
// Methods Implementing Icon
public int getIconHeight ();
public int getIconWidth ();
public void paintIcon (Component c, java.awt.Graphics g, int x, int y);
}
InsetsUIResourceJava 1.2
javax.swing.plafcloneable serializable

A trivial subclass of java.awt.Insets that implements the UIResource marker interface.

public class InsetsUIResource extends java.awt.Insets implements UIResource {
// Public Constructors
public InsetsUIResource (int top, int left, int bottom, int right);
}
InternalFrameUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JInternalFrame.

public abstract class InternalFrameUI extends ComponentUI {
// Public Constructors
public InternalFrameUI ();
}

Passed To: JInternalFrame.setUI()

Returned By: JInternalFrame.getUI()

LabelUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JLabel.

public abstract class LabelUI extends ComponentUI {
// Public Constructors
public LabelUI ();
}

Passed To: JLabel.setUI()

Returned By: JLabel.getUI()

ListUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JList.

public abstract class ListUI extends ComponentUI {
// Public Constructors
public ListUI ();
// Public Instance Methods
public abstract java.awt.Rectangle getCellBounds (JList list, int index1, int index2);
public abstract java.awt.Point indexToLocation (JList list, int index);
public abstract int locationToIndex (JList list, java.awt.Point location);
}

Passed To: JList.setUI()

Returned By: JList.getUI()

MenuBarUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JMenuBar.

public abstract class MenuBarUI extends ComponentUI {
// Public Constructors
public MenuBarUI ();
}

Passed To: JMenuBar.setUI()

Returned By: JMenuBar.getUI()

MenuItemUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JMenuItem.

public abstract class MenuItemUI extends ButtonUI {
// Public Constructors
public MenuItemUI ();
}

Passed To: JMenuItem.setUI()

OptionPaneUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JOptionPane.

public abstract class OptionPaneUI extends ComponentUI {
// Public Constructors
public OptionPaneUI ();
// Public Instance Methods
public abstract boolean containsCustomComponents (JOptionPane op);
public abstract void selectInitialValue (JOptionPane op);
}

Passed To: JOptionPane.setUI()

Returned By: JOptionPane.getUI()

PanelUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JPanel.

public abstract class PanelUI extends ComponentUI {
// Public Constructors
public PanelUI ();
}
PopupMenuUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JPopupMenu.

public abstract class PopupMenuUI extends ComponentUI {
// Public Constructors
public PopupMenuUI ();
}

Passed To: JPopupMenu.setUI()

Returned By: JPopupMenu.getUI()

ProgressBarUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JProgressBar.

public abstract class ProgressBarUI extends ComponentUI {
// Public Constructors
public ProgressBarUI ();
}

Passed To: JProgressBar.setUI()

Returned By: JProgressBar.getUI()

ScrollBarUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JScrollBar.

public abstract class ScrollBarUI extends ComponentUI {
// Public Constructors
public ScrollBarUI ();
}

Returned By: JScrollBar.getUI()

ScrollPaneUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JScrollPane.

public abstract class ScrollPaneUI extends ComponentUI {
// Public Constructors
public ScrollPaneUI ();
}

Passed To: JScrollPane.setUI()

Returned By: JScrollPane.getUI()

SeparatorUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JSeparator.

public abstract class SeparatorUI extends ComponentUI {
// Public Constructors
public SeparatorUI ();
}

Passed To: JSeparator.setUI()

Returned By: JSeparator.getUI()

SliderUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JSlider.

public abstract class SliderUI extends ComponentUI {
// Public Constructors
public SliderUI ();
}

Passed To: JSlider.setUI()

Returned By: JSlider.getUI()

SplitPaneUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JSplitPane.

public abstract class SplitPaneUI extends ComponentUI {
// Public Constructors
public SplitPaneUI ();
// Public Instance Methods
public abstract void finishedPaintingChildren (JSplitPane jc, java.awt.Graphics g);
public abstract int getDividerLocation (JSplitPane jc);
public abstract int getMaximumDividerLocation (JSplitPane jc);
public abstract int getMinimumDividerLocation (JSplitPane jc);
public abstract void resetToPreferredSizes (JSplitPane jc);
public abstract void setDividerLocation (JSplitPane jc, int location);
}

Passed To: JSplitPane.setUI()

Returned By: JSplitPane.getUI()

TabbedPaneUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JTabbedPane.

public abstract class TabbedPaneUI extends ComponentUI {
// Public Constructors
public TabbedPaneUI ();
// Public Instance Methods
public abstract java.awt.Rectangle getTabBounds (JTabbedPane pane, int index);
public abstract int getTabRunCount (JTabbedPane pane);
public abstract int tabForCoordinate (JTabbedPane pane, int x, int y);
}

Passed To: JTabbedPane.setUI()

Returned By: JTabbedPane.getUI()

TableHeaderUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JTableHeader.

public abstract class TableHeaderUI extends ComponentUI {
// Public Constructors
public TableHeaderUI ();
}

Passed To: javax.swing.table.JTableHeader.setUI()

Returned By: javax.swing.table.JTableHeader.getUI()

TableUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JTable.

public abstract class TableUI extends ComponentUI {
// Public Constructors
public TableUI ();
}

Passed To: JTable.setUI()

Returned By: JTable.getUI()

TextUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JTextComponent.

public abstract class TextUI extends ComponentUI {
// Public Constructors
public TextUI ();
// Public Instance Methods
public abstract void damageRange (javax.swing.text.JTextComponent t, int p0, int p1);
public abstract void damageRange (javax.swing.text.JTextComponent t, int p0, int p1, javax.swing.text.Position.Bias firstBias, javax.swing.text.Position.Bias secondBias);
public abstract javax.swing.text.EditorKit getEditorKit (javax.swing.text.JTextComponent t);
public abstract int getNextVisualPositionFrom (javax.swing.text.JTextComponent t, int pos, javax.swing.text.Position.Bias b, int direction, javax.swing.text.Position.Bias[ ] biasRet) throws javax.swing.text.BadLocationException;
public abstract javax.swing.text.View getRootView (javax.swing.text.JTextComponent t);
public abstract java.awt.Rectangle modelToView (javax.swing.text.JTextComponent t, int pos) throws javax.swing.text.BadLocationException;
public abstract java.awt.Rectangle modelToView (javax.swing.text.JTextComponent t, int pos, javax.swing.text.Position.Bias bias) throws javax.swing.text.BadLocationException;
public abstract int viewToModel (javax.swing.text.JTextComponent t, java.awt.Point pt);
public abstract int viewToModel (javax.swing.text.JTextComponent t, java.awt.Point pt, javax.swing.text.Position.Bias[ ] biasReturn);
}

Passed To: javax.swing.text.JTextComponent.setUI()

Returned By: javax.swing.text.JTextComponent.getUI()

ToolBarUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JToolBar.

public abstract class ToolBarUI extends ComponentUI {
// Public Constructors
public ToolBarUI ();
}

Passed To: JToolBar.setUI()

Returned By: JToolBar.getUI()

ToolTipUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JToolTip.

public abstract class ToolTipUI extends ComponentUI {
// Public Constructors
public ToolTipUI ();
}

Returned By: JToolTip.getUI()

TreeUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JTree.

public abstract class TreeUI extends ComponentUI {
// Public Constructors
public TreeUI ();
// Public Instance Methods
public abstract void cancelEditing (JTree tree);
public abstract javax.swing.tree.TreePath getClosestPathForLocation (JTree tree, int x, int y);
public abstract javax.swing.tree.TreePath getEditingPath (JTree tree);
public abstract java.awt.Rectangle getPathBounds (JTree tree, javax.swing.tree.TreePath path);
public abstract javax.swing.tree.TreePath getPathForRow (JTree tree, int row);
public abstract int getRowCount (JTree tree);
public abstract int getRowForPath (JTree tree, javax.swing.tree.TreePath path);
public abstract boolean isEditing (JTree tree);
public abstract void startEditingAtPath (JTree tree, javax.swing.tree.TreePath path);
public abstract boolean stopEditing (JTree tree);
}

Passed To: JTree.setUI()

Returned By: JTree.getUI()

UIResourceJava 1.2
javax.swing.plaf

This marker interface defines no methods; it is used to distinguish user-interface property values specified by a UI delegate from property values specified explicitly by an application. Only programmers writing custom look-and-feels or custom UI delegate objects need to use this interface. Application-level code never uses it.

Any component properties set by the installUI() method of a UI delegate object should be set to objects that implement the UIResource interface. This allows the uninstallUI() method to determine which properties were explicitly set by the application and leave these properties unchanged.

The requirement for property values that implement UIResource means that the javax.swing.plaf package contains a number of trivial wrapper classes that extend common resource types such as java.awt.Color, java.awt.Font, and so on. These wrapper classes add no new functionality but exist simply to implement UIResource.

public abstract interface UIResource {
}

Implementations: DefaultListCellRenderer.UIResource, JScrollPane.ScrollBar, ScrollPaneLayout.UIResource, BorderUIResource, BorderUIResource.BevelBorderUIResource, BorderUIResource.CompoundBorderUIResource, BorderUIResource.EmptyBorderUIResource, BorderUIResource.EtchedBorderUIResource, BorderUIResource.LineBorderUIResource, BorderUIResource.MatteBorderUIResource, BorderUIResource.TitledBorderUIResource, ColorUIResource, DimensionUIResource, FontUIResource, IconUIResource, InsetsUIResource, javax.swing.table.DefaultTableCellRenderer.UIResource

ViewportUIJava 1.2
javax.swing.plaf

This abstract class defines the methods that must be implemented by a pluggable look-and-feel delegate for JViewport.

public abstract class ViewportUI extends ComponentUI {
// Public Constructors
public ViewportUI ();
}


Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.