1 23 24 28 package com.sun.enterprise.util.diagnostics; 29 30 import java.awt.*; 31 import java.awt.event.*; 32 import javax.swing.*; 33 import javax.swing.text.*; 34 import java.util.logging.Logger ; 36 import java.util.logging.Level ; 37 import com.sun.logging.LogDomains; 38 40 class ReporterFrame extends JFrame implements ActionListener 41 { 42 static Logger _logger=LogDomains.getLogger(LogDomains.UTIL_LOGGER); 44 public void pr(String s) 46 { 47 textArea.append(s + "\n"); } 50 51 53 ReporterFrame(String title) 54 { 55 addButtonPanel(); 56 addTextPanel(); 57 58 setTitle(titleRoot + " -- " + title); setSize(900, 300); 60 if(standAlone) 61 { 62 addWindowListener(new WindowAdapter() 63 { 64 public void windowClosing(WindowEvent e) 65 { 66 System.exit(0); 67 } 68 } ); 69 70 for(int i = 0; i < 1000; i++) 71 textArea.append("This is line# " + i + "\n"); 73 show(); 74 } 75 } 76 78 private void addButtonPanel() 79 { 80 JPanel panel = new JPanel(); 81 wrapButton = new JButton("Wrap"); panel.add(wrapButton); 83 wrapButton.addActionListener(this); 84 85 noWrapButton = new JButton("No wrap"); panel.add(noWrapButton); 87 noWrapButton.addActionListener(this); 88 89 getContentPane().add(panel, "South"); } 91 92 94 private void addTextPanel() 95 { 96 textArea = new JTextArea(800, 200); 98 scrollPane = new JScrollPane(textArea); 99 getContentPane().add(scrollPane, "Center"); } 101 102 104 public void actionPerformed(ActionEvent evt) 105 { 106 Object source = evt.getSource(); 107 108 if(source == wrapButton) 109 { 110 textArea.setLineWrap(true); 111 scrollPane.validate(); 112 } 113 else if(source == noWrapButton) 114 { 115 textArea.setLineWrap(false); 116 scrollPane.validate(); 117 } 118 119 120 121 156 } 157 158 160 161 static void setStandAlone() 162 { 163 _logger.log(Level.FINE,"setStandAlone() here!!!"); 166 standAlone = true; 168 } 169 170 172 private JButton wrapButton; 173 private JButton noWrapButton; 174 private JTextArea textArea; 176 private JScrollPane scrollPane; 177 private final static String titleRoot = "iPlanet Reporter"; private static boolean standAlone = false; 179 } 180 181 | Popular Tags |