5 import java.awt.event.*;
9 import ij.plugin.filter.Analyzer;
15 public class TextWindow extends JFrame implements ActionListener, FocusListener {
26 public TextWindow(String title, String data,
int width,
int height) {
27 this(title,
"", data, width, height);
38 public TextWindow(String title, String headings, String data,
int width,
int height) {
40 enableEvents(AWTEvent.WINDOW_EVENT_MASK);
42 textPanel.setTitle(title);
43 getContentPane().add(textPanel, BorderLayout.CENTER);
45 if (data!=null && !data.equals(
""))
47 System.out.println(
"Data was "+data);
52 addFocusListener(
this);
54 setSize(width, height);
68 enableEvents(AWTEvent.WINDOW_EVENT_MASK);
70 getContentPane().add(textPanel, BorderLayout.CENTER);
72 setSize(width, height);
79 JMenuBar mb =
new JMenuBar();
80 JMenu m =
new JMenu(
"File");
81 m.add(
new JMenuItem(
"Save As..."));
82 m.addActionListener(
this);
84 m =
new JMenu(
"Edit");
85 m.add(
new JMenuItem(
"Cut"));
86 m.add(
new JMenuItem(
"Copy"));
87 m.add(
new JMenuItem(
"Copy All"));
88 m.add(
new JMenuItem(
"Clear"));
89 m.add(
new JMenuItem(
"Select All"));
90 if (getTitle().equals(
"Results")) {
92 m.add(
new JMenuItem(
"Clear Results"));
93 m.add(
new JMenuItem(
"Summarize"));
94 m.add(
new JMenuItem(
"Set Measurements..."));
96 m.addActionListener(
this);
112 textPanel.setFont(font);
115 boolean openFile(String path) {
116 OpenDialog od =
new OpenDialog(
"Open Text File...", path);
117 String directory = od.getDirectory();
118 String name = od.getFileName();
121 path = directory + name;
125 BufferedReader r =
new BufferedReader(
new FileReader(directory + name));
129 catch (Exception e) {
133 textPanel.setTitle(name);
145 public void load(BufferedReader in)
throws IOException {
148 String s=in.readLine();
154 public void actionPerformed(ActionEvent evt) {
155 String cmd = evt.getActionCommand();
156 textPanel.doCommand(cmd);
159 public void processWindowEvent(WindowEvent e) {
160 super.processWindowEvent(e);
162 if (
id==WindowEvent.WINDOW_CLOSING)
166 public void close() {
167 if (getTitle().equals(
"Results")) {
168 if (!Analyzer.resetCounter())
170 IJ.setTextPanel(null);
172 if (getTitle().equals(
"Log")) {
173 IJ.debugMode =
false;
181 public void focusGained(FocusEvent e) {
184 public void focusLost(FocusEvent e) {}