01: /*
02: * Copyright (C) 2004 TiongHiang Lee
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: * Email: thlee@onemindsoft.org
19: */
20:
21: package org.onemind.swingweb.widgetdemo;
22:
23: import java.awt.BorderLayout;
24: import java.awt.GridLayout;
25: import java.awt.event.ActionEvent;
26: import java.awt.event.ActionListener;
27: import javax.swing.*;
28:
29: public class DemoConsole extends JFrame {
30:
31: private JTabbedPane _tabs = new JTabbedPane();
32:
33: private JTextArea _console = new JTextArea();
34:
35: public DemoConsole() {
36: JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
37: getContentPane().add(splitPane);
38: splitPane.setTopComponent(_tabs);
39: JPanel consoleArea = getConsoleArea();
40: splitPane.setBottomComponent(consoleArea);
41: addDemo(new LabelButtonTextDemo(this ));
42: //addDemo(new EditorPaneDemo(this));
43: addDemo(new TableDemo(this ));
44: }
45:
46: public JPanel getConsoleArea() {
47: JPanel c = new JPanel();
48: JScrollPane scroll = new JScrollPane(_console);
49: c.setLayout(new BorderLayout());
50: c.add(scroll, BorderLayout.CENTER);
51: JPanel controls = new JPanel();
52: controls.setLayout(new GridLayout(0, 1));
53: JButton btnClear = new JButton("Clear");
54: btnClear.addActionListener(new ActionListener() {
55:
56: public void actionPerformed(ActionEvent e) {
57: _console.setText("");
58: }
59: });
60: JButton btnSubmit = new JButton("Submit");
61: btnSubmit.addActionListener(new ActionListener() {
62:
63: public void actionPerformed(ActionEvent e) {
64: //just a submit button
65: }
66: });
67: controls.add(btnClear);
68: controls.add(btnSubmit);
69: c.add(controls, BorderLayout.EAST);
70: return c;
71: }
72:
73: public void addDemo(AbstractDemo demo) {
74: _tabs.addTab(demo.getTitle(), demo);
75: }
76:
77: public void log(String msg) {
78: _console.append(msg + "\n");
79: }
80:
81: public static void main(String args[]) {
82: DemoConsole d = new DemoConsole();
83: //d.pack();
84: d.setSize(800, 800);
85: d.show();
86: }
87: }
|