1 23 24 28 package com.sun.enterprise.tools.common.util.diagnostics; 29 30 import java.awt.*; 31 import java.awt.event.*; 32 import javax.swing.*; 33 import javax.swing.text.*; 34 35 class ReporterFrame extends JFrame implements ActionListener 36 { 37 public void pr(String s) 38 { 39 textArea.append(s + "\n"); } 42 43 45 ReporterFrame(String title) 46 { 47 addButtonPanel(); 48 addTextPanel(); 49 50 setTitle(titleRoot + " -- " + title); setSize(900, 300); 52 if(standAlone) 53 { 54 addWindowListener(new WindowAdapter() 55 { 56 public void windowClosing(WindowEvent e) 57 { 58 System.exit(0); 59 } 60 } ); 61 62 for(int i = 0; i < 1000; i++) 63 textArea.append("This is line# " + i + "\n"); 65 show(); 66 } 67 } 68 70 private void addButtonPanel() 71 { 72 JPanel panel = new JPanel(); 73 wrapButton = new JButton("Wrap"); panel.add(wrapButton); 75 wrapButton.addActionListener(this); 76 77 noWrapButton = new JButton("No wrap"); panel.add(noWrapButton); 79 noWrapButton.addActionListener(this); 80 81 getContentPane().add(panel, "South"); } 83 84 86 private void addTextPanel() 87 { 88 textArea = new JTextArea(800, 200); 90 scrollPane = new JScrollPane(textArea); 91 getContentPane().add(scrollPane, "Center"); } 93 94 96 public void actionPerformed(ActionEvent evt) 97 { 98 Object source = evt.getSource(); 99 100 if(source == wrapButton) 101 { 102 textArea.setLineWrap(true); 103 scrollPane.validate(); 104 } 105 else if(source == noWrapButton) 106 { 107 textArea.setLineWrap(false); 108 scrollPane.validate(); 109 } 110 111 112 113 135 } 136 137 139 140 static void setStandAlone() 141 { 142 System.err.println("setStandAlone() here!!!"); standAlone = true; 144 } 145 146 148 private JButton wrapButton; 149 private JButton noWrapButton; 150 private JTextArea textArea; 152 private JScrollPane scrollPane; 153 private final static String titleRoot = "iPlanet Reporter"; private static boolean standAlone = false; 155 } 156 157 | Popular Tags |