1 23 24 29 30 package com.sun.enterprise.util.diagnostics; 31 32 import java.awt.*; 33 import java.awt.event.*; 34 import javax.swing.*; 35 import javax.swing.text.*; 36 37 42 43 class JWhichUI extends JFrame implements ActionListener 44 { 45 public JWhichUI() 46 { 47 addButtonPanel(); 48 addTextPanel(); 49 50 setTitle(title); 51 setSize(900, 300); 52 53 addWindowListener(new WindowAdapter() 54 { 55 public void windowClosing(WindowEvent e) 56 { 57 System.exit(0); 58 } 59 } ); 60 61 show(); 62 } 63 64 66 public void pr(String s) 67 { 68 textArea.append(s + "\n"); } 71 72 74 private void addButtonPanel() 75 { 76 JPanel panel = new JPanel(); 77 searchButton = new JButton("Search"); panel.add(searchButton); 79 searchButton.addActionListener(this); 80 Dimension d = searchButton.getPreferredSize(); 81 d.setSize(450, d.getHeight()); 82 searchString = new JTextField(); 83 searchString.setPreferredSize(d); 84 panel.add(searchString); 85 searchString.addActionListener(this); 86 87 getContentPane().add(panel, "South"); } 89 90 92 private void addTextPanel() 93 { 94 textArea = new JTextArea(800, 50); 95 scrollPane = new JScrollPane(textArea); 96 getContentPane().add(scrollPane, "Center"); } 98 99 101 public void actionPerformed(ActionEvent evt) 102 { 103 Object source = evt.getSource(); 104 105 if(source == searchButton) 106 { 107 String what = searchString.getText(); 108 109 if(what == null || what.length() <= 0) 110 return; 111 112 JWhich jw = new JWhich(what); 113 pr(jw.getResult()); 114 } 115 } 116 117 119 public static void main(String [] args) 120 { 121 JWhichUI jwui = new JWhichUI(); 122 jwui.show(); 123 } 124 125 127 private JButton searchButton; 128 private JTextField searchString; 129 private JTextArea textArea; 130 private JScrollPane scrollPane; 131 private final static String title = "JWhich -- Class Finder";} 133 134 | Popular Tags |