1 package org.enhydra.dods.wizard; 2 3 import java.awt.Button ; 4 import java.awt.Dialog ; 5 import java.awt.Dimension ; 6 import java.awt.Font ; 7 import java.awt.Frame ; 8 import java.awt.GridBagLayout ; 9 import java.awt.Panel ; 10 import java.awt.SystemColor ; 11 import java.awt.TextArea ; 12 import java.awt.event.ActionEvent ; 13 import java.awt.event.ActionListener ; 14 import java.awt.event.KeyAdapter ; 15 import java.awt.event.KeyEvent ; 16 import java.awt.event.WindowEvent ; 17 18 24 public class TraceDialog extends Dialog { 25 Panel mainPanel; 26 GridBagLayout gridBagLayout; 27 XYLayout xyLayout; 28 Button bOK; 29 TextArea taTrace; 30 Process process; 31 32 38 public TraceDialog(Frame frame, String title) { 39 super(frame, title, false); 40 mainPanel = new Panel (); 41 xyLayout = new XYLayout(); 42 bOK = new Button (); 43 taTrace = new TextArea (); 44 enableEvents(64L); 45 try { 46 jbInit(); 47 add(mainPanel); 48 pack(); 49 } catch (Exception exception) { 50 exception.printStackTrace(); 51 } 52 this.setResizable(false); 53 this.setSize(new Dimension (790, 560)); 54 } 55 56 private void jbInit() 57 throws Exception { 58 mainPanel.setLayout(xyLayout); 59 mainPanel.setBackground(SystemColor.control); 60 mainPanel.setSize(new Dimension (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 ("Dialog", 0, 10)); 70 taTrace.setSize(new Dimension (750, 560)); 71 bOK.setLabel("Cancel"); 72 bOK.addActionListener(new ActionListener () { 73 public void actionPerformed(ActionEvent actionevent) { 74 bOK_actionPerformed(actionevent); 75 } 76 }); 77 bOK.addKeyListener(new KeyAdapter () { 78 public void keyPressed(KeyEvent 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 89 public void setDefaultFocus() { 90 bOK.requestFocus(); 91 } 92 93 98 public void appendLine(String s) { 99 taTrace.append(s); 100 } 101 102 107 public void setButtonName(String s) { 108 bOK.setLabel(s); 109 } 110 111 protected void processWindowEvent(WindowEvent 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 actionevent) { 123 cancel(); 124 } 125 126 void bOKKeyPressed(KeyEvent keyevent) { 127 int i = keyevent.getKeyCode(); 128 129 if (i == 27 || i == 10) { 130 cancel(); 131 } 132 } 133 } 134 | Popular Tags |