Fix most warnings from GCJ
[jpcrr.git] / org / jpc / pluginsaux / AuthorsDialog.java
blobfd0c8f986613930d4c1917b0bef96c8c3f4b2209
1 /*
2 JPC-RR: A x86 PC Hardware Emulator
3 Release 1
5 Copyright (C) 2007-2009 Isis Innovation Limited
6 Copyright (C) 2009 H. Ilari Liusvaara
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 2 as published by
10 the Free Software Foundation.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 Based on JPC x86 PC Hardware emulator,
22 A project from the Physics Dept, The University of Oxford
24 Details about original JPC can be found at:
26 www-jpc.physics.ox.ac.uk
30 package org.jpc.pluginsaux;
32 import javax.swing.*;
33 import java.awt.event.*;
34 import java.awt.*;
36 public class AuthorsDialog implements ActionListener, WindowListener
38 private JFrame window;
39 private JPanel panel;
40 private JPanel panel2;
41 private Response response;
42 private boolean answerReady;
43 private JTextField[] texts;
45 public class Response
47 public String[] authors;
50 public AuthorsDialog(String[] existing)
52 response = null;
53 answerReady = false;
54 window = new JFrame("Change run authors");
55 panel = new JPanel(null);
56 BoxLayout layout2 = new BoxLayout(panel, BoxLayout.Y_AXIS);
57 panel.setLayout(layout2);
58 GridLayout layout = new GridLayout(0, 1);
59 panel2 = new JPanel(layout);
60 window.add(panel);
61 window.addWindowListener(this);
63 panel.add(panel2);
65 if(existing == null) {
66 texts = new JTextField[1];
67 texts[0] = new JTextField("", 40);
68 } else {
69 texts = new JTextField[1 + existing.length];
70 for(int i = 0; i < existing.length; i++)
71 texts[i] = new JTextField(existing[i], 40);
72 texts[existing.length] = new JTextField("", 40);
75 for(int i = 0; i < texts.length; i++)
76 panel2.add(texts[i]);
78 JButton ass = new JButton("Add");
79 ass.setActionCommand("ADD");
80 ass.addActionListener(this);
81 JButton close = new JButton("Close");
82 close.setActionCommand("CLOSE");
83 close.addActionListener(this);
84 JButton cancl = new JButton("Cancel");
85 cancl.setActionCommand("CANCEL");
86 cancl.addActionListener(this);
87 panel.add(ass);
88 panel.add(close);
89 panel.add(cancl);
91 window.pack();
92 window.setVisible(true);
93 window.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
96 public synchronized Response waitClose()
98 if(answerReady) {
99 answerReady = false;
100 return response;
102 while(!answerReady) {
103 try {
104 wait();
105 } catch(InterruptedException e) {
108 answerReady = false;
109 return response;
112 public void actionPerformed(ActionEvent evt)
114 String command = evt.getActionCommand();
115 if(command == "ADD") {
116 JTextField[] ntexts = new JTextField[texts.length + 1];
117 System.arraycopy(texts, 0, ntexts, 0, texts.length);
118 ntexts[texts.length] = new JTextField("", 40);
119 panel2.add(ntexts[texts.length]);
120 texts = ntexts;
121 window.pack();
122 } else if(command == "CLOSE") {
123 response = new Response();
124 response.authors = new String[texts.length];
125 for(int i = 0; i < texts.length; i++) {
126 String str = texts[i].getText();
127 if("".equals(str))
128 str = null;
129 response.authors[i] = str;
131 window.setVisible(false);
132 window.dispose();
133 synchronized(this) {
134 answerReady = true;
135 notifyAll();
137 } else if(command == "CANCEL") {
138 window.setVisible(false);
139 window.dispose();
140 synchronized(this) {
141 response = null;
142 answerReady = true;
143 notifyAll();
148 public void windowActivated(WindowEvent e) { /* Not interested. */ }
149 public void windowClosed(WindowEvent e) { /* Not interested. */ }
150 public void windowDeactivated(WindowEvent e) { /* Not interested. */ }
151 public void windowDeiconified(WindowEvent e) { /* Not interested. */ }
152 public void windowIconified(WindowEvent e) { /* Not interested. */ }
153 public void windowOpened(WindowEvent e) { /* Not interested. */ }
155 public void windowClosing(WindowEvent e)
157 window.setVisible(false);
158 synchronized(this) {
159 response = null;
160 answerReady = true;
161 notifyAll();