diff options
author | Anthony Towns <aj@erisian.com.au> | 2010-11-20 17:40:49 +1000 |
---|---|---|
committer | Anthony Towns <aj@erisian.com.au> | 2010-11-20 17:40:49 +1000 |
commit | 081fbd5715f9d3d81d98e149fb95d40447c07a79 (patch) | |
tree | 073885e98179ef663f08aaaf52cb7e74c2c66427 /ao-tools/altosui/AltosChannelMenu.java | |
parent | 90b9bc4475011bead7117ed72fa5efa0f77b2813 (diff) | |
parent | 7920ed5c34b088f45ce4213b061ddd1ffe22cee8 (diff) |
Merge branch 'buttonbox' of git://git.gag.com/fw/altos into buttonbox
Conflicts:
ao-tools/altosui/AltosFlightUI.java
Diffstat (limited to 'ao-tools/altosui/AltosChannelMenu.java')
-rw-r--r-- | ao-tools/altosui/AltosChannelMenu.java | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/ao-tools/altosui/AltosChannelMenu.java b/ao-tools/altosui/AltosChannelMenu.java index 504c13c6..8069c853 100644 --- a/ao-tools/altosui/AltosChannelMenu.java +++ b/ao-tools/altosui/AltosChannelMenu.java @@ -28,8 +28,7 @@ import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -public class AltosChannelMenu extends JMenu implements ActionListener { - ButtonGroup group; +public class AltosChannelMenu extends JComboBox implements ActionListener { int channel; LinkedList<ActionListener> listeners; @@ -38,33 +37,28 @@ public class AltosChannelMenu extends JMenu implements ActionListener { } public void actionPerformed(ActionEvent e) { - channel = Integer.parseInt(e.getActionCommand()); + channel = getSelectedIndex(); + + ActionEvent newe = new ActionEvent(this, channel, e.getActionCommand()); ListIterator<ActionListener> i = listeners.listIterator(); - ActionEvent newe = new ActionEvent(this, channel, e.getActionCommand()); while (i.hasNext()) { ActionListener listener = i.next(); listener.actionPerformed(newe); } + setMaximumSize(getPreferredSize()); } public AltosChannelMenu(int current_channel) { - super("Channel", true); - group = new ButtonGroup(); channel = current_channel; listeners = new LinkedList<ActionListener>(); - for (int c = 0; c <= 9; c++) { - JRadioButtonMenuItem radioitem = new JRadioButtonMenuItem(String.format("Channel %1d (%7.3fMHz)", c, - 434.550 + c * 0.1), - c == channel); - radioitem.setActionCommand(String.format("%d", c)); - radioitem.addActionListener(this); - add(radioitem); - group.add(radioitem); - } + for (int c = 0; c <= 9; c++) + addItem(String.format("Channel %1d (%7.3fMHz)", c, 434.550 + c * 0.1)); + setSelectedIndex(channel); + setMaximumRowCount(10); } } |