public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();

    if (cmd.equals("ok")) System.out.println("do ok");
    else if (cmd.equals("cancel")) this.setVisible(false);
    else if (cmd.equals("help")) displayHelp();
  }
示例#2
0
 /**
  * Handle ui actions.
  *
  * @param event The action event
  */
 public void actionPerformed(ActionEvent event) {
   String action = event.getActionCommand();
   if (action.equals(GuiUtils.CMD_SAVE)) {
     doSave();
   } else if (action.equals(GuiUtils.CMD_SAVEAS)) {
     doSaveAs();
   } else if (action.equals(GuiUtils.CMD_RENAME)) {
     doRename();
   } else if (action.equals(GuiUtils.CMD_NEW)) {
     doNew();
   } else if (action.equals(GuiUtils.CMD_IMPORT)) {
     doImport();
   } else if (action.equals(GuiUtils.CMD_EXPORT)) {
     doExport();
   } else if (action.equals(GuiUtils.CMD_REMOVE)) {
     doRemove();
   } else if (action.equals(GuiUtils.CMD_CLOSE)) {
     doClose();
   } else if (action.equals(CMD_BLACKBG)) {
     setCanvasBackground(Color.BLACK);
   } else if (action.equals(CMD_WHITEBG)) {
     setCanvasBackground(Color.WHITE);
   } else {
     super.actionPerformed(event);
   }
 }
示例#3
0
  // ボタンが押されたときのイベント処理
  public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();

    if (cmd.equals("submit")) { // 送信
      sendMessage("msg " + msgTextField.getText());
      msgTextField.setText("");
    } else if (cmd.equals("rename")) { // 名前の変更
      sendMessage("setName " + nameTextField.getText());
    } else if (cmd.equals("addRoom")) { // 部屋を作成
      String roomName = nameTextField.getText();
      sendMessage("addRoom " + roomName);
      enteredRoom(roomName);
      sendMessage("getUsers " + roomName);
    } else if (cmd.equals("enterRoom")) { // 入室
      Object room = roomList.getSelectedValue();
      if (room != null) {
        String roomName = room.toString();
        sendMessage("enterRoom " + roomName);
        enteredRoom(roomName);
      }
    } else if (cmd.equals("exitRoom")) { // 退室
      sendMessage("exitRoom " + roomName);
      exitedRoom();
    }
  }
示例#4
0
 /**
  * Handle the event
  *
  * @param ae The event
  */
 public void actionPerformed(ActionEvent ae) {
   String cmd = ae.getActionCommand();
   if (cmd.equals(CMD_CONNECT)) {
     doConnect();
   } else {
     super.actionPerformed(ae);
   }
 }
示例#5
0
    public void actionPerformed(ActionEvent event) {

      JMenuItem mi;
      String label = "";

      if (warningPopup == null) {
        warningPopup = new WarningDialog(textViewerFrame);
      }
      if ((editor1 == null) || (editor1.getDocument() == null)) {
        String errstr = "TextViewer:editor1 or document is null";
        warningPopup.display(errstr);
        return;
      }
      String actionStr = event.getActionCommand(); // is not makeing anysense
      // when keystrokes typed
      if ((event.getSource() instanceof JMenuItem)) {
        mi = (JMenuItem) event.getSource();
        label = mi.getText();
      } else if ((event.getSource() instanceof JTextArea)) { // keystroke
        label = "FindAgain"; // just set it to findagain
      } else {
        System.err.println("Debug:TextViewer:" + actionStr);
        System.err.println("Debug:TextViewer:" + event.getSource().toString());
        String errstr =
            "TextViewer:FindAction: "
                + event.getSource().toString()
                + " not an instance of JMenuItem or JTextArea";
        warningPopup.display(errstr);
        return;
      }

      if (label.equals("FindAgain")) {
        isFindAgain = true;
        lastFindStr = lastFindStr;
      } else {
        isFindAgain = false;
        lastFindStr = "";
      }
      StringBoolean content = new StringBoolean(lastFindStr, forwardFindDirection);

      boolean okPressed = mySearchDialog.display(content);
      if (!okPressed) {
        return;
      }
      lastFindStr = content.mystring;
      forwardFindDirection = content.myboolean;

      if (forwardFindDirection) {
        lastFindIndex = searchForward(lastFindStr);
        //		System.out.println("Debug:TextViewer: lastFindIndex:"+lastFindIndex);

      } else {
        lastFindIndex = searchBackward(lastFindStr);
        //		System.out.println("Debug:TextViewer: lastFindIndex:"+lastFindIndex);
      }
    }
 public void doAction(ActionEvent e) {
   String cmd = e.getActionCommand();
   // the new button creates a new set of texfields
   if (cmd.equals("new")) {
     Container container = getParent();
     if (container != null) container.setVisible(false);
     displayNewTxf("", "");
     if (container != null) container.setVisible(true);
   }
 }
 /**
  * Handle action events
  *
  * @param event event to handle
  */
 public void actionPerformed(ActionEvent event) {
   String cmd = event.getActionCommand();
   if (cmd.equals(GuiUtils.CMD_OK) || cmd.equals(GuiUtils.CMD_APPLY)) {
     accept();
   }
   if (cmd.equals(GuiUtils.CMD_OK) || cmd.equals(GuiUtils.CMD_CANCEL)) {
     close();
   }
   if (cmd.equals(GuiUtils.CMD_HELP)) {
     ucar.unidata.ui.Help.getDefaultHelp().gotoTarget(helpId);
   }
 }
  /**
   * An interface action has been performed. Find out what it was and handle it.
   *
   * @param event The event that has occured.
   */
  public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();

    if (command.equals("0")
        || command.equals("1")
        || command.equals("2")
        || command.equals("3")
        || command.equals("4")
        || command.equals("5")
        || command.equals("6")
        || command.equals("7")
        || command.equals("8")
        || command.equals("9")) {
      int number = Integer.parseInt(command);
      calc.numberPressed(number);
    } else if (command.equals("A")
        || command.equals("B")
        || command.equals("C")
        || command.equals("D")
        || command.equals("E")
        || command.equals("F")) {
      int number = getNumberFromHexString(command);
      calc.numberPressed(number);
    } else if (command.equals("+")) {
      calc.plus();
    } else if (command.equals("-")) {
      calc.minus();
    } else if (command.equals("=")) {
      calc.equals();
    } else if (command.equals("C")) {
      calc.clear();
    } else if (command.equals("?")) {
      showInfo();
    }
    // Exercise 1 multi
    else if (command.equals("*")) {
      calc.multiplication();
    }
    // Exercise 1 division
    else if (command.equals("/")) {
      calc.division();
    } else if (command.equals("Cl")) {
      // had to change this, so it works in hexadecimal mode
      calc.clear();
    } else if (command.equals("Hexadecimal mode")) {
      calc.flipHexSwitch(); // flip the switch
    }

    // else unknown command.

    redisplay();
  }
  /**
   * Controls the zoom menu bar
   *
   * @param a the ActionEvent
   */
  public void actionPerformed(ActionEvent a) {

    if (a.getActionCommand().equals("Update")) {
      this.repaint();
    }

    if (a.getActionCommand().equals("25%")) {
      this.zoom(.25);
      enableZoomItems();
      twentyFive.setEnabled(false);
    }

    if (a.getActionCommand().equals("50%")) {
      this.zoom(.50);
      enableZoomItems();
      fifty.setEnabled(false);
    }

    if (a.getActionCommand().equals("75%")) {
      this.zoom(.75);
      enableZoomItems();
      seventyFive.setEnabled(false);
    }

    if (a.getActionCommand().equals("100%")) {
      this.zoom(1.0);
      enableZoomItems();
      hundred.setEnabled(false);
    }

    if (a.getActionCommand().equals("150%")) {
      this.zoom(1.5);
      enableZoomItems();
      hundredFifty.setEnabled(false);
    }

    if (a.getActionCommand().equals("200%")) {
      this.zoom(2.0);
      enableZoomItems();
      twoHundred.setEnabled(false);
    }

    if (a.getActionCommand().equals("500%")) {
      this.zoom(5.0);
      enableZoomItems();
      fiveHundred.setEnabled(false);
    }
  }
示例#10
0
  /**
   * El action performed es el encargado de recibir las acciones que se realice en los respectivos
   * botones.
   */
  public void actionPerformed(ActionEvent event) {
    String comando = event.getActionCommand();

    if (comando.equals(IngresarHora)) {
      String[] parametros = new String[0];
      llamada.main(parametros);
    } else if (comando.equals(IngresarVehiculo)) {
      String[] parametros = new String[0];
      llamada2.main(parametros);
    } else {
      String[] parametros = new String[0];
      llamada3.main(parametros);
    }
  }
示例#11
0
  public void actionPerformed(ActionEvent e) {
    String cmd = (e.getActionCommand());

    if (cmd.equals(aboutItem.getText()))
      JOptionPane.showMessageDialog(
          this,
          "Simple Image Program for DB2004\nversion 0.1\nThanks to BvS",
          "About imageLab",
          JOptionPane.INFORMATION_MESSAGE);
    else if (cmd.equals(quitItem.getText())) System.exit(0);
    else if (cmd.equals(openItem.getText())) {
      int returnVal = chooser.showOpenDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        try {
          pic2 = new Picture(chooser.getSelectedFile().getName());
          pic1 = new Picture(pic2.width(), pic2.height());
          lab.setIcon(pic2.getJLabel().getIcon());
          sliderPanel.setVisible(false);
          pack();
          repaint();
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this,
              "Could not open " + chooser.getSelectedFile().getName() + "\n" + ex.getMessage(),
              "Open Error",
              JOptionPane.INFORMATION_MESSAGE);
        }
      }

    } else if (cmd.equals(saveItem.getText())) {
      int returnVal = chooser.showSaveDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        try {
          pic2.save(chooser.getSelectedFile().getName());
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this,
              "Could not write " + chooser.getSelectedFile().getName() + "\n" + ex.getMessage(),
              "Save Error",
              JOptionPane.INFORMATION_MESSAGE);
        }
      }
    }
  }
示例#12
0
 /**
  * Handle the CLOSEANCEL, OK, HELP, events.
  *
  * @param event The event
  */
 public void actionPerformed(ActionEvent event) {
   String cmd = event.getActionCommand();
   if (cmd.equals(GuiUtils.CMD_CLOSE)) {
     doClose();
   } else if (cmd.equals(GuiUtils.CMD_NEW)) {
     if (myTables.size() > 0) {
       ((ParamDefaultsTable) myTables.get(0)).addNewRow();
     }
   } else if (cmd.equals(GuiUtils.CMD_OK)) {
     saveData();
     doClose();
   } else if (cmd.equals(GuiUtils.CMD_HELP)) {
     showHelp();
   } else if (cmd.equals(GuiUtils.CMD_SAVEAS)) {
     doSaveAs(getCurrentTable().getParamInfoList());
   } else if (cmd.equals(GuiUtils.CMD_OPEN)) {
     doOpen();
   } else if (cmd.equals(GuiUtils.CMD_IMPORT)) {
     doImport();
   }
 }
  public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();

    if (cmd.equals("cancel")) {
      this.dispose();
      timer.cancel();
    } else if (cmd.equals("ok")) {
      StnPlotSpecification spec = createPlotSpec();
      try {
        spec.writeToLog("New Station Value Plot (" + mFileViewer.getTitle() + "):");
      } catch (Exception ex) {
      }

      JOAStnValPlotWindow plotWind = new JOAStnValPlotWindow(spec, mFileViewer);
      plotWind.pack();
      plotWind.setVisible(true);
      mFileViewer.addOpenWindow(plotWind);
      timer.cancel();
      this.dispose();
    }
  }
示例#14
0
 public void actionPerformed(ActionEvent e) {
   // When a toolbar button or menu item is
   // clicked on this function will be called
   String cmd = e.getActionCommand();
   if (cmd.equals("New")) {
     newFile();
   } else if (cmd.equals("Open")) {
     openFile();
   } else if (cmd.equals("Save")) {
     saveFile();
   } else if (cmd.equals("Save As")) {
     saveFileAs();
   } else if (cmd.equals("Exit")) {
     exit();
   } else if (cmd.equals("Run")) {
     evaluate();
   } else if (cmd.equals("Stop")) {
     stopEvaluate();
   } else if (cmd.equals("Pretty")) {
     prettyPrint();
   }
 }
 public void actionPerformed(ActionEvent e) {
   if (ACTION_COMMAND_BUTTON1.equalsIgnoreCase(e.getActionCommand())) {
     this.doActionOnButton1();
   } else if (ACTION_COMMAND_BUTTON2.equalsIgnoreCase(e.getActionCommand())) {
     this.doActionOnButton2();
   } else if (ACTION_COMMAND_BUTTON3.equalsIgnoreCase(e.getActionCommand())) {
     this.doActionOnButton3();
   } else if (ACTION_COMMAND_BUTTON4.equalsIgnoreCase(e.getActionCommand())) {
     this.doActionOnButton4();
   } else if (ACTION_COMMAND_BUTTON5.equalsIgnoreCase(e.getActionCommand())) {
     this.doActionOnButton5();
   } else if (ACTION_COMMAND_VERTICAL_EXAGGERATION.equalsIgnoreCase(e.getActionCommand())) {
     Double ve = (Double) e.getSource();
     this.doSetVerticalExaggeration(ve);
     this.wwd.redraw();
   }
 }
示例#16
0
 public void actionPerformed(ActionEvent e) {
   Object s = e.getSource();
   if (s instanceof JButton && (JButton) s == okButton) {
     commit();
     endDialog();
   } else if (s instanceof JButton && (JButton) s == cancelButton) {
     if (VncViewer.nViewers == 1)
       if (cc.viewer instanceof VncViewer) {
         ((VncViewer) cc.viewer).exit(1);
       }
     ret = false;
     endDialog();
   } else if (s instanceof JButton && (JButton) s == optionsButton) {
     options.showDialog(getJDialog());
   } else if (s instanceof JButton && (JButton) s == aboutButton) {
     VncViewer.showAbout(getJDialog());
   } else if (s instanceof JComboBox && (JComboBox) s == server) {
     if (e.getActionCommand().equals("comboBoxEdited")) {
       server.insertItemAt(editor.getItem(), 0);
       server.setSelectedIndex(0);
     }
   }
 }
示例#17
0
 /**
  * Public by implementing ActionListener.
  *
  * @param e ActionEvent to check
  */
 public void actionPerformed(ActionEvent e) {
   actionPerformed(e.getActionCommand());
 }
示例#18
0
 @Override
 public void actionPerformed(ActionEvent e) {
   if (e.getActionCommand().equals("下棋")) {
     audience.setEnabled(false);
     fighter.setEnabled(false);
     begin.setEnabled(true);
     //			JOptionPane.showMessageDialog(null, "下棋");
     System.out.println("下棋");
     try {
       System.out.println("客户端发送下棋指令");
       out66.writeObject("对手");
       out66.flush();
       out66.writeObject(new char[0][0]);
       out66.flush();
       out66.writeObject(new boolean[0][0]);
       out66.flush();
     } catch (IOException e1) {
       e1.printStackTrace();
     }
   }
   if (e.getActionCommand().equals("观看")) {
     submit.setEnabled(false);
     regret.setEnabled(false);
     audience.setEnabled(false);
     fighter.setEnabled(false);
     //			JOptionPane.showMessageDialog(null, "观看");
     System.out.println("观看");
     try {
       out66.writeObject("观众");
       out66.flush();
       out66.writeObject(stateList.get(stateList.size() - 1));
       out66.flush();
       out66.writeObject(takenList.get(takenList.size() - 1));
       out66.flush();
     } catch (IOException e1) {
       e1.printStackTrace();
     }
   }
   /*if (e.getActionCommand().equals("人机对弈"))
   {
   	audience.setEnabled(false);
   	fighter.setEnabled(false);
   	AIPlayer.setEnabled(false);
   	begin.setEnabled(true);
   	JOptionPane.showMessageDialog(null, "人机对弈");
   }*/
   if (e.getActionCommand().equals("发送")) {
     //			JOptionPane.showMessageDialog(null, "发送");
     System.out.println("发送");
     String str = myRole + ": " + " " + jt1.getText() + "\n";
     try {
       out99.writeObject(" " + str);
       out99.flush();
       out99.writeObject(new char[8][8]);
       out99.flush();
       out99.writeObject(new boolean[8][8]);
       out99.flush();
     } catch (IOException e1) {
       e1.printStackTrace();
     }
     jt2.append(str);
     jt1.setText("");
   }
   if (e.getActionCommand().equals("取消")) {
     //			JOptionPane.showMessageDialog(null, "取消");
     System.out.println("取消");
     jt1.setText("");
   }
   if (e.getActionCommand().equals("悔棋")) {
     //			JOptionPane.showMessageDialog(null, "悔棋");
     System.out.println("悔棋");
     try {
       out66.writeObject("请求悔棋");
       out66.flush();
       out66.writeObject(new char[8][8]);
       out66.flush();
       out66.writeObject(new boolean[8][8]);
       out66.flush();
     } catch (IOException e1) {
       e1.printStackTrace();
     }
     // RegretChess();
     // ShowChessNumber();
   }
   if (e.getActionCommand().equals("退出")) {
     int quit =
         JOptionPane.showConfirmDialog(null, "您确定要强制退出吗?", "请确认您的选择", JOptionPane.YES_NO_OPTION);
     if (quit == JOptionPane.YES_OPTION) {
       JOptionPane.showMessageDialog(null, "已强制退出");
       System.exit(0);
     } else return;
   }
   if (e.getActionCommand().equals("开始")) {
     begin.setEnabled(false);
     System.out.println("客户端发送开始指令");
     //			JOptionPane.showMessageDialog(null, "开始");
     try {
       out66.writeObject("请求开始");
       out66.flush();
       out66.writeObject(stateList.get(stateList.size() - 1));
       out66.flush();
       out66.writeObject(takenList.get(takenList.size() - 1));
       out66.flush();
     } catch (IOException e1) {
       e1.printStackTrace();
     }
     Begin();
     if (kind == "黑") {
       for (int i = 0; i < 8; i++)
         for (int j = 0; j < 8; j++)
           if (cell[i][j].taken == false) {
             CheckPlace(cell[i][j]);
             if (canPut) {
               cell[i][j].ChangeBackground();
               canPut = false;
             }
           }
     }
   }
   if (e.getActionCommand().equals("存盘")) {
     //			JOptionPane.showMessageDialog(null, "存盘");
     System.out.println("存盘");
     try {
       System.out.println();
       out.writeObject(stateList);
       out.flush();
       out.close();
     } catch (IOException e1) {
       e1.printStackTrace();
     }
   }
 }
示例#19
0
    public void actionPerformed(ActionEvent ae) {
      String cmd = ae.getActionCommand().intern();
      if (ae.getSource() == butChannel) {
        String pass = null;
        String channel = (String) cboChannels.getSelectedItem();
        if (channels.containsKey(channel) && ((Boolean) channels.get(channel)).booleanValue()) {
          String message = "Password for " + channel + "? (blank for no password)";
          pass =
              JOptionPane.showInputDialog(
                  (Component) ae.getSource(),
                  message,
                  "Join Channel",
                  JOptionPane.QUESTION_MESSAGE);
        }
        server.writeObject(new SD_Channel(false, channel, ("".equals(pass) ? null : pass)));
        showUserStatus = false;
      } else if (ae.getSource() == butCreate) {
        String channel =
            JOptionPane.showInputDialog(
                (Component) ae.getSource(),
                "Enter the name of the channel",
                "Create Channel",
                JOptionPane.INFORMATION_MESSAGE);
        if (channel == null) return;
        String message = "Password for " + channel + "? (blank for no password)";
        String pass =
            JOptionPane.showInputDialog(
                (Component) ae.getSource(), message, "Join Channel", JOptionPane.QUESTION_MESSAGE);
        server.writeObject(new SD_Channel(true, channel, ("".equals(pass) ? null : pass)));
        showUserStatus = false;
        // ---------- Invite a Specific User
      } else if (ae.getSource() == butInvite) {
        String invite =
            JOptionPane.showInputDialog(
                (Component) ae.getSource(),
                "Enter the name of the User to Invite",
                "Invite User",
                JOptionPane.INFORMATION_MESSAGE);
        if (invite == null) return;
        messageText.setText("\\invite " + invite);
        sendMessage();

      } else if (cmd == "whisper") {
        String user = (String) userList.getSelectedValue();
        if (user != null && !messageText.getText().equals("") && !user.equals(username)) {
          messageText.setText("\\whisper " + user + " " + messageText.getText());
          sendMessage();
        } else {
          error(
              "invalid user or no message, type a message below,"
                  + " select a user, and then whisper");
        }
      } else if (cmd == "private message") {
        String user = (String) userList.getSelectedValue();
        if (user != null && !user.equals(username)) {
          privates.newPrivate(user);
        } else {
          error("invalid user");
        }
      } else if (ae.getActionCommand().equals("ignore")) {
        String user = (String) userList.getSelectedValue();
        if (user != null) {
          ignore(user, false);
        } else {
          error("no user selected");
        }
      } else if (cmd == "clear ignore list") {
        ignores.clear();
        updateList();
        serverMessage("ignore list cleared");
      } else if (cmd == "kick user") {
        String user = (String) userList.getSelectedValue();
        if (user != null) {
          if (user.equals(username)) {
            error("cannot kick yourself");
          } else {
            server.writeObject(new SD_Kick(user));
          }
        } else {
          error("no user selected");
        }
      }
    }
示例#20
0
  public void actionPerformed(ActionEvent e) {
    action = e.getActionCommand();

    new Thread(this).start();
  }