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.*;
28 import java.util.prefs.*;
29 import java.util.concurrent.LinkedBlockingQueue;
31 public class AltosConfigureUI extends JDialog {
36 JRadioButton enable_voice;
40 JButton configure_log;
41 JTextField log_directory;
43 public AltosConfigureUI(JFrame in_owner, AltosVoice in_voice) {
44 super(in_owner, "Configure AltosUI", false);
48 Insets insets = new Insets(4, 4, 4, 4);
52 pane = getContentPane();
53 pane.setLayout(new GridBagLayout());
55 c = new GridBagConstraints();
57 c.fill = GridBagConstraints.NONE;
58 c.anchor = GridBagConstraints.CENTER;
63 enable_voice = new JRadioButton("Enable Voice", AltosPreferences.voice());
64 enable_voice.addActionListener(new ActionListener() {
65 public void actionPerformed(ActionEvent e) {
66 JRadioButton item = (JRadioButton) e.getSource();
67 boolean enabled = item.isSelected();
68 AltosPreferences.set_voice(enabled);
70 voice.speak_always("Enable voice.");
72 voice.speak_always("Disable voice.");
75 pane.add(enable_voice, c);
78 test_voice = new JButton("Test Voice");
79 test_voice.addActionListener(new ActionListener() {
80 public void actionPerformed(ActionEvent e) {
81 voice.speak("That's one small step for man; one giant leap for mankind.");
84 pane.add(test_voice, c);
86 close = new JButton("Close");
87 close.addActionListener(new ActionListener() {
88 public void actionPerformed(ActionEvent e) {
97 configure_log = new JButton("Configure Log");
98 configure_log.addActionListener(new ActionListener() {
99 public void actionPerformed(ActionEvent e) {
100 AltosPreferences.ConfigureLog();
101 log_directory.setText(AltosPreferences.logdir().getPath());
108 pane.add(configure_log, c);
110 log_directory = new JTextField(AltosPreferences.logdir().getPath());
113 c.fill = GridBagConstraints.BOTH;
114 pane.add(log_directory, c);
117 setLocationRelativeTo(owner);