1 package org.jacorb.poa.gui.beans; 2 3 22 23 import java.util.Calendar ; 24 25 31 public class ConsolePanel extends java.awt.Panel implements java.awt.event.ActionListener 32 { 33 private static int ROW_BUFFER = 256; 34 private int rowCount = 0; 35 private java.awt.Panel ivjButtonPanel = null; 36 private java.awt.FlowLayout ivjButtonPanelFlowLayout = null; 37 private java.awt.Button ivjClearButton = null; 38 private java.awt.TextArea ivjConsole = null; 39 private java.awt.Button ivjHideButton = null; 40 private java.awt.Button ivjShowButton = null; 41 private java.awt.BorderLayout ivjConsolePanelBorderLayout = null; 42 private java.awt.Panel ivjLeftPanel = null; 43 private java.awt.Panel ivjRightPanel = null; 44 45 48 49 public ConsolePanel() { 50 super(); 51 initialize(); 52 } 53 57 public ConsolePanel(java.awt.LayoutManager layout) { 58 super(layout); 59 } 60 private void _actionHideConsole() { 61 int height = getBounds().height; 62 63 remove(getConsole()); 64 getButtonPanel().remove(getHideButton()); 65 getButtonPanel().remove(getClearButton()); 66 getButtonPanel().add(getShowButton(), getShowButton().getName()); 67 68 java.awt.Component c = this; 69 while ((c = c.getParent()) != null) if (c instanceof java.awt.Frame ) break; 70 c.setSize(c.getBounds().width, c.getBounds().height-height+33); 71 c.validate(); 72 } 73 private void _actionShowConsole() { 74 add(getConsole(), "Center"); 75 getButtonPanel().remove(getShowButton()); 76 getButtonPanel().add(getHideButton(), getHideButton().getName()); 77 getButtonPanel().add(getClearButton(), getClearButton().getName()); 78 79 java.awt.Component c = this; 80 while ((c = c.getParent()) != null) if (c instanceof java.awt.Frame ) break; 81 c.setSize(c.getBounds().width, c.getBounds().height+100); 82 c.validate(); 83 } 84 synchronized public void _printMessage(String text) { 85 if (rowCount++ > ROW_BUFFER) { 86 getConsole().setText(""); 87 rowCount = 1; 88 } 89 getConsole().append(text + "\n"); 90 } 91 95 96 public void actionPerformed(java.awt.event.ActionEvent e) { 97 if ((e.getSource() == getClearButton()) ) { 100 connEtoM1(e); 101 } 102 if ((e.getSource() == getHideButton()) ) { 103 connEtoC1(e); 104 } 105 if ((e.getSource() == getShowButton()) ) { 106 connEtoC2(e); 107 } 108 } 111 115 116 private void connEtoC1(java.awt.event.ActionEvent arg1) { 117 try { 118 this._actionHideConsole(); 121 } catch (java.lang.Throwable ivjExc) { 124 handleException(ivjExc); 127 } 128 } 129 133 134 private void connEtoC2(java.awt.event.ActionEvent arg1) { 135 try { 136 this._actionShowConsole(); 139 } catch (java.lang.Throwable ivjExc) { 142 handleException(ivjExc); 145 } 146 } 147 151 152 private void connEtoM1(java.awt.event.ActionEvent arg1) { 153 try { 154 getConsole().setText(""); 157 } catch (java.lang.Throwable ivjExc) { 160 handleException(ivjExc); 163 } 164 } 165 169 170 private java.awt.Panel getButtonPanel() { 171 if (ivjButtonPanel == null) { 172 try { 173 ivjButtonPanel = new java.awt.Panel (); 174 ivjButtonPanel.setName("ButtonPanel"); 175 ivjButtonPanel.setLayout(getButtonPanelFlowLayout()); 176 getButtonPanel().add(getHideButton(), getHideButton().getName()); 177 getButtonPanel().add(getClearButton(), getClearButton().getName()); 178 } catch (java.lang.Throwable ivjExc) { 181 handleException(ivjExc); 184 } 185 }; 186 return ivjButtonPanel; 187 } 188 192 193 private java.awt.FlowLayout getButtonPanelFlowLayout() { 194 java.awt.FlowLayout ivjButtonPanelFlowLayout = null; 195 try { 196 197 ivjButtonPanelFlowLayout = new java.awt.FlowLayout (); 198 ivjButtonPanelFlowLayout.setAlignment(java.awt.FlowLayout.LEFT); 199 ivjButtonPanelFlowLayout.setVgap(5); 200 ivjButtonPanelFlowLayout.setHgap(10); 201 } catch (java.lang.Throwable ivjExc) { 202 handleException(ivjExc); 203 }; 204 return ivjButtonPanelFlowLayout; 205 } 206 210 211 private java.awt.Button getClearButton() { 212 if (ivjClearButton == null) { 213 try { 214 ivjClearButton = new java.awt.Button (); 215 ivjClearButton.setName("ClearButton"); 216 ivjClearButton.setLabel(" Clear "); 217 } catch (java.lang.Throwable ivjExc) { 220 handleException(ivjExc); 223 } 224 }; 225 return ivjClearButton; 226 } 227 231 232 private java.awt.TextArea getConsole() { 233 if (ivjConsole == null) { 234 try { 235 ivjConsole = new java.awt.TextArea (); 236 ivjConsole.setName("Console"); 237 ivjConsole.setFont(new java.awt.Font ("dialog", 0, 10)); 238 ivjConsole.setBackground(java.awt.SystemColor.window); 239 } catch (java.lang.Throwable ivjExc) { 242 handleException(ivjExc); 245 } 246 }; 247 return ivjConsole; 248 } 249 253 254 private java.awt.BorderLayout getConsolePanelBorderLayout() { 255 java.awt.BorderLayout ivjConsolePanelBorderLayout = null; 256 try { 257 258 ivjConsolePanelBorderLayout = new java.awt.BorderLayout (); 259 ivjConsolePanelBorderLayout.setVgap(0); 260 ivjConsolePanelBorderLayout.setHgap(10); 261 } catch (java.lang.Throwable ivjExc) { 262 handleException(ivjExc); 263 }; 264 return ivjConsolePanelBorderLayout; 265 } 266 270 271 private java.awt.Button getHideButton() { 272 if (ivjHideButton == null) { 273 try { 274 ivjHideButton = new java.awt.Button (); 275 ivjHideButton.setName("HideButton"); 276 ivjHideButton.setLabel("Hide Console"); 277 } catch (java.lang.Throwable ivjExc) { 280 handleException(ivjExc); 283 } 284 }; 285 return ivjHideButton; 286 } 287 291 292 private java.awt.Panel getLeftPanel() { 293 if (ivjLeftPanel == null) { 294 try { 295 ivjLeftPanel = new java.awt.Panel (); 296 ivjLeftPanel.setName("LeftPanel"); 297 ivjLeftPanel.setLayout(null); 298 } catch (java.lang.Throwable ivjExc) { 301 handleException(ivjExc); 304 } 305 }; 306 return ivjLeftPanel; 307 } 308 312 313 private java.awt.Panel getRightPanel() { 314 if (ivjRightPanel == null) { 315 try { 316 ivjRightPanel = new java.awt.Panel (); 317 ivjRightPanel.setName("RightPanel"); 318 ivjRightPanel.setLayout(null); 319 } catch (java.lang.Throwable ivjExc) { 322 handleException(ivjExc); 325 } 326 }; 327 return ivjRightPanel; 328 } 329 333 334 private java.awt.Button getShowButton() { 335 if (ivjShowButton == null) { 336 try { 337 ivjShowButton = new java.awt.Button (); 338 ivjShowButton.setName("ShowButton"); 339 ivjShowButton.setBounds(27, 384, 90, 23); 340 ivjShowButton.setLabel("Show Console"); 341 } catch (java.lang.Throwable ivjExc) { 344 handleException(ivjExc); 347 } 348 }; 349 return ivjShowButton; 350 } 351 355 private void handleException(Throwable exception) { 356 357 358 } 361 364 365 private void initConnections() { 366 getClearButton().addActionListener(this); 369 getHideButton().addActionListener(this); 370 getShowButton().addActionListener(this); 371 } 372 375 376 private void initialize() { 377 setName("ConsolePanel"); 380 setLayout(getConsolePanelBorderLayout()); 381 setBackground(java.awt.SystemColor.control); 382 setSize(426, 240); 383 add(getButtonPanel(), "South"); 384 add(getConsole(), "Center"); 385 add(getLeftPanel(), "West"); 386 add(getRightPanel(), "East"); 387 initConnections(); 388 remove(getConsole()); 390 getButtonPanel().remove(getHideButton()); 391 getButtonPanel().remove(getClearButton()); 392 getButtonPanel().add(getShowButton(), getShowButton().getName()); 393 } 395 399 public static void main(java.lang.String [] args) { 400 try { 401 java.awt.Frame frame; 402 try { 403 Class aFrameClass = Class.forName("com.ibm.uvm.abt.edit.TestFrame"); 404 frame = (java.awt.Frame )aFrameClass.newInstance(); 405 } catch (java.lang.Throwable ivjExc) { 406 frame = new java.awt.Frame (); 407 } 408 ConsolePanel aConsolePanel; 409 aConsolePanel = new ConsolePanel(); 410 frame.add("Center", aConsolePanel); 411 frame.setSize(aConsolePanel.getSize()); 412 frame.setVisible(true); 413 } catch (Throwable exception) { 414 System.err.println("Exception occurred in main() of java.awt.Panel"); 415 exception.printStackTrace(System.out); 416 } 417 } 418 419 } 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | Popular Tags |