- 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;
+ 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);
+ }