KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > thinlet > drafts > Style


1 package thinlet.drafts;
2
3 import java.awt.*;
4 import thinlet.*;
5
6 /**
7  *
8  */

9 public class Style {
10     
11     /**
12      *
13      */

14     public void loadFontNames(Thinlet thinlet, Object JavaDoc namecombo) {
15         String JavaDoc[] fontlist = Utilities.getUtilities().getFontList();
16         String JavaDoc currentname = thinlet.getFont().getName();
17         for (int i = 0; i < fontlist.length; i++) {
18             Object JavaDoc choice = Thinlet.create("choice");
19             thinlet.setString(choice, "text", fontlist[i]);
20             thinlet.add(namecombo, choice);
21             
22             if (fontlist[i].equals(currentname)) {
23                 thinlet.setInteger(namecombo, "selected", i);
24             }
25         }
26     }
27     
28     /**
29      *
30      */

31     public void loadFontSizes(Thinlet thinlet, Object JavaDoc sizecombo) {
32         int[] sizelist = { 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 };
33         int currentsize = thinlet.getFont().getSize();
34         for (int i = 0; i < sizelist.length; i++) {
35             Object JavaDoc choice = Thinlet.create("choice");
36             thinlet.setString(choice, "text", String.valueOf(sizelist[i]));
37             thinlet.add(sizecombo, choice);
38             
39             if (sizelist[i] == currentsize) {
40                 thinlet.setInteger(sizecombo, "selected", i);
41                 thinlet.setString(sizecombo, "text", String.valueOf(currentsize)); // fix it
42
}
43         }
44     }
45     
46     /**
47      *
48      */

49     public void changeFont(Thinlet thinlet, String JavaDoc name, boolean bold, boolean italic, String JavaDoc size) {
50         thinlet.setFont(new Font(name, (bold ? Font.BOLD : 0) |
51             (italic ? Font.ITALIC : 0), Integer.parseInt(size)));
52     }
53     
54     /**
55      *
56      */

57     public void changeColors(Thinlet thinlet, int index) {
58         switch (index) {
59             case 0: //default
60
thinlet.setColors(0xe6e6e6, 0x000000, 0xffffff,
61                     0x909090, 0xb0b0b0, 0xededed, 0xb9b9b9, 0x89899a, 0xc5c5dd);
62                 break;
63             case 1: //yellow
64
thinlet.setColors(0xeeeecc, 0x000000, 0xffffff,
65                     0x999966, 0xb0b096, 0xededcb, 0xcccc99, 0xcc6600, 0xffcc66);
66                 break;
67             case 2: //blue
68
thinlet.setColors(0x6375d6, 0xffffff, 0x7f8fdd,
69                     0xd6dff5, 0x9caae5, 0x666666, 0x003399, 0xff3333, 0x666666);
70                 break;
71             case 3: //xp background text textbackground border disable hover press focus select
72
thinlet.setFont(new Font("Tahoma", Font.PLAIN, 11));
73                 thinlet.setColors(0xece9d8, 0x000000, 0xffffff,
74                     0x909090, 0xb0b0b0, 0xededed, 0xc7c5b2, 0xe68b2c, 0xf2c977);
75         }
76     }
77 }
Popular Tags