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
;
32 import org
.jpc
.diskimages
.DiskImage
;
33 import static org
.jpc
.Misc
.callShowOptionDialog
;
36 import java
.awt
.event
.*;
39 public class NewDiskDialog
implements ActionListener
, WindowListener
41 private JFrame window
;
43 private Response response
;
44 private boolean answerReady
;
45 private JTextField nameField
;
46 private JComboBox imageField
;
50 public String diskName
;
51 public String diskFile
;
54 public NewDiskDialog()
58 window
= new JFrame("Add disk");
59 GridLayout layout
= new GridLayout(0, 2);
60 panel
= new JPanel(layout
);
62 window
.addWindowListener(this);
64 JLabel label
= new JLabel("Image name");
65 nameField
= new JTextField("Image", 40);
69 label
= new JLabel("Image name");
70 String
[] choices
= DiskImage
.getLibrary().imagesByType(10); //FLOPPY and CDROM
77 callShowOptionDialog(null, "No images available.", "Can't add disk", JOptionPane
.YES_NO_OPTION
,
78 JOptionPane
.WARNING_MESSAGE
, null, new String
[]{"Dismiss"}, "Dismiss");
82 imageField
= new JComboBox(choices
);
84 panel
.add(imageField
);
86 JButton ass
= new JButton("Add");
87 ass
.setActionCommand("ADD");
88 ass
.addActionListener(this);
89 JButton cancl
= new JButton("Cancel");
90 cancl
.setActionCommand("CANCEL");
91 cancl
.addActionListener(this);
96 window
.setVisible(true);
97 window
.setDefaultCloseOperation(JFrame
.DO_NOTHING_ON_CLOSE
);
100 public synchronized Response
waitClose()
106 while(!answerReady
) {
109 } catch(InterruptedException e
) {
116 public void actionPerformed(ActionEvent evt
)
118 String command
= evt
.getActionCommand();
119 if(command
== "ADD") {
120 response
= new Response();
121 response
.diskFile
= nameField
.getText();
122 response
.diskName
= (String
)(imageField
.getSelectedItem());
123 window
.setVisible(false);
129 } else if(command
== "CANCEL") {
130 window
.setVisible(false);
140 public void windowActivated(WindowEvent e
) { /* Not interested. */ }
141 public void windowClosed(WindowEvent e
) { /* Not interested. */ }
142 public void windowDeactivated(WindowEvent e
) { /* Not interested. */ }
143 public void windowDeiconified(WindowEvent e
) { /* Not interested. */ }
144 public void windowIconified(WindowEvent e
) { /* Not interested. */ }
145 public void windowOpened(WindowEvent e
) { /* Not interested. */ }
147 public void windowClosing(WindowEvent e
)
149 window
.setVisible(false);