KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > dods > wizard > TraceDialog


1 package org.enhydra.dods.wizard;
2
3 import java.awt.Button JavaDoc;
4 import java.awt.Dialog JavaDoc;
5 import java.awt.Dimension JavaDoc;
6 import java.awt.Font JavaDoc;
7 import java.awt.Frame JavaDoc;
8 import java.awt.GridBagLayout JavaDoc;
9 import java.awt.Panel JavaDoc;
10 import java.awt.SystemColor JavaDoc;
11 import java.awt.TextArea JavaDoc;
12 import java.awt.event.ActionEvent JavaDoc;
13 import java.awt.event.ActionListener JavaDoc;
14 import java.awt.event.KeyAdapter JavaDoc;
15 import java.awt.event.KeyEvent JavaDoc;
16 import java.awt.event.WindowEvent JavaDoc;
17
18 /**
19  * This trace dialog is used for showing output of ExecThread class.
20  *
21  * @author Nenad Vico
22  * @version 1.0
23  */

24 public class TraceDialog extends Dialog JavaDoc {
25     Panel JavaDoc mainPanel;
26     GridBagLayout JavaDoc gridBagLayout;
27     XYLayout xyLayout;
28     Button JavaDoc bOK;
29     TextArea JavaDoc taTrace;
30     Process JavaDoc process;
31
32     /**
33      * Consrtuctor(Frame, String)
34      *
35      * @param frame Frame from which the Trace Dialog has been invited.
36      * @param title Title of the Trace Dialog.
37      */

38     public TraceDialog(Frame JavaDoc frame, String JavaDoc title) {
39         super(frame, title, false);
40         mainPanel = new Panel JavaDoc();
41         xyLayout = new XYLayout();
42         bOK = new Button JavaDoc();
43         taTrace = new TextArea JavaDoc();
44         enableEvents(64L);
45         try {
46             jbInit();
47             add(mainPanel);
48             pack();
49         } catch (Exception JavaDoc exception) {
50             exception.printStackTrace();
51         }
52         this.setResizable(false);
53         this.setSize(new Dimension JavaDoc(790, 560));
54     }
55
56     private void jbInit()
57         throws Exception JavaDoc {
58         mainPanel.setLayout(xyLayout);
59         mainPanel.setBackground(SystemColor.control);
60         mainPanel.setSize(new Dimension JavaDoc(790, 560));
61         taTrace.setColumns(122);
62         if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
63             taTrace.setRows(34);
64         } else {
65             taTrace.setRows(39);
66         }
67         taTrace.setBackground(SystemColor.control);
68         taTrace.setEditable(false);
69         taTrace.setFont(new Font JavaDoc("Dialog", 0, 10));
70         taTrace.setSize(new Dimension JavaDoc(750, 560));
71         bOK.setLabel("Cancel");
72         bOK.addActionListener(new ActionListener JavaDoc() {
73             public void actionPerformed(ActionEvent JavaDoc actionevent) {
74                 bOK_actionPerformed(actionevent);
75             }
76         });
77         bOK.addKeyListener(new KeyAdapter JavaDoc() {
78             public void keyPressed(KeyEvent JavaDoc keyevent) {
79                 bOKKeyPressed(keyevent);
80             }
81         });
82         mainPanel.add(taTrace, new XYConstraints(12, 10, 758, 490));
83         mainPanel.add(bOK, new XYConstraints(330, 508, 80, 20));
84     }
85
86     /**
87      * Set default focus on buttom.
88      */

89     public void setDefaultFocus() {
90         bOK.requestFocus();
91     }
92
93     /**
94      * Appends new line Trace Dialog.
95      *
96      * @param s Line that will be appended to Trace Dialog.
97      */

98     public void appendLine(String JavaDoc s) {
99         taTrace.append(s);
100     }
101
102     /**
103      * Set name to the button.
104      *
105      * @param s Name of the button.
106      */

107     public void setButtonName(String JavaDoc s) {
108         bOK.setLabel(s);
109     }
110
111     protected void processWindowEvent(WindowEvent JavaDoc windowevent) {
112         if (windowevent.getID() == 201) {
113             cancel();
114         }
115         super.processWindowEvent(windowevent);
116     }
117
118     void cancel() {
119         dispose();
120     }
121
122     void bOK_actionPerformed(ActionEvent JavaDoc actionevent) {
123         cancel();
124     }
125
126     void bOKKeyPressed(KeyEvent JavaDoc keyevent) {
127         int i = keyevent.getKeyCode();
128
129         if (i == 27 || i == 10) {
130             cancel();
131         }
132     }
133 }
134
Popular Tags