Merge branch 'buttonbox' of git://git.gag.com/fw/altos into buttonbox
authorAnthony Towns <aj@erisian.com.au>
Sat, 20 Nov 2010 08:20:45 +0000 (18:20 +1000)
committerAnthony Towns <aj@erisian.com.au>
Sat, 20 Nov 2010 08:20:45 +0000 (18:20 +1000)
ao-tools/altosui/AltosChannelMenu.java
ao-tools/altosui/AltosFlightUI.java

index 8069c8531b1c71f9a5802be9c1e3a94d23a4c352..abbb86f43c31ea56e75b6cd6e5a48b11e18a5a24 100644 (file)
@@ -30,31 +30,11 @@ import java.util.concurrent.LinkedBlockingQueue;
 
 public class AltosChannelMenu extends JComboBox implements ActionListener {
        int                             channel;
-       LinkedList<ActionListener>      listeners;
-
-       public void addActionListener(ActionListener l) {
-               listeners.add(l);
-       }
-
-       public void actionPerformed(ActionEvent e) {
-               channel = getSelectedIndex();
-
-               ActionEvent newe = new ActionEvent(this, channel, e.getActionCommand());
-
-               ListIterator<ActionListener>    i = listeners.listIterator();
-
-               while (i.hasNext()) {
-                       ActionListener  listener = i.next();
-                       listener.actionPerformed(newe);
-               }
-               setMaximumSize(getPreferredSize());
-       }
 
        public AltosChannelMenu(int current_channel) {
 
                channel = current_channel;
 
-               listeners = new LinkedList<ActionListener>();
                for (int c = 0; c <= 9; c++)
                        addItem(String.format("Channel %1d (%7.3fMHz)", c, 434.550 + c * 0.1));
                setSelectedIndex(channel);
index 21b41528b32a056aee22989167cbead46b506425..6db6c67b192d04ad792bd3806be2380412fa4d56 100644 (file)
@@ -131,6 +131,7 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay {
        }
 
        Container       bag;
+       JComboBox       channels;
 
        public AltosFlightUI(AltosVoice in_voice, AltosFlightReader in_reader, final int serial) {
                AltosPreferences.init(this);
@@ -151,10 +152,10 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay {
 
                if (serial >= 0) {
                        // Channel menu
-                       JComboBox channels = new AltosChannelMenu(AltosPreferences.channel(serial));
+                       channels = new AltosChannelMenu(AltosPreferences.channel(serial));
                        channels.addActionListener(new ActionListener() {
                                        public void actionPerformed(ActionEvent e) {
-                                               int channel = Integer.parseInt(e.getActionCommand());
+                                               int channel = channels.getSelectedIndex();
                                                reader.set_channel(channel);
                                                AltosPreferences.set_channel(serial, channel);
                                        }