1 package thinlet.drafts; 2 3 import java.awt.*; 4 import thinlet.*; 5 6 9 public class Drafts extends Thinlet { 10 11 14 public Drafts() { 15 try { 17 add(parse("drafts.xml")); 18 } catch (Exception exc) { exc.printStackTrace(); } 19 } 20 21 24 public void loadDraft(Object splitpane, Object tree) { 25 if (getCount(splitpane) > 2) { 26 remove(getItem(splitpane, 1)); 27 } 28 Object node = getSelectedItem(tree); 29 if (node != null) { 30 Object draft = getProperty(node, "draft"); 31 if (draft == null) { 32 String ui = (String ) getProperty(node, "ui"); 33 String logic = (String ) getProperty(node, "logic"); 34 if ((ui != null) && (logic != null)) { 35 try { 36 Object handler = Class.forName(logic).getConstructor(null).newInstance(null); 37 draft = parse(ui, handler); 38 putProperty(node, "draft", draft); 39 } catch (Exception exc) { exc.printStackTrace(); } 40 } 41 } 42 if (draft != null) { 43 add(splitpane, draft, 1); 44 } 45 } 46 } 47 48 51 public void paint(Graphics g) { 52 Utilities.getUtilities().initGraphics(g); 53 super.paint(g); 54 } 55 56 59 protected void handleException(Throwable throwable) { 60 new ExceptionDialog(this, throwable); 61 } 62 63 66 public static void main(String [] args) { 67 new FrameLauncher("Thinlet Drafts", new Drafts(), 580, 435); 68 } 69 } | Popular Tags |