KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > barracuda > testbed > workbench > WorkBench


1 package org.enhydra.barracuda.testbed.workbench;
2
3 import java.awt.*;
4 import java.awt.event.*;
5 import java.util.*;
6 import javax.swing.*;
7 import javax.swing.event.*;
8 import javax.swing.plaf.*;
9 import javax.swing.plaf.metal.*;
10
11 import org.enhydra.barracuda.testbed.workbench.stress.URLStressTester;
12 import org.enhydra.barracuda.testbed.workbench.jdbc.JDBCTester;
13
14 /**
15  * This class provides the JPanel that acts as the WorkBench. You should
16  * run this class directly to launch the Workbench GUI.
17  *
18  * It contains a JTabbedPane which in turn contains an instance of
19  * various workbench utilities. You should refer to those files for
20  * full documentation.
21  *
22  * The basic purpose of this class (and subpackages) is to provide a nice
23  * place to add gui utilities that we write to aid in debugging Barracuda
24  * and DB webapps. Right now there are 2 distinct components: a URL Stress
25  * tester utility (allows you to stress test a simple URL), and a JDBC DB SQL
26  * utility (allows you to connect to a DB via JDBC and execute SQL commands).
27  */

28 public class WorkBench extends JPanel {
29
30     //debug vars
31
public static int showDebug = 2;
32
33     //objects
34

35     
36     /**
37      * Public constructor
38      */

39     public WorkBench() {
40         //init the screen and catch any unexpected errors
41
try {
42             initViews();
43         } catch (Exception JavaDoc be) {
44             System.out.println ("Error initializing "+this);
45             be.printStackTrace();
46         }
47     }
48     
49     /**
50      * This method is responsible for laying out the
51      * UI components.
52      *
53      * @throws Exception
54      */

55     private void initViews() throws Exception JavaDoc {
56         //basic setup
57
this.setLayout(new BorderLayout());
58
59         //create a tab pane
60
JTabbedPane jtpTabs = new JTabbedPane();
61         this.add(jtpTabs, BorderLayout.CENTER);
62         
63         //...add the URLStressTester
64
URLStressTester urlStressTester = new URLStressTester();
65         jtpTabs.addTab("URL Stress Tester", null, urlStressTester, "Perform URL Stress Testing");
66         
67         //...add the JDBCTester
68
JDBCTester jdbcTester = new JDBCTester();
69         jtpTabs.addTab("JDBC Tester", null, jdbcTester, "Connect to a JDBC Datasource");
70         
71         //...add the ??? example
72
//(if you want to add something to the workbench, this is the place to do it)
73
}
74
75
76     public static void main(String JavaDoc[] args) {
77         //create the master frame
78
JFrame frame = new JFrame();
79         frame.addWindowListener(new WindowAdapter() {
80             public void windowClosing(java.awt.event.WindowEvent JavaDoc event) {
81                 System.exit(0); // close the application
82
}
83         });
84
85         //add in the WorkBench
86
WorkBench masterView = new WorkBench();
87         frame.getContentPane().add(masterView, BorderLayout.CENTER);
88
89         //finally, size and show
90
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
91         frame.setTitle("Barracuda Workbench");
92         frame.setSize(new Dimension(800, 600));
93         frame.setLocation((d.width-frame.getSize().width)/2, (d.height-frame.getSize().height)/2);
94         frame.setVisible(true);
95     }
96
97     /**
98      * static initializer for look & feel adjustments
99      */

100     static {
101         try {
102             //set the look & feel and then get the UIDefaults
103
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
104             UIDefaults uid = UIManager.getLookAndFeelDefaults();
105             
106             //override the default CheckBox foreground to be the same color as JLabels
107
uid.put("CheckBox.foreground", uid.get("Label.foreground"));
108             uid.put("RadioButton.foreground", uid.get("Label.foreground"));
109         } catch (Exception JavaDoc e) {}
110     }
111     
112
113 }
114
Popular Tags