Module java.desktop

Class SynthStyleFactory

java.lang.Object
javax.swing.plaf.synth.SynthStyleFactory

public abstract class SynthStyleFactory extends Object
用于获取SynthStyle的工厂。每个Synth ComponentUI都会调用当前的SynthStyleFactory来为它们的每个不同区域获取一个SynthStyle

以下示例创建了一个自定义的SynthStyleFactory,根据Region返回不同的样式:

 class MyStyleFactory extends SynthStyleFactory {
     public SynthStyle getStyle(JComponent c, Region id) {
         if (id == Region.BUTTON) {
             return buttonStyle;
         }
         else if (id == Region.TREE) {
             return treeStyle;
         }
         return defaultStyle;
     }
 }
 SynthLookAndFeel laf = new SynthLookAndFeel();
 UIManager.setLookAndFeel(laf);
 SynthLookAndFeel.setStyleFactory(new MyStyleFactory());
 
自 JDK 版本:
1.5
参见:
  • Constructor Details

    • SynthStyleFactory

      public SynthStyleFactory()
      创建一个SynthStyleFactory
  • Method Details

    • getStyle

      public abstract SynthStyle getStyle(JComponent c, Region id)
      返回指定组件的样式。
      参数:
      c - 请求样式的组件
      id - 区域标识符
      返回:
      区域的SynthStyle。