2 JPC-RR: A x86 PC Hardware Emulator
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
;
33 import java
.awt
.event
.*;
36 public class AuthorsDialog
implements ActionListener
, WindowListener
38 private JFrame window
;
40 private JPanel panel2
;
41 private Response response
;
42 private boolean answerReady
;
43 private JTextField
[] texts
;
47 public String
[] authors
;
50 public AuthorsDialog(String
[] existing
)
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
);
61 window
.addWindowListener(this);
65 if(existing
== null) {
66 texts
= new JTextField
[1];
67 texts
[0] = new JTextField("", 40);
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
++)
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);
92 window
.setVisible(true);
93 window
.setDefaultCloseOperation(JFrame
.DO_NOTHING_ON_CLOSE
);
96 public synchronized Response
waitClose()
102 while(!answerReady
) {
105 } catch(InterruptedException e
) {
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
]);
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();
129 response
.authors
[i
] = str
;
131 window
.setVisible(false);
137 } else if(command
== "CANCEL") {
138 window
.setVisible(false);
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);