パッケージ javax.swing.plaf.synth
SynthStyleFactory
を提供する必要があります。 どちらの構成オプションを使用する場合も、次に説明する合成アーキテクチャの知識とSwingのアーキテクチャの知識が必要です。
特に指定されていないかぎり、Synthパッケージに定義されたメソッドに対してnullは有効な値ではないため、nullが渡されると、NullPointerException
がスローされます。
Synth
SynthのそれぞれのComponentUI
実装では、それ自体をRegion
ごとに1つのSynthStyle
と関連付けますが、ほとんどのComponent
がRegion
を1つしか持っていないため、SynthStyle
も1つだけとなります。 SynthStyle
は、スタイルに関連したすべてのプロパティ(フォント、色などのComponent
のプロパティ)にアクセスするために使用されます。 また、SynthStyle
は、Component
のバックグラウンド、ボーダー、フォーカスなどの部分をペイントするためにSynthPainter
を取得する際にも使用されます。 ComponentUI
は、SynthStyle
をSynthStyleFactory
から取得します。 SynthStyleFactory
は、SynthLookAndFeel.setStyleFactory(javax.swing.plaf.synth.SynthStyleFactory)
を介して直接提供することも、SynthLookAndFeel.load(java.io.InputStream, java.lang.Class<?>)
を介して間接的に提供することもできます。 次の例では、SynthLookAndFeel.load()
メソッドを使用してSynthLookAndFeel
を構成し、それを現在のLook & Feelとして設定しています。
SynthLookAndFeel laf = new SynthLookAndFeel();
laf.load(MyClass.class.getResourceAsStream("laf.xml"), MyClass.class);
UIManager.setLookAndFeel(laf);
多くのJComponent
は小さく分割され、Region
内の型保証された列挙によって識別されます。 たとえば、JTabbedPane
は、JTabbedPane
(Region.TABBED_PANE
)のRegion
、コンテンツ領域(Region.TABBED_PANE_CONTENT
)、タブ(Region.TABBED_PANE_TAB_AREA
)の背後にある領域、およびタブ(Region.TABBED_PANE_TAB
)で構成されます。 各JComponent
の各Region
にはSynthStyle
が1つずつあります。 これにより、各JComponent
の各領域の個々の部分をカスタマイズできます。
多くのSynthメソッドはSynthContext
を取ります。 これは、現在のComponent
に関する情報を提供するために使用され、現在のRegion
に関連付けられたSynthStyle
、Component
の状態を表すビット・マスク(有効な状態については、SynthConstants
を参照)、およびペイントされるComponent
の部分を識別するRegion
が含まれています。
JTextComponent
以外によるテキストの描画はすべて、SynthGraphicsUtils
に委譲され、これは、SynthStyle
のメソッドSynthStyle.getGraphicsUtils(javax.swing.plaf.synth.SynthContext)
を使って取得されます。 テキスト描画は、独自のSynthGraphicsUtils
を指定することでカスタマイズできます。
各コンポーネントのノート
JTree
Synthは、ツリーのセル用の領域Region.TREE_CELL
を提供します。 レンダラの色を指定するには、TREE_CELL
領域にスタイルを提供します。 次に、この例を示します。
<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"/>
この例では、選択されているときは白地に赤、選択されていないときは赤地に白の色の組み合わせを指定しています。 バックグラウンドを表示するには、ラベルを透明にする必要があります。 このためには、次のXML (抜粋)を使用します。
<style id="labelStyle">
<opaque value="FALSE"/>
</style>
<bind style="labelStyle" type="region" key="Label"/>
JListとJTable
JListとJTableのレンダラで使用する色は、リスト領域とテーブル領域を使って指定します。 次のXML (抜粋)は、選択されているときは白地に赤、選択されていないときは赤地に白の色を指定する方法を示しています。
<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"/>
-
インタフェースのサマリー インタフェース 説明 SynthConstants Synthが使用する定数です。SynthIcon SynthContext
を渡されたアイコン。SynthUI SynthUIは、特定のコンポーネントのSynthContextを取得するために使用します。 -
クラスのサマリー クラス 説明 ColorType スタイルから取得できる型保証された色の列挙です。Region Swingコンポーネントの個別の描画領域です。SynthButtonUI JButton
のSynth L&F UIの委譲を提供します。SynthCheckBoxMenuItemUI JCheckBoxMenuItem
のSynth L&F UIの委譲を提供します。SynthCheckBoxUI JCheckBox
のSynth L&F UIの委譲を提供します。SynthColorChooserUI JColorChooser
のSynth L&F UIの委譲を提供します。SynthComboBoxUI JComboBox
のSynth L&F UIの委譲を提供します。SynthContext Region
に関するコンテキスト依存の情報を含む不変の一時オブジェクトです。SynthDesktopIconUI デスクトップ上の最小化された内部フレームのSynth L&F UIの委譲を提供します。SynthDesktopPaneUI JDesktopPane
のSynth L&F UIの委譲を提供します。SynthEditorPaneUI JEditorPane
のSynth L&F UIの委譲を提供します。SynthFormattedTextFieldUI JFormattedTextField
のSynth L&F UIの委譲を提供します。SynthGraphicsUtils 単純な図形の呼出しのためのラッパーです。SynthInternalFrameUI JInternalFrame
のSynth L&F UIの委譲を提供します。SynthLabelUI JLabel
のSynth L&F UIの委譲を提供します。SynthListUI JList
のSynth L&F UIの委譲を提供します。SynthLookAndFeel SynthLookAndFeelは、カスタマイズされたLook & Feelを作成するための基礎を提供します。SynthMenuBarUI JMenuBar
のSynth L&F UIの委譲を提供します。SynthMenuItemUI JMenuItem
のSynth L&F UIの委譲を提供します。SynthMenuUI JMenu
のSynth L&F UIの委譲を提供します。SynthOptionPaneUI JOptionPane
のSynth L&F UIの委譲を提供します。SynthPainter SynthPainter
は、JComponent
の一部分をペイントするときに使用します。SynthPanelUI JPanel
のSynth L&F UIの委譲を提供します。SynthPasswordFieldUI JPasswordField
のSynth L&F UIの委譲を提供します。SynthPopupMenuUI JPopupMenu
のSynth L&F UIの委譲を提供します。SynthProgressBarUI JProgressBar
のSynth L&F UIの委譲を提供します。SynthRadioButtonMenuItemUI JRadioButtonMenuItem
のSynth L&F UIの委譲を提供します。SynthRadioButtonUI JRadioButton
のSynth L&F UIの委譲を提供します。SynthRootPaneUI JRootPane
のSynth L&F UIの委譲を提供します。SynthScrollBarUI JScrollBar
のSynth L&F UIの委譲を提供します。SynthScrollPaneUI JScrollPane
のSynth L&F UIの委譲を提供します。SynthSeparatorUI JSeparator
のSynth L&F UIの委譲を提供します。SynthSliderUI JSlider
のSynth L&F UIの委譲を提供します。SynthSpinnerUI JSpinner
のSynth L&F UIの委譲を提供します。SynthSplitPaneUI JSplitPane
のSynth L&F UIの委譲を提供します。SynthStyle SynthStyle
は、スタイル・プロパティのセットです。SynthStyleFactory SynthStyle
を取得するために使用するファクトリです。SynthTabbedPaneUI JTabbedPane
のSynth L&F UIの委譲を提供します。SynthTableHeaderUI JTableHeader
のSynth L&F UIの委譲を提供します。SynthTableUI JTable
のSynth L&F UIの委譲を提供します。SynthTextAreaUI Synth Look & Feelのプレーン・テキスト・エディタのLook & Feelを提供します。SynthTextFieldUI JTextField
のSynth L&F UIの委譲を提供します。SynthTextPaneUI Synth Look & Feelの書式付きテキスト・エディタのLook & Feelを提供します。SynthToggleButtonUI JToggleButton
のSynth L&F UIの委譲を提供します。SynthToolBarUI JToolBar
のSynth L&F UIの委譲を提供します。SynthToolTipUI JToolTip
のSynth L&F UIの委譲を提供します。SynthTreeUI JTree
のSynth L&F UIの委譲を提供します。SynthViewportUI JViewport
のSynth L&F UIの委譲を提供します。