javax.swing.plaf.synth

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

Synth is a skinnable look and feel in which all painting is delegated. Synth does not provide a default look. In order to use Synth you need to specify a file, or provide a {@link javax.swing.plaf.synth.SynthStyleFactory}. Both configuration options require an understanding of the synth architecture, which is described below, as well as an understanding of Swing's architecture.

Unless otherwise specified null is not a legal value to any of the methods defined in the synth package and if passed in will result in a NullPointerException.

Synth

Each {@link javax.swing.plaf.ComponentUI} implementation in Synth associates itself with one {@link javax.swing.plaf.synth.SynthStyle} per {@link javax.swing.plaf.synth.Region}, most Components only have one Region and therefor only one SynthStyle. SynthStyle is used to access all style related properties: fonts, colors and other Component properties. In addition SynthStyles are used to obtain {@link javax.swing.plaf.synth.SynthPainter}s for painting the background, border, focus and other portions of a Component. The ComponentUIs obtain SynthStyles from a {@link javax.swing.plaf.synth.SynthStyleFactory}. A SynthStyleFactory can be provided directly by way of {@link javax.swing.plaf.synth.SynthLookAndFeel#setStyleFactory(javax.swing.plaf.synth.SynthStyleFactory)}, or indirectly by way of {@link javax.swing.plaf.synth.SynthLookAndFeel#load}. The following example uses the SynthLookAndFeel.load() method to configure a SynthLookAndFeel and sets it as the current look and feel:

  SynthLookAndFeel laf = new SynthLookAndFeel();
  laf.load(MyClass.class.getResourceAsStream("laf.xml"), MyClass.class);
  UIManager.setLookAndFeel(laf);
      

Many JComponents are broken down into smaller pieces and identified by the type safe enumeration in {@link javax.swing.plaf.synth.Region}. For example, a JTabbedPane consists of a Region for the JTabbedPane ({@link javax.swing.plaf.synth.Region#TABBED_PANE}), the content area ({@link javax.swing.plaf.synth.Region#TABBED_PANE_CONTENT}), the area behind the tabs ({@link javax.swing.plaf.synth.Region#TABBED_PANE_TAB_AREA}), and the tabs ({@link javax.swing.plaf.synth.Region#TABBED_PANE_TAB}). Each Region of each JComponent will have a SynthStyle. This allows you to customize individual pieces of each region of each JComponent.

Many of the Synth methods take a {@link javax.swing.plaf.synth.SynthContext}. This is used to provide information about the current Component and includes: the {@link javax.swing.plaf.synth.SynthStyle} associated with the current {@link javax.swing.plaf.synth.Region}, the state of the Component as a bitmask (refer to {@link javax.swing.plaf.synth.SynthConstants} for the valid states), and a {@link javax.swing.plaf.synth.Region} identifying the portion of the Component being painted.

All text rendering by non-JTextComponents is delegated to a {@link javax.swing.plaf.synth.SynthGraphicsUtils}, which is obtained using the {@link javax.swing.plaf.synth.SynthStyle} method {@link javax.swing.plaf.synth.SynthStyle#getGraphicsUtils}. You can customize text rendering by supplying your own {@link javax.swing.plaf.synth.SynthGraphicsUtils}.

Notes on specific components

JTree

Synth provides a region for the cells of a tree: Region.TREE_CELL. To specify the colors of the renderer you'll want to provide a style for the TREE_CELL region. The following illustrates this:

  <style id="treeCellStyle">
    <opaque value="TRUE"/>
    <state>
      <color value="WHITE" type="TEXT_FOREGROUND"/>
      <color value="RED" type="TEXT_BACKGROUND"/>
    </state>
    <state value="SELECTED">
      <color value="RED" type="TEXT_FOREGROUND"/>
      <color value="WHITE" type="BACKGROUND"/>
    </state>
  </style>
  <bind style="treeCellStyle" type="region" key="TreeCell"/>

This specifies a color combination of red on white, when selected, and white on red when not selected. To see the background you need to specify that labels are not opaque. The following XML fragment does that:

  <style id="labelStyle">
    <opaque value="FALSE"/>
  </style>
  <bind style="labelStyle" type="region" key="Label"/>

JList and JTable

The colors that the renderers for JList and JTable use are specified by way of the list and table Regions. The following XML fragment illustrates how to specify red on white, when selected, and white on red when not selected:

  <style id="style">
    <opaque value="TRUE"/>
    <state>
      <color value="WHITE" type="TEXT_FOREGROUND"/>
      <color value="RED" type="TEXT_BACKGROUND"/>
      <color value="RED" type="BACKGROUND"/>
    </state>
    <state value="SELECTED">
      <color value="RED" type="TEXT_FOREGROUND"/>
      <color value="WHITE" type="TEXT_BACKGROUND"/>
    </state>
  </style>
  <bind style="style" type="region" key="Table"/>
  <bind style="style" type="region" key="List"/>
Java Source File NameTypeComment
ColorType.javaClass A typesafe enumeration of colors that can be fetched from a style.

Each SynthStyle has a set of ColorTypes that are accessed by way of the SynthStyle.getColor(SynthContextColorType) method.

DefaultMenuLayout.javaClass The default layout manager for Popup menus and menubars.
DefaultSynthStyleFactory.javaClass Factory used for obtaining styles.
ImagePainter.javaClass ImagePainter fills in the specified region using an Image.
ParsedSynthStyle.javaClass ParsedSynthStyle are the SynthStyle's that SynthParser creates.
Region.javaClass A distinct rendering area of a Swing component.
SynthArrowButton.javaClass JButton object that draws a scaled Arrow in one of the cardinal directions.
SynthBorder.javaClass SynthBorder is a border that delegates to a Painter.
SynthButtonUI.javaClass Synth's ButtonUI implementation.
SynthCheckBoxMenuItemUI.javaClass Synth's CheckBoxMenuItemUI.
SynthCheckBoxUI.javaClass Synth's CheckBoxUI.
SynthColorChooserUI.javaClass Synth's ColorChooserUI.
SynthComboBoxUI.javaClass Synth's ComboBoxUI.
SynthComboPopup.javaClass Synth's ComboPopup.
SynthConstants.javaInterface Constants used by Synth.
SynthContext.javaClass An immutable transient object containing contextual information about a Region.
SynthDefaultLookup.javaClass SynthDefaultLookup redirects all lookup calls to the SynthContext.
SynthDesktopIconUI.javaClass Synth L&F for a minimized window on a desktop.
SynthDesktopPaneUI.javaClass Synth L&F for a desktop.
SynthEditorPaneUI.javaClass Provides the look and feel for a JEditorPane in the Synth look and feel.
SynthFormattedTextFieldUI.javaClass Provides the look and feel implementation for JFormattedTextField.
SynthGraphicsUtils.javaClass Wrapper for primitive graphics calls.
SynthInternalFrameTitlePane.javaClass
SynthInternalFrameUI.javaClass Synth's InternalFrameUI.
SynthLabelUI.javaClass Synth's LabelUI.
SynthListUI.javaClass Synth's ListUI.
SynthLookAndFeel.javaClass SynthLookAndFeel provides the basis for creating a customized look and feel.
SynthMenuBarUI.javaClass Synth's MenuBarUI.
SynthMenuItemUI.javaClass Synth's MenuItemUI.
SynthMenuUI.javaClass Synth's MenuUI.
SynthOptionPaneUI.javaClass Synth's OptionPaneUI.
SynthPainter.javaClass SynthPainter is used for painting portions of JComponents.
SynthPanelUI.javaClass Synth's PanelUI.
SynthParser.javaClass
SynthPasswordFieldUI.javaClass Provides the Synth look and feel for a password field.
SynthPopupMenuUI.javaClass Synth's PopupMenuUI.
SynthProgressBarUI.javaClass Synth's ProgressBarUI.
SynthRadioButtonMenuItemUI.javaClass Synth's RadioButtonMenuItemUI.
SynthRadioButtonUI.javaClass Synth's RadioButtonUI.
SynthRootPaneUI.javaClass Synth's RootPaneUI.
SynthScrollBarUI.javaClass Synth's ScrollBarUI.
SynthScrollPaneUI.javaClass Synth's ScrollPaneUI.
SynthSeparatorUI.javaClass A Synth L&F implementation of SeparatorUI.
SynthSliderUI.javaClass Synth's SliderUI.
SynthSpinnerUI.javaClass Synth's SpinnerUI.
SynthSplitPaneDivider.javaClass Synth's SplitPaneDivider.
SynthSplitPaneUI.javaClass Synth's SplitPaneUI.
SynthStyle.javaClass SynthStyle is a set of style properties. Each SynthUI references at least one SynthStyle that is obtained using a SynthStyleFactory.
SynthStyleFactory.javaClass Factory used for obtaining SynthStyles.
SynthTabbedPaneUI.javaClass Looks up 'selectedTabPadInsets' from the Style, which will be additional insets for the selected tab.
SynthTableHeaderUI.javaClass
SynthTableUI.javaClass
SynthTextAreaUI.javaClass Provides the look and feel for a plain text editor in the Synth look and feel.
SynthTextFieldUI.javaClass Basis of a look and feel for a JTextField in the Synth look and feel.

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

SynthTextPaneUI.javaClass Provides the look and feel for a styled text editor in the Synth look and feel.

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

SynthToggleButtonUI.javaClass Synth's ToggleButtonUI.
SynthToolBarUI.javaClass A Synth L&F implementation of ToolBarUI.
SynthToolTipUI.javaClass Synth's ToolTipUI.
SynthTreeUI.javaClass Skinnable TreeUI.
SynthViewportUI.javaClass Synth's ViewportUI.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.