Java Reference
In-Depth Information
To demonstrate the use of client properties, the following two lines change the
JToolBar.isRollover attribute of a JToolBar to Boolean.TRUE . Other toolbars might not want
this attribute set to Boolean.TRUE and would therefore leave that setting at Boolean.FALSE .
JToolBar toolbar = new JToolBar();
toolbar.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
Creating a New UI Delegate
Sometimes, modifying a few of the UIResource elements of the Swing component isn't quite
enough to get the appearance or behavior you desire. When this is the case, you need to create
a new UI delegate for the component. Each Swing component has its own UI delegate for
controlling the view and controller aspects of its MVC architecture.
Table 20-8 provides a listing of the Swing components, the abstract class that describes
the UI delegate for each component, and the specific implementations for the predefined
look and feel classes. For instance, calling the getUIClassID() method of a JToolBar will
return the class ID string of "ToolBarUI" for its UI delegate. If you then ask the UIManager for
the specific implementation of this UI delegate for the currently installed look and feel with a
call to UIManager.get("ToolBarUI") , an implementation of the abstract ToolBarUI class is
returned. Therefore, if you want to develop a custom look and feel for the JToolBar component,
you must create an implementation of the abstract ToolBarUI class.
Table 20-8. Swing Component Delegates
Swing Component
Class ID String
Implementation Class
JButton
ButtonUI
ButtonUI
JCheckBox
CheckBoxUI
ButtonUI
JCheckBoxMenuItem
CheckBoxMenuItemUI
MenuItemUI
JColorChooser
ColorChooserUI
ColorChooserUI
JComboBox
ComboBoxUI
ComboBoxUI
JComponent
n/a
ComponentUI
JDesktopPane
DesktopPaneUI
DesktopPaneUI
JEditorPane
EditorPaneUI
TextUI
JFileChooser
FileChooserUI
FileChooserUI
JFormattedTextField
FormattedTextFieldUI
TextUI
JInternalFrame
InternalFrameUI
InternalFrameUI
JInternalFrame.JDesktopIcon
DesktopIconUI
DesktopIconUI
JLabel
LabelUI
LabelUI
JList
ListUI
ListUI
JMenu
MenuUI
MenuItemUI
JMenuBar
MenuBarUI
MenuBarUI
Search WWH ::




Custom Search