summaryrefslogtreecommitdiff
path: root/altosui/AltosFlightUI.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-06-16 21:57:35 -0700
committerKeith Packard <keithp@keithp.com>2014-06-16 21:57:35 -0700
commite612693e33ef3b0e22db0656792992fa6e961ff2 (patch)
tree7b0bca38c4c3dbfa22c35634850cde527d4de18a /altosui/AltosFlightUI.java
parent6579e4cae8fea65780f1c4677f29c1fc17ca41e2 (diff)
altosui/telegps: Use menus for frequency list and telemetry formats
This will let us move them into the Mac OS X menu bar, as well as making them look a bit nicer. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/AltosFlightUI.java')
-rw-r--r--altosui/AltosFlightUI.java57
1 files changed, 17 insertions, 40 deletions
diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java
index 43deb631..2e192c73 100644
--- a/altosui/AltosFlightUI.java
+++ b/altosui/AltosFlightUI.java
@@ -170,13 +170,17 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay {
}
Container bag;
- AltosFreqList frequencies;
- JComboBox<String> telemetries;
- JLabel telemetry;
+
+ JMenuBar menu_bar;
+ AltosFreqList frequencies;
+ AltosUITelemetryMenu telemetries;
+ JLabel telemetry;
ActionListener show_timer;
public AltosFlightUI(AltosVoice in_voice, AltosFlightReader in_reader, final int serial) {
+ super();
+
AltosUIPreferences.set_component(this);
displays = new LinkedList<AltosFlightDisplay>();
@@ -193,6 +197,10 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay {
/* Stick channel selector at top of table for telemetry monitoring */
if (serial >= 0) {
+
+ menu_bar = new JMenuBar();
+ setJMenuBar(menu_bar);
+
// Channel menu
frequencies = new AltosFreqList(AltosUIPreferences.frequency(serial));
frequencies.set_product("Monitor");
@@ -208,43 +216,19 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay {
reader.save_frequency();
}
});
- c.gridx = 0;
- c.gridy = 0;
- c.weightx = 0;
- c.weighty = 0;
- c.insets = new Insets(3, 3, 3, 3);
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.WEST;
- bag.add (frequencies, c);
+ menu_bar.add (frequencies);
// Telemetry format menu
- if (reader.supports_telemetry(Altos.ao_telemetry_standard)) {
- telemetries = new JComboBox<String>();
- for (int i = 1; i <= Altos.ao_telemetry_max; i++)
- telemetries.addItem(Altos.telemetry_name(i));
- int telemetry = AltosPreferences.telemetry(serial);
- if (telemetry <= Altos.ao_telemetry_off ||
- telemetry > Altos.ao_telemetry_max)
- telemetry = Altos.ao_telemetry_standard;
- telemetries.setSelectedIndex(telemetry - 1);
- telemetries.setMaximumRowCount(Altos.ao_telemetry_max);
- telemetries.setPreferredSize(null);
- telemetries.revalidate();
+ if (reader.supports_telemetry(AltosLib.ao_telemetry_standard)) {
+ telemetries = new AltosUITelemetryMenu(serial);
telemetries.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- int telemetry = telemetries.getSelectedIndex() + 1;
+ int telemetry = telemetries.get_selected();
reader.set_telemetry(telemetry);
reader.save_telemetry();
}
});
- c.gridx = 1;
- c.gridy = 0;
- c.weightx = 0;
- c.weighty = 0;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.WEST;
- bag.add (telemetries, c);
- c.insets = new Insets(0, 0, 0, 0);
+ menu_bar.add(telemetries);
} else {
String version;
@@ -256,14 +240,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay {
version = "Telemetry: None";
telemetry = new JLabel(version);
- c.gridx = 1;
- c.gridy = 0;
- c.weightx = 0;
- c.weighty = 0;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.WEST;
- bag.add (telemetry, c);
- c.insets = new Insets(0, 0, 0, 0);
+ menu_bar.add(telemetry);
}
}