KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > plaf > synth > SynthStyleFactory


1 /*
2  * @(#)SynthStyleFactory.java 1.8 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package javax.swing.plaf.synth;
8
9 import java.awt.*;
10 import java.util.*;
11 import javax.swing.plaf.*;
12 import javax.swing.*;
13
14 /**
15  * Factory used for obtaining <code>SynthStyle</code>s. Each of the
16  * Synth <code>ComponentUI</code>s will call into the current
17  * <code>SynthStyleFactory</code> to obtain a <code>SynthStyle</code>
18  * for each of the distinct regions they have.
19  * <p>
20  * The following example creates a custom <code>SynthStyleFactory</code>
21  * that returns a different style based on the <code>Region</code>:
22  * <pre>
23  * class MyStyleFactory extends SynthStyleFactory {
24  * public SynthStyle getStyle(JComponent c, Region id) {
25  * if (id == Region.BUTTON) {
26  * return buttonStyle;
27  * }
28  * else if (id == Region.TREE) {
29  * return treeStyle;
30  * }
31  * return defaultStyle;
32  * }
33  * }
34  * SynthLookAndFeel laf = new SynthLookAndFeel();
35  * UIManager.setLookAndFeel(laf);
36  * SynthLookAndFeel.setStyleFactory(new MyStyleFactory());
37  * </pre>
38  *
39  * @see SynthStyleFactory
40  * @see SynthStyle
41  *
42  * @version 1.8, 12/19/03
43  * @since 1.5
44  * @author Scott Violet
45  */

46 public abstract class SynthStyleFactory {
47     /**
48      * Creates a <code>SynthStyleFactory</code>.
49      */

50     public SynthStyleFactory() {
51     }
52
53     /**
54      * Returns the style for the specified Component.
55      *
56      * @param c Component asking for
57      * @param id Region identifier
58      * @return SynthStyle for region.
59      */

60     public abstract SynthStyle JavaDoc getStyle(JComponent c, Region JavaDoc id);
61 }
62
Popular Tags