KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > thinlet > drafts > Drafts


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

9 public class Drafts extends Thinlet {
10
11     /**
12      *
13      */

14     public Drafts() {
15         //setFont(new Font("Trebuchet MS", Font.PLAIN, 12));
16
try {
17             add(parse("drafts.xml"));
18         } catch (Exception JavaDoc exc) { exc.printStackTrace(); }
19     }
20     
21     /**
22      *
23      */

24     public void loadDraft(Object JavaDoc splitpane, Object JavaDoc tree) {
25         if (getCount(splitpane) > 2) {
26             remove(getItem(splitpane, 1));
27         }
28         Object JavaDoc node = getSelectedItem(tree);
29         if (node != null) {
30             Object JavaDoc draft = getProperty(node, "draft");
31             if (draft == null) {
32                 String JavaDoc ui = (String JavaDoc) getProperty(node, "ui");
33                 String JavaDoc logic = (String JavaDoc) getProperty(node, "logic");
34                 if ((ui != null) && (logic != null)) {
35                     try {
36                         Object JavaDoc handler = Class.forName(logic).getConstructor(null).newInstance(null);
37                         draft = parse(ui, handler);
38                         putProperty(node, "draft", draft);
39                     } catch (Exception JavaDoc exc) { exc.printStackTrace(); }
40                 }
41             }
42             if (draft != null) {
43                 add(splitpane, draft, 1);
44             }
45         }
46     }
47     
48     /**
49      *
50      */

51     public void paint(Graphics g) {
52         Utilities.getUtilities().initGraphics(g);
53         super.paint(g);
54     }
55     
56     /**
57      *
58      */

59     protected void handleException(Throwable JavaDoc throwable) {
60         new ExceptionDialog(this, throwable);
61     }
62     
63     /**
64      *
65      */

66     public static void main(String JavaDoc[] args) {
67         new FrameLauncher("Thinlet Drafts", new Drafts(), 580, 435);
68     }
69 }
Popular Tags