1 package net.sourceforge.selfesteem.applet;
2
3 import javax.swing.*;
4 import javax.swing.tree.DefaultTreeModel;
5 import javax.swing.tree.TreePath;
6 import java.awt.*;
7 import java.io.PrintWriter;
8 import java.io.StringWriter;
9
10 public class SelfEsteem extends JApplet implements Source {
11 public void init() {
12 try {
13 load();
14
15 } catch (Throwable e) {
16 StringWriter writer = new StringWriter();
17 e.printStackTrace(new PrintWriter(writer));
18
19 TextArea text = new TextArea(writer.toString());
20 text.setEditable(false);
21 text.setBackground(Color.white);
22 getContentPane().add(text);
23
24 e.printStackTrace();
25 }
26 }
27
28 private void load() {
29 MyTreeNode root = new Parser().parse(this);
30
31 getContentPane().add(new JScrollPane(buildTree(root)));
32 }
33
34 public static JTreeTable buildTree(MyTreeNode root) {
35 JTreeTable treeTable = new JTreeTable(new DefaultTreeModel(root));
36 treeTable.setDefaultRenderer(Integer.class, new ProgressBarRenderer());
37 treeTable.getColumnModel().getColumn(1).setMaxWidth(125);
38 treeTable.getColumnModel().getColumn(1).setMinWidth(125);
39
40 JTreeTable.TreeTableCellRenderer tree = treeTable.tree;
41
42 tree.setCellRenderer(new MyCellRenderer());
43 for (int i = 0; i < tree.getRowCount(); i++) {
44 tree.expandRow(i);
45 }
46 for (int i = 0; i < tree.getRowCount(); i++) {
47 MyTreeNode node = (MyTreeNode) tree.getPathForRow(i).getLastPathComponent();
48 if (node.isStory()) {
49 tree.collapseRow(i);
50 }
51 }
52 return treeTable;
53 }
54 }
This page was automatically generated by Maven