TWaverのswingベースのアプリケーション--ツリー
2405 ワード
package com;
import java.awt.*;
import javax.swing.*;
import twaver.*;
import twaver.network.*;
import twaver.tree.*;
public class DummyDemo extends JFrame {
//BorderLayout bo=new BorderLayout();
// 、
TDataBox box = new TDataBox(" ");
TTree tree = new TTree(box);
TNetwork network=new TNetwork(box);
private JPanel treePane = new JPanel(new BorderLayout());
public DummyDemo() {
this.getContentPane().add(network, BorderLayout.CENTER);
this.setSize(700, 700);
//
loadData();
// --- new tree JScrollPane ,
// JScrollPane network JSplitPane
tree.setEnsureVisibleOnSelected(true);
JScrollPane scroll = new JScrollPane(tree);
treePane.add(scroll, BorderLayout.CENTER);
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePane, network);
split.setDividerLocation(180);
this.add(split);
}
private void loadData() {
//
Node atm1 = new Node();
atm1.setName("ATM1");
atm1.setLocation(100, 100);
box.addElement(atm1);
Node atm2 = new Node();
atm2.setName("ATM2");
atm2.setLocation(200, 100);
box.addElement(atm2);
Node sdh1 = new Node();
sdh1.setName("SDH1");
sdh1.setLocation(100, 200);
box.addElement(sdh1);
Node sdh2 = new Node();
sdh2.setName("SDH2");
sdh2.setLocation(200, 200);
box.addElement(sdh2);
// Dummy( )
Dummy atm=new Dummy();
atm.setName(" ");
atm.addChild(atm1);
atm.addChild(atm2);
box.addElement(atm);
Dummy sdh=new Dummy();
sdh.setName(" ");
sdh.addChild(sdh1);
sdh.addChild(sdh2);
box.addElement(sdh);
}
public static void main(String[] args) throws Exception {
DummyDemo test = new DummyDemo();
test.show();
}
}