2 * Copyright © 2010 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 import java.awt.event.*;
23 import javax.swing.filechooser.FileNameExtensionFilter;
24 import javax.swing.table.*;
25 import javax.swing.event.*;
29 import java.util.prefs.*;
31 import altosui.AltosRomconfig;
33 public class AltosRomconfigUI
35 implements ActionListener
40 JLabel radio_calibration_label;
43 JTextField serial_value;
44 JTextField radio_calibration_value;
49 /* Build the UI using a grid bag */
50 public AltosRomconfigUI(JFrame in_owner) {
51 super (in_owner, "Configure TeleMetrum Rom Values", true);
56 Insets il = new Insets(4,4,4,4);
57 Insets ir = new Insets(4,4,4,4);
59 pane = getContentPane();
60 pane.setLayout(new GridBagLayout());
63 c = new GridBagConstraints();
64 c.gridx = 0; c.gridy = 0;
66 c.fill = GridBagConstraints.NONE;
67 c.anchor = GridBagConstraints.LINE_START;
69 serial_label = new JLabel("Serial:");
70 pane.add(serial_label, c);
72 c = new GridBagConstraints();
73 c.gridx = 3; c.gridy = 0;
75 c.fill = GridBagConstraints.HORIZONTAL;
77 c.anchor = GridBagConstraints.LINE_START;
79 serial_value = new JTextField("0");
80 pane.add(serial_value, c);
82 /* Radio calibration value */
83 c = new GridBagConstraints();
84 c.gridx = 0; c.gridy = 1;
86 c.fill = GridBagConstraints.NONE;
87 c.anchor = GridBagConstraints.LINE_START;
90 radio_calibration_label = new JLabel("Radio Calibration:");
91 pane.add(radio_calibration_label, c);
93 c = new GridBagConstraints();
94 c.gridx = 3; c.gridy = 1;
96 c.fill = GridBagConstraints.HORIZONTAL;
98 c.anchor = GridBagConstraints.LINE_START;
101 radio_calibration_value = new JTextField("1186611");
102 pane.add(radio_calibration_value, c);
105 c = new GridBagConstraints();
106 c.gridx = 0; c.gridy = 2;
108 c.fill = GridBagConstraints.NONE;
109 c.anchor = GridBagConstraints.CENTER;
111 ok = new JButton("OK");
113 ok.addActionListener(this);
114 ok.setActionCommand("ok");
116 c = new GridBagConstraints();
117 c.gridx = 3; c.gridy = 2;
119 c.fill = GridBagConstraints.NONE;
120 c.anchor = GridBagConstraints.CENTER;
122 cancel = new JButton("Cancel");
124 cancel.addActionListener(this);
125 cancel.setActionCommand("cancel");
128 setLocationRelativeTo(owner);
133 /* Listen for events from our buttons */
134 public void actionPerformed(ActionEvent e) {
135 String cmd = e.getActionCommand();
137 if (cmd.equals("ok"))
143 return Integer.parseInt(serial_value.getText());
146 int radio_calibration() {
147 return Integer.parseInt(radio_calibration_value.getText());
150 public AltosRomconfig romconfig() {
151 return new AltosRomconfig(serial(), radio_calibration());
154 public AltosRomconfig showDialog() {