Example #1
1
  /**
   * Sets a mnemomic for the specified button.
   *
   * @param b button
   * @param mnem mnemonics that have already been assigned
   */
  public static void setMnemonic(final AbstractButton b, final StringBuilder mnem) {
    // do not set mnemonics for Mac! Alt+key used for special characters.
    if (Prop.MAC) return;

    // find and assign unused mnemomic
    final String label = b.getText();
    final int ll = label.length();
    for (int l = 0; l < ll; l++) {
      final char ch = Character.toLowerCase(label.charAt(l));
      if (!letter(ch) || mnem.indexOf(Character.toString(ch)) != -1) continue;
      b.setMnemonic(ch);
      mnem.append(ch);
      break;
    }
  }
  public Transferable createTransferable(JComponent comp) {

    // Clear

    image = null;

    Icon icon = null;

    if (comp instanceof JLabel) {

      JLabel label = (JLabel) comp;

      icon = label.getIcon();

    } else if (comp instanceof AbstractButton) {

      AbstractButton button = (AbstractButton) comp;

      icon = button.getIcon();
    }

    if (icon instanceof ImageIcon) {

      image = ((ImageIcon) icon).getImage();

      return this;
    }

    return null;
  }
 public void setShdPopupOnBtnClick(boolean shdPopup) {
   this.shdPopup = shdPopup;
   if (shdPopup) {
     main.addActionListener(pl);
   } else {
     main.removeActionListener(pl);
   }
 }
Example #4
0
 private void setButtonStatus(boolean status) {
   for (AbstractButton button : commandMap.keySet()) {
     button.setEnabled(status);
   }
   btnQuit.setEnabled(status);
   btnShutdown.setEnabled(status);
   btnReset.setEnabled(status);
   btnConnection.setEnabled(!status);
 }
Example #5
0
  public void addActions(JPanel buttPanel) {

    AbstractAction netcdfAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            String location = ds.getLocation();
            if (location == null) location = "test";
            int pos = location.lastIndexOf(".");
            if (pos > 0) location = location.substring(0, pos);

            String filename = fileChooser.chooseFilenameToSave(location + ".nc");
            if (filename == null) return;
            writeNetCDF(filename);
          }
        };
    BAMutil.setActionProperties(netcdfAction, "netcdf", "Write netCDF-3 file", false, 'S', -1);
    BAMutil.addActionToContainer(buttPanel, netcdfAction);

    AbstractAction ncstreamAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            String location = ds.getLocation();
            if (location == null) location = "test";
            int pos = location.lastIndexOf(".");
            if (pos > 0) location = location.substring(0, pos);

            String filename = fileChooser.chooseFilenameToSave(location + ".ncs");
            if (filename == null) return;
            writeNcstream(filename);
          }
        };
    BAMutil.setActionProperties(ncstreamAction, "netcdf", "Write ncstream file", false, 'S', -1);
    BAMutil.addActionToContainer(buttPanel, ncstreamAction);

    AbstractButton compareButton = BAMutil.makeButtcon("Select", "Compare to another file", false);
    compareButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            compareDataset();
          }
        });
    buttPanel.add(compareButton);

    AbstractAction attAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            showAtts();
          }
        };
    BAMutil.setActionProperties(attAction, "FontDecr", "global attributes", false, 'A', -1);
    BAMutil.addActionToContainer(buttPanel, attAction);
  }
Example #6
0
  /**
   * Handles the <tt>ActionEvent</tt>, when one of the tool bar buttons is clicked.
   *
   * @param e the <tt>ActionEvent</tt> that notified us
   */
  public void actionPerformed(ActionEvent e) {
    AbstractButton button = (AbstractButton) e.getSource();
    String buttonText = button.getName();

    ChatPanel chatPanel = chatContainer.getCurrentChat();

    if (buttonText.equals("previous")) {
      chatPanel.loadPreviousPageFromHistory();
    } else if (buttonText.equals("next")) {
      chatPanel.loadNextPageFromHistory();
    } else if (buttonText.equals("sendFile")) {
      SipCommFileChooser scfc =
          GenericFileDialog.create(
              null,
              "Send file...",
              SipCommFileChooser.LOAD_FILE_OPERATION,
              ConfigurationUtils.getSendFileLastDir());
      File selectedFile = scfc.getFileFromDialog();
      if (selectedFile != null) {
        ConfigurationUtils.setSendFileLastDir(selectedFile.getParent());
        chatContainer.getCurrentChat().sendFile(selectedFile);
      }
    } else if (buttonText.equals("invite")) {
      ChatInviteDialog inviteDialog = new ChatInviteDialog(chatPanel);

      inviteDialog.setVisible(true);
    } else if (buttonText.equals("leave")) {
      ChatRoomWrapper chatRoomWrapper =
          (ChatRoomWrapper) chatPanel.getChatSession().getDescriptor();
      ChatRoomWrapper leavedRoomWrapped =
          GuiActivator.getMUCService().leaveChatRoom(chatRoomWrapper);
    } else if (buttonText.equals("call")) {
      call(false, false);
    } else if (buttonText.equals("callVideo")) {
      call(true, false);
    } else if (buttonText.equals("desktop")) {
      call(true, true);
    } else if (buttonText.equals("options")) {
      GuiActivator.getUIService().getConfigurationContainer().setVisible(true);
    } else if (buttonText.equals("font")) chatPanel.showFontChooserDialog();
    else if (buttonText.equals("createConference")) {
      chatPanel.showChatConferenceDialog();
    }
  }
  public void layoutComponents() {
    setLayout(new BorderLayout());
    add(main, BorderLayout.CENTER);

    if (popperIsVisible) {
      if (getPopperButtonLocation() == RIGHT) {
        popper.setPreferredSize(new Dimension(14, main.getHeight()));
        add(popper, BorderLayout.EAST);
      } else if (getPopperButtonLocation() == BOTTOM) {
        popper.setPreferredSize(new Dimension(main.getWidth(), 14));
        add(popper, BorderLayout.SOUTH);

        setPopperArrowDirection(DOWN);
        setPopupLocation(popper.getX(), popper.getY() + popper.getHeight() + 5);
      }
    }

    Utilities.updateView(this);
  }
  public void setUseFlatUI(boolean b) {
    main.setContentAreaFilled(!b);
    main.setFocusPainted(!b);
    main.setBorderPainted(!b);
    main.setMargin(new Insets(1, 1, 1, 1));

    popper.setContentAreaFilled(!b);
    popper.setFocusPainted(!b);
    popper.setBorderPainted(!b);
    popper.setMargin(new Insets(1, 1, 1, 1));

    setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    setOpaque(false);

    MouseAdapter ma =
        new MouseAdapter() {
          public void mouseEntered(MouseEvent e) {
            main.setContentAreaFilled(true);
            main.setBackground(new Color(216, 240, 254));
            // m.getMainButton().setForeground( Color.black );
            setBorder(new LineBorder(new Color(200, 200, 200), 1));
            setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

            popper.setBackground(new Color(242, 242, 242));
            popper.setContentAreaFilled(true);
            popper.setBorder(menu.getBorder());
          }

          public void mouseExited(MouseEvent e) {
            main.setContentAreaFilled(false);
            //	c.setForeground( Color.black );
            setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
            setCursor(Cursor.getDefaultCursor());

            popper.setContentAreaFilled(false);
            popper.setBorder(null);
          }
        };

    main.addMouseListener(ma);
    popper.addMouseListener(ma);
  }
Example #9
0
 /**
  * Sets the output text.
  *
  * @param out cached output
  */
 public void setText(final ArrayOutput out) {
   final byte[] buf = out.buffer();
   final int size = (int) out.size();
   final byte[] chop = token(DOTS);
   if (out.finished() && size >= chop.length) {
     System.arraycopy(chop, 0, buf, size - chop.length, chop.length);
   }
   text.setText(buf, size);
   header.setText((out.finished() ? CHOPPED : "") + RESULT);
   home.setEnabled(gui.context.data() != null);
 }
Example #10
0
  /** Creates a new view. */
  public NetView() {
    initComponents();

    scrollPane.setLayout(new PlacardScrollPaneLayout());
    scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0));

    setEditor(new DefaultDrawingEditor());
    undo = new UndoRedoManager();
    view.setDrawing(createDrawing());
    view.getDrawing().addUndoableEditListener(undo);
    initActions();
    undo.addPropertyChangeListener(
        new PropertyChangeListener() {

          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            setHasUnsavedChanges(undo.hasSignificantEdits());
          }
        });

    ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels");

    JPanel placardPanel = new JPanel(new BorderLayout());
    javax.swing.AbstractButton pButton;
    pButton = ButtonFactory.createZoomButton(view);
    pButton.putClientProperty("Quaqua.Button.style", "placard");
    pButton.putClientProperty("Quaqua.Component.visualMargin", new Insets(0, 0, 0, 0));
    pButton.setFont(UIManager.getFont("SmallSystemFont"));
    placardPanel.add(pButton, BorderLayout.WEST);
    toggleGridButton = pButton = ButtonFactory.createToggleGridButton(view);
    pButton.putClientProperty("Quaqua.Button.style", "placard");
    pButton.putClientProperty("Quaqua.Component.visualMargin", new Insets(0, 0, 0, 0));
    pButton.setFont(UIManager.getFont("SmallSystemFont"));
    labels.configureToolBarButton(pButton, "view.toggleGrid.placard");
    placardPanel.add(pButton, BorderLayout.EAST);
    scrollPane.add(placardPanel, JScrollPane.LOWER_LEFT_CORNER);

    toggleGridButton.setSelected(preferences.getBoolean("view.gridVisible", false));
    view.setScaleFactor(preferences.getDouble("view.scaleFactor", 1d));

    view.addPropertyChangeListener(
        new PropertyChangeListener() {

          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            if ("scaleFactor".equals(name)) {
              preferences.putDouble("view.scaleFactor", (Double) evt.getNewValue());
              firePropertyChange("scaleFactor", evt.getOldValue(), evt.getNewValue());
            }
          }
        });
  }
Example #11
0
  /**
   * Default constructor.
   *
   * @param man view manager
   */
  public TextView(final ViewNotifier man) {
    super(TEXTVIEW, man);
    border(5).layout(new BorderLayout(0, 5));

    header = new BaseXHeader(RESULT);

    home = BaseXButton.command(GUIMenuCmd.C_HOME, gui);
    home.setEnabled(false);

    text = new TextPanel(false, gui);
    text.setSyntax(new SyntaxXML());
    search = new SearchEditor(gui, text);

    final AbstractButton save = BaseXButton.get("c_save", SAVE, false, gui);
    final AbstractButton find = search.button(FIND);

    final BaseXBack buttons = new BaseXBack(false);
    buttons.layout(new TableLayout(1, 3, 1, 0)).border(0, 0, 4, 0);
    buttons.add(save);
    buttons.add(home);
    buttons.add(find);

    final BaseXBack b = new BaseXBack(false).layout(new BorderLayout());
    b.add(buttons, BorderLayout.WEST);
    b.add(header, BorderLayout.EAST);
    add(b, BorderLayout.NORTH);

    add(search, BorderLayout.CENTER);

    save.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            save();
          }
        });
    refreshLayout();
  }
  public boolean importData(JComponent comp, Transferable t) {

    ImageIcon icon = null;

    try {

      if (t.isDataFlavorSupported(flavors[0])) {

        image = (Image) t.getTransferData(flavors[0]);

        icon = new ImageIcon(image);
      }

      if (comp instanceof JLabel) {

        JLabel label = (JLabel) comp;

        label.setIcon(icon);

        return true;

      } else if (comp instanceof AbstractButton) {

        AbstractButton button = (AbstractButton) comp;

        button.setIcon(icon);

        return true;
      }

    } catch (UnsupportedFlavorException ignored) {
    } catch (IOException ignored) {
    }

    return false;
  }
Example #13
0
 /**
  * Serializes the specified nodes.
  *
  * @param n nodes to display
  */
 private void setText(final DBNodes n) {
   if (visible()) {
     try {
       final ArrayOutput ao = new ArrayOutput();
       ao.setLimit(gui.gopts.get(GUIOptions.MAXTEXT));
       if (n != null) n.serialize(Serializer.get(ao));
       setText(ao);
       cmd = null;
       ns = ao.finished() ? n : null;
     } catch (final IOException ex) {
       Util.debug(ex);
     }
   } else {
     home.setEnabled(gui.context.data() != null);
   }
 }
  public void createButtons(String text, Icon icon) {
    if (main == null) {
      main = new JButton(text, icon);

      if (text == null) {
        main.setMargin(new Insets(0, 0, 0, 0));
      }
    }

    // main.setFont( new Font("Verdana", Font.PLAIN, 11) );
    ImageIcon img = new ImageIcon("resources/images/popicon.gif");
    popper =
        new JButton(/*img*/ ) {

          public void paintComponent(Graphics g) {
            super.paintComponent(g);

            Graphics2D g2 = (Graphics2D) g;
            int width = getWidth(), height = getHeight();
            int midWidth = width / 2, midHeight = height / 2;

            int[] xpoints = {midWidth - 4, midWidth, midWidth + 4};
            int[] ypoints = {midHeight - 1, midHeight + 3, midHeight - 1};

            if (ARROW_DIRECTION == FORWARD) {
              xpoints = new int[] {midWidth - 3, midWidth - 3, midWidth + 2};
              ypoints = new int[] {midHeight - 4, midHeight + 4, midHeight};
            }

            g2.setColor(getPopperArrowColor());
            g2.fill(new Polygon(xpoints, ypoints, 3));
          }
        };

    // popper.setPreferredSize( new Dimension(img.getImage().getWidth(this) + 10,

    popper.addActionListener(this);

    setBorder(null);
    // setLayout( new BoxLayout(this, BoxLayout.X_AXIS) );
    layoutComponents();
  }
  public void showMenu() {
    if (LOCATION == BELOW) {
      setPopupLocation(main.getX() - main.getWidth(), main.getY() + getHeight());
    } else if (LOCATION == ABOVE) {
      setPopupLocation(main.getX() - main.getWidth(), main.getY() - menu.getHeight());
    }

    if (getPopperButtonLocation() == RIGHT) {
      if (getPopperButtonLocation() == RIGHT) {
        tempPopArrowDir = getPopperArrowDirection();
      }

      setPopperArrowDirection(DOWN);
    }

    menu.show(popper, getPopupX(), getPopupY());
  }
Example #16
0
  public NcmlEditor(JPanel buttPanel, PreferencesExt prefs) {
    this.prefs = prefs;
    fileChooser = new FileManager(null, null, null, (PreferencesExt) prefs.node("FileManager"));

    AbstractAction coordAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            addCoords = (Boolean) getValue(BAMutil.STATE);
            String tooltip = addCoords ? "add Coordinates is ON" : "add Coordinates is OFF";
            coordButt.setToolTipText(tooltip);
          }
        };
    addCoords = prefs.getBoolean("coordState", false);
    String tooltip2 = addCoords ? "add Coordinates is ON" : "add Coordinates is OFF";
    BAMutil.setActionProperties(coordAction, "addCoords", tooltip2, true, 'C', -1);
    coordAction.putValue(BAMutil.STATE, Boolean.valueOf(addCoords));
    coordButt = BAMutil.addActionToContainer(buttPanel, coordAction);

    protoChooser = new ComboBox((PreferencesExt) prefs.node("protoChooser"));
    addProtoChoices();
    buttPanel.add(protoChooser);
    protoChooser.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String ptype = (String) protoChooser.getSelectedItem();
            String proto = protoMap.get(ptype);
            if (proto != null) {
              editor.setText(proto);
            }
          }
        });

    editor = new JEditorPane();

    // Instantiate a XMLEditorKit with wrapping enabled.
    XMLEditorKit kit = new XMLEditorKit(false);

    // Set the wrapping style.
    kit.setWrapStyleWord(true);

    editor.setEditorKit(kit);

    // Set the font style.
    editor.setFont(new Font("Monospaced", Font.PLAIN, 12));

    // Set the tab size
    editor.getDocument().putProperty(PlainDocument.tabSizeAttribute, 2);

    // Enable auto indentation.
    editor.getDocument().putProperty(XMLDocument.AUTO_INDENTATION_ATTRIBUTE, true);

    // Enable tag completion.
    editor.getDocument().putProperty(XMLDocument.TAG_COMPLETION_ATTRIBUTE, true);

    // Initialise the folding
    kit.setFolding(true);

    // Set a style
    kit.setStyle(XMLStyleConstants.ATTRIBUTE_NAME, Color.RED, Font.BOLD);

    // Put the editor in a panel that will force it to resize, when a different view is choosen.
    ScrollableEditorPanel editorPanel = new ScrollableEditorPanel(editor);

    JScrollPane scroller = new JScrollPane(editorPanel);

    // Add the number margin as a Row Header View
    scroller.setRowHeaderView(new LineNumberMargin(editor));

    AbstractAction wrapAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            XMLEditorKit kit = (XMLEditorKit) editor.getEditorKit();
            kit.setLineWrappingEnabled(!kit.isLineWrapping());
            editor.updateUI();
          }
        };
    BAMutil.setActionProperties(wrapAction, "Wrap", "Toggle Wrapping", false, 'W', -1);
    BAMutil.addActionToContainer(buttPanel, wrapAction);

    AbstractAction saveAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            String location = (ds == null) ? ncmlLocation : ds.getLocation();
            if (location == null) location = "test";
            int pos = location.lastIndexOf(".");
            if (pos > 0) location = location.substring(0, pos);
            String filename = fileChooser.chooseFilenameToSave(location + ".ncml");
            if (filename == null) return;
            if (doSaveNcml(editor.getText(), filename)) ncmlLocation = filename;
          }
        };
    BAMutil.setActionProperties(saveAction, "Save", "Save NcML", false, 'S', -1);
    BAMutil.addActionToContainer(buttPanel, saveAction);

    AbstractAction netcdfAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            if (outChooser == null) {
              outChooser = new NetcdfOutputChooser((Frame) null);
              outChooser.addPropertyChangeListener(
                  "OK",
                  new PropertyChangeListener() {
                    public void propertyChange(PropertyChangeEvent evt) {
                      writeNetcdf((NetcdfOutputChooser.Data) evt.getNewValue());
                    }
                  });
            }

            String location = (ds == null) ? ncmlLocation : ds.getLocation();
            if (location == null) location = "test";
            int pos = location.lastIndexOf(".");
            if (pos > 0) location = location.substring(0, pos);

            outChooser.setOutputFilename(location);
            outChooser.setVisible(true);
          }
        };
    BAMutil.setActionProperties(netcdfAction, "netcdf", "Write netCDF file", false, 'N', -1);
    BAMutil.addActionToContainer(buttPanel, netcdfAction);

    AbstractAction transAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            doTransform(editor.getText());
          }
        };
    BAMutil.setActionProperties(
        transAction,
        "Import",
        "read textArea through NcMLReader\n write NcML back out via resulting dataset",
        false,
        'T',
        -1);
    BAMutil.addActionToContainer(buttPanel, transAction);

    AbstractButton compareButton = BAMutil.makeButtcon("Select", "Check NcML", false);
    compareButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Formatter f = new Formatter();
            checkNcml(f);

            infoTA.setText(f.toString());
            infoTA.gotoTop();
            infoWindow.show();
          }
        });
    buttPanel.add(compareButton);

    setLayout(new BorderLayout());
    add(scroller, BorderLayout.CENTER);

    // the info window
    infoTA = new TextHistoryPane();
    infoWindow = new IndependentWindow("Extra Information", BAMutil.getImage("netcdfUI"), infoTA);
    infoWindow.setBounds(
        (Rectangle) prefs.getBean("InfoWindowBounds", new Rectangle(300, 300, 500, 300)));
  }
Example #17
0
  /**
   * Handles the <tt>ActionEvent</tt>, when one of the tool bar buttons is clicked.
   *
   * @param e the <tt>ActionEvent</tt> that notified us
   */
  public void actionPerformed(ActionEvent e) {
    AbstractButton button = (AbstractButton) e.getSource();
    String buttonText = button.getName();

    ChatPanel chatPanel = chatContainer.getCurrentChat();

    if (buttonText.equals("previous")) {
      chatPanel.loadPreviousPageFromHistory();
    } else if (buttonText.equals("next")) {
      chatPanel.loadNextPageFromHistory();
    } else if (buttonText.equals("sendFile")) {
      SipCommFileChooser scfc =
          GenericFileDialog.create(
              null,
              "Send file...",
              SipCommFileChooser.LOAD_FILE_OPERATION,
              ConfigurationUtils.getSendFileLastDir());
      File selectedFile = scfc.getFileFromDialog();
      if (selectedFile != null) {
        ConfigurationUtils.setSendFileLastDir(selectedFile.getParent());
        chatContainer.getCurrentChat().sendFile(selectedFile);
      }
    } else if (buttonText.equals("history")) {
      HistoryWindow history;

      HistoryWindowManager historyWindowManager =
          GuiActivator.getUIService().getHistoryWindowManager();

      ChatSession chatSession = chatPanel.getChatSession();

      if (historyWindowManager.containsHistoryWindowForContact(chatSession.getDescriptor())) {
        history = historyWindowManager.getHistoryWindowForContact(chatSession.getDescriptor());

        if (history.getState() == JFrame.ICONIFIED) history.setState(JFrame.NORMAL);

        history.toFront();
      } else {
        history = new HistoryWindow(chatPanel.getChatSession().getDescriptor());

        history.setVisible(true);

        historyWindowManager.addHistoryWindowForContact(chatSession.getDescriptor(), history);
      }
    } else if (buttonText.equals("invite")) {
      ChatInviteDialog inviteDialog = new ChatInviteDialog(chatPanel);

      inviteDialog.setVisible(true);
    } else if (buttonText.equals("leave")) {
      ConferenceChatManager conferenceManager =
          GuiActivator.getUIService().getConferenceChatManager();
      conferenceManager.leaveChatRoom((ChatRoomWrapper) chatPanel.getChatSession().getDescriptor());
    } else if (buttonText.equals("call")) {
      call(false, false);
    } else if (buttonText.equals("callVideo")) {
      call(true, false);
    } else if (buttonText.equals("desktop")) {
      call(true, true);
    } else if (buttonText.equals("options")) {
      GuiActivator.getUIService().getConfigurationContainer().setVisible(true);
    } else if (buttonText.equals("font")) chatPanel.showFontChooserDialog();
  }
 public void setEnabled(boolean b) {
   main.setEnabled(b);
   popper.setEnabled(b);
 }
Example #19
0
  private void guiSetup() throws IOException {
    setContentPane(root);

    // control
    commandMap.put(btnForward, Command.FORWARD);
    commandMap.put(btnBackward, Command.BACKWARD);
    commandMap.put(btnLeft, Command.TURN_LEFT);
    commandMap.put(btnRight, Command.TURN_RIGHT);
    commandMap.put(btnStop, Command.STOP);

    // Servo && Camera
    commandMap.put(btnServoDown, Command.SERVO_DOWN);
    commandMap.put(btnServoLeft, Command.SERVO_LEFT);
    commandMap.put(btnServoRight, Command.SERVO_RIGHT);
    commandMap.put(btnServoUp, Command.SERVO_UP);
    commandMap.put(btnCamera, Command.TOGGLE_CAMERA);

    // LEDs
    commandMap.put(btnLeftLed, Command.TOGGLE_LEFT_BLINK);
    commandMap.put(btnRightLed, Command.TOGGLE_RIGHT_BLINK);
    commandMap.put(btnLED, Command.TOGGLE_LED);

    // speeds
    commandMap.put(btnSpeed1, Command.SPEED);
    commandMap.put(btnSpeed2, Command.SPEED);
    commandMap.put(btnSpeed3, Command.SPEED);
    commandMap.put(btnSpeed4, Command.SPEED);
    commandMap.put(btnSpeed5, Command.SPEED);

    // debugs
    commandMap.put(btnLF, Command.LEFT_FORWARD);
    commandMap.put(btnLB, Command.LEFT_BACKWARD);
    commandMap.put(btnLP, Command.LEFT_PAUSE);
    commandMap.put(btnRF, Command.RIGHT_FORWARD);
    commandMap.put(btnRB, Command.RIGHT_BACKWARD);
    commandMap.put(btnRP, Command.RIGHT_PAUSE);

    for (AbstractButton button : commandMap.keySet()) {
      button.addActionListener(this);
    }
    btnQuit.addActionListener(this);
    btnConnection.addActionListener(this);
    btnReset.addActionListener(this);
    btnShutdown.addActionListener(this);

    /*
            btnForward.addActionListener (this);
            btnLeft.addActionListener (this);
            btnBackward.addActionListener (this);
            btnRight.addActionListener (this);
            btnStop.addActionListener (this);

            btnSpeed1.addActionListener (this);
            btnSpeed2.addActionListener (this);
            btnSpeed3.addActionListener (this);
            btnSpeed4.addActionListener (this);
            btnSpeed5.addActionListener (this);
            btnLeftLed.addActionListener (this);
            btnRightLed.addActionListener (this);
            btnServoLeft.addActionListener (this);
            btnServoUp.addActionListener (this);
            btnServoRight.addActionListener (this);
            btnServoDown.addActionListener (this);
            btnLED.addActionListener (this);
            btnCamera.addActionListener (this);
            btnLF.addActionListener (this);
            btnLB.addActionListener (this);
            btnLP.addActionListener (this);
            btnRF.addActionListener (this);
            btnRB.addActionListener (this);
            btnRP.addActionListener (this);
    */

    ButtonGroup group1 = new ButtonGroup();
    group1.add(btnSpeed1);
    group1.add(btnSpeed2);
    group1.add(btnSpeed3);
    group1.add(btnSpeed4);
    group1.add(btnSpeed5);
    btnSpeed3.setSelected(true);

    setButtonStatus(false);
  }
 public void addActionListener(ActionListener l) {
   main.addActionListener(l);
   listener = l;
 }
Example #21
0
 public void ajouterActionListener(ActionListener actionListener, AbstractButton abstractButton) {
   abstractButton.addActionListener(actionListener);
 }