+ AltosUIFreqList frequencies;
+ JTextField callsign_value;
+
+ /* DocumentListener interface methods */
+ public void changedUpdate(DocumentEvent e) {
+ if (callsign_value != null) {
+ String callsign = callsign_value.getText();
+ thread.set_callsign(callsign);
+ AltosUIPreferences.set_callsign(callsign);
+ }
+ }
+
+ public void insertUpdate(DocumentEvent e) {
+ changedUpdate(e);
+ }
+
+ public void removeUpdate(DocumentEvent e) {
+ changedUpdate(e);
+ }
+
+ int row = 0;
+
+ public GridBagConstraints constraints (int x, int width, int fill) {
+ GridBagConstraints c = new GridBagConstraints();
+ Insets insets = new Insets(4, 4, 4, 4);
+
+ c.insets = insets;
+ c.fill = fill;
+ if (width == 3)
+ c.anchor = GridBagConstraints.CENTER;
+ else if (x == 2)
+ c.anchor = GridBagConstraints.EAST;
+ else
+ c.anchor = GridBagConstraints.WEST;
+ c.gridx = x;
+ c.gridwidth = width;
+ c.gridy = row;
+ return c;
+ }
+
+ public GridBagConstraints constraints(int x, int width) {
+ return constraints(x, width, GridBagConstraints.NONE);
+ }
+
+ void idle_exception(JFrame owner, Exception e) {
+ if (e instanceof FileNotFoundException) {
+ JOptionPane.showMessageDialog(owner,
+ ((FileNotFoundException) e).getMessage(),
+ "Cannot open target device",
+ JOptionPane.ERROR_MESSAGE);
+ } else if (e instanceof AltosSerialInUseException) {
+ JOptionPane.showMessageDialog(owner,
+ String.format("Device \"%s\" already in use",
+ device.toShortString()),
+ "Device in use",
+ JOptionPane.ERROR_MESSAGE);
+ } else if (e instanceof IOException) {
+ IOException ee = (IOException) e;
+ JOptionPane.showMessageDialog(owner,
+ device.toShortString(),
+ ee.getLocalizedMessage(),
+ JOptionPane.ERROR_MESSAGE);
+ } else {
+ JOptionPane.showMessageDialog(owner,
+ String.format("Connection to \"%s\" failed",
+ device.toShortString()),
+ "Connection Failed",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }