Ejemplo n.º 1
0
 /**
  * Wait for response from robot
  *
  * @return false if inData is still null. true if robot responded
  */
 public boolean waitForResponse() {
   int timeout = 100;
   while (inData == null) {
     try {
       Thread.sleep(timeout);
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
     if (timeout >= 1000) {
       GUI.printErrorToStatus("No repsonse from robot.");
       return false;
     }
     timeout = timeout + 100;
   }
   return true;
 }
Ejemplo n.º 2
0
  /**
   * Receives events and calls methods depending on the event
   *
   * @param ActionEvent
   */
  @Override
  public void actionPerformed(ActionEvent e) {
    JMenuItem source = (JMenuItem) (e.getSource());

    if (source.getActionCommand().equals("import")) {
      int returnVal = fc.showOpenDialog(null);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        setChanged();
        notifyObservers(file);
        GUI.printToStatus("Opened file: " + file.toString());
        System.out.println("should've been notified");
        // This is where a real application would open the file.
        // log.append("Opening: " + file.getName() + "." + newline);
      } else {
        System.out.println("No file selected");
      }
    } else if (source.getActionCommand().equals("exit")) {
      // TODO prompt user to save work?
      System.exit(0);

    } else if (source.getActionCommand().equals("axesVis")) {
      JCheckBoxMenuItem checkBox = (JCheckBoxMenuItem) source;
      setChanged();
      notifyObservers(checkBox);
    } else if (source.getActionCommand().equals("gridVis")) {
      JCheckBoxMenuItem checkBox = (JCheckBoxMenuItem) source;
      setChanged();
      notifyObservers(checkBox);
    } else if (source.getActionCommand().equals("setComPort")) {
      JMenuItem checkBox = (JMenuItem) source;
      setChanged();
      notifyObservers(checkBox);
    } else if (source.getActionCommand().equals("doCalib")) {
      JMenuItem calibButton = (JMenuItem) source;
      setChanged();
      notifyObservers(calibButton);
    } else if (source.getActionCommand().equals("about")) {
      JOptionPane.showMessageDialog(
          null,
          "Bachelors Work @ Chalmers University Of Technology spring semester 2012\nAuthors: \nJohan Sandstrom\nDaniel Nicklasson\nChristian Fransson\nSimon Ivarsson");
    }
  }