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.*;
30 import java.util.concurrent.LinkedBlockingQueue;
32 public class AltosConfigureUI
34 implements DocumentListener
40 JRadioButton enable_voice;
44 JButton configure_log;
45 JTextField log_directory;
47 JLabel callsign_label;
48 JTextField callsign_value;
50 /* DocumentListener interface methods */
51 public void changedUpdate(DocumentEvent e) {
52 AltosPreferences.set_callsign(callsign_value.getText());
55 public void insertUpdate(DocumentEvent e) {
59 public void removeUpdate(DocumentEvent e) {
63 public AltosConfigureUI(JFrame in_owner, AltosVoice in_voice) {
64 super(in_owner, "Configure AltosUI", false);
68 Insets insets = new Insets(4, 4, 4, 4);
72 pane = getContentPane();
73 pane.setLayout(new GridBagLayout());
75 c = new GridBagConstraints();
77 c.fill = GridBagConstraints.NONE;
78 c.anchor = GridBagConstraints.CENTER;
83 enable_voice = new JRadioButton("Enable Voice", AltosPreferences.voice());
84 enable_voice.addActionListener(new ActionListener() {
85 public void actionPerformed(ActionEvent e) {
86 JRadioButton item = (JRadioButton) e.getSource();
87 boolean enabled = item.isSelected();
88 AltosPreferences.set_voice(enabled);
90 voice.speak_always("Enable voice.");
92 voice.speak_always("Disable voice.");
95 pane.add(enable_voice, c);
98 test_voice = new JButton("Test Voice");
99 test_voice.addActionListener(new ActionListener() {
100 public void actionPerformed(ActionEvent e) {
101 voice.speak("That's one small step for man; one giant leap for mankind.");
104 pane.add(test_voice, c);
106 configure_log = new JButton("Configure Log");
107 configure_log.addActionListener(new ActionListener() {
108 public void actionPerformed(ActionEvent e) {
109 AltosPreferences.ConfigureLog();
110 log_directory.setText(AltosPreferences.logdir().getPath());
117 pane.add(configure_log, c);
119 log_directory = new JTextField(AltosPreferences.logdir().getPath());
122 c.fill = GridBagConstraints.BOTH;
123 pane.add(log_directory, c);
125 callsign_label = new JLabel("Callsign");
128 pane.add(callsign_label, c);
130 callsign_value = new JTextField(AltosPreferences.callsign());
131 callsign_value.getDocument().addDocumentListener(this);
134 pane.add(callsign_value, c);
136 close = new JButton("Close");
137 close.addActionListener(new ActionListener() {
138 public void actionPerformed(ActionEvent e) {
145 c.fill = GridBagConstraints.NONE;
149 setLocationRelativeTo(owner);