コード例 #1
1
ファイル: TankBattle.java プロジェクト: lamChuanJiang/LBD
 public void actionPerformed(ActionEvent ae) {
   // 响应用户点击
   if (ae.getActionCommand().equals("new_game")) {
     // 如果选择 “开始新游戏” 则跳转到游戏开始
     ae_panel = new GamePanel(false);
     Thread ae_thread = new Thread(ae_panel);
     ae_thread.start();
     // 先删除旧面板 -- 开始界面
     this.remove(start_panel);
     this.add(ae_panel);
     this.addKeyListener(ae_panel);
     this.setVisible(true); // 如果没有这句点击后不会出现新的游戏面板
   } else if (ae.getActionCommand().equals("qs_game")) {
     // 退出时保存游戏进度
     Recorder.set_enemies(ae_panel.enemies);
     Recorder.save_game_data();
     // 0 表示正常退出
     System.exit(0);
   } else if (ae.getActionCommand().equals("restart_old_game")) {
     // 恢复游戏数据 -- 如果曾经保存
     Recorder.recovery_position();
     ae_panel = new GamePanel(true);
     Thread ae_thread = new Thread(ae_panel);
     ae_thread.start();
     // 先删除旧面板 -- 开始界面
     this.remove(start_panel);
     this.add(ae_panel);
     this.addKeyListener(ae_panel);
     this.setVisible(true);
   } else if (ae.getActionCommand().equals("save_now")) {
     Recorder.set_enemies(ae_panel.enemies);
     Recorder.recovery_position();
   }
 }
コード例 #2
0
ファイル: FloorPanel.java プロジェクト: osamie/xbpl4kyn
 public void actionPerformed(ActionEvent e) {
   if (e.getSource().equals(up)) {
     ViewControl.getInstance().onHallCall(floorNumber, Constants.DIRECTION_UP);
   } else if (e.getSource().equals(down)) {
     ViewControl.getInstance().onHallCall(floorNumber, Constants.DIRECTION_DOWN);
   }
 }
コード例 #3
0
ファイル: Swing4.java プロジェクト: mc5827/Java-Programs
	public void actionPerformed(ActionEvent e)
	{
		if(e.getSource()==b)
		{
			temp=tf.getText();
			temp1[]=ta.getText().split();
			index=0;
			index=temp1[].indexOf(temp,index);
			ta.select(index, index+temp.length());
			b.setVisible(false);
			b1.setVisible(true);
		}
		if(e.getSource()==b1)
		{
			index=temp1.indexOf(temp,index+temp.length());
			if(index!=-1)
			{
				ta.requestFocusInWindow();
				ta.select(index, index+temp.length());
			}
			else
			{
				b.setVisible(true);
				b1.setVisible(false);
				index=0;
			}
		}
	}	
コード例 #4
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == jb1) {
     try {
       strategyFrame =
           new StrategyFrame(
               trainingTeaBLService.showFrameStrategy(), trainingTeaBLService, jb1.getText());
       strategyFrame.setTrainingTeaWindow(this.trainingTeaWindow);
     } catch (RemoteException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
     }
   } else if (e.getSource() == jb2) {
     try {
       strategyFrame =
           new StrategyFrame(
               trainingTeaBLService.showFrameStrategy(), trainingTeaBLService, jb2.getText());
       strategyFrame.setTrainingTeaWindow(this.trainingTeaWindow);
     } catch (RemoteException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
     }
   } else if (e.getSource() == refresh) {
     refresh();
   }
 }
コード例 #5
0
 public void actionPerformed(ActionEvent evt) {
   if (evt.getSource() == ok) dispose();
   else if (evt.getSource() == pluginMgr) {
     new org.gjt.sp.jedit.pluginmgr.PluginManager(
         JOptionPane.getFrameForComponent(ErrorListDialog.this));
   }
 }
コード例 #6
0
ファイル: ActionEventTest.java プロジェクト: pukim/sist
 // 이벤트 발생시 동작되는 메소드
 public void actionPerformed(ActionEvent ae) {
   if (ae.getSource() == but1) {
     tf.setText(" 버튼-1이 눌렸어요");
   } else if (ae.getSource() == but2) {
     tf.setText(" 버튼-2이 눌렸어요");
   }
 }
コード例 #7
0
ファイル: tom_SameJava.java プロジェクト: cstrahan/aduni
 public void actionPerformed(ActionEvent ev) {
   if (ev.getSource() == newg) {
     dialog.hide();
     resetBoard();
   }
   if (ev.getSource() == quitg) System.exit(0);
 }
コード例 #8
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == ctl) {
     this.menu();
   } else if (e.getSource() == exit) {
     exitPerform();
   } else if (e.getSource() == rank) {
     if (count != 0) {
       card.show(mainPanel, "four");
       rankPanel.setMemory(memory, count - 1);
       buttonPanel.removeAll();
       buttonPanel.setBounds(width - 200, height - 80, 190, 50);
       buttonPanel.add(exit);
       check = 4;
       count--;
     }
   } else if (e.getSource() == back) {
     if (secondPanel.clip != null) {
       secondPanel.clip.stop();
       System.out.printf("test");
     }
     check = 0;
     card.previous(mainPanel);
     buttonPanel.removeAll();
     ctl.setText("- Play -");
     buttonPanel.add(ctl);
     buttonPanel.add(rank);
     buttonPanel.add(exit);
     buttonPanel.setOpaque(false);
     buttonPanel.setBounds(width / 2 - 50, height / 2 - 50, 80, 100);
   }
 }
コード例 #9
0
 @Test
 public void testBodyGetterSetter() {
   byte[] mockByteArray = "unit-test-testGetBody".getBytes(Charset.defaultCharset());
   actionEvent.setBody(mockByteArray);
   Assert.assertEquals(
       actionEvent.getBody(), mockByteArray, "The value of body should be set in the object");
 }
コード例 #10
0
 @Override
 public void interceptException(AnnotatedElement element, EventVO event) {
   Method method = (Method) element;
   ActionEvent actionEvent = method.getAnnotation(ActionEvent.class);
   if (actionEvent != null) {
     UserContext ctx = UserContext.current();
     long userId = ctx.getCallerUserId();
     long accountId = ctx.getAccountId();
     long startEventId = ctx.getStartEventId();
     String eventDescription = actionEvent.eventDescription();
     if (ctx.getEventDetails() != null) {
       eventDescription += ". " + ctx.getEventDetails();
     }
     if (actionEvent.create()) {
       long eventId =
           EventUtils.saveCreatedEvent(
               userId,
               accountId,
               EventVO.LEVEL_ERROR,
               actionEvent.eventType(),
               "Error while creating entity for " + eventDescription);
       ctx.setStartEventId(eventId);
     } else {
       EventUtils.saveEvent(
           userId,
           accountId,
           EventVO.LEVEL_ERROR,
           actionEvent.eventType(),
           "Error while " + eventDescription,
           startEventId);
     }
   }
 }
コード例 #11
0
 @Override
 public void interceptComplete(AnnotatedElement element, EventVO event) {
   Method method = (Method) element;
   ActionEvent actionEvent = method.getAnnotation(ActionEvent.class);
   if (actionEvent != null) {
     UserContext ctx = UserContext.current();
     long userId = ctx.getCallerUserId();
     long accountId = ctx.getAccountId();
     long startEventId = ctx.getStartEventId();
     String eventDescription = actionEvent.eventDescription();
     if (ctx.getEventDetails() != null) {
       eventDescription += ". " + ctx.getEventDetails();
     }
     if (actionEvent.create()) {
       // This start event has to be used for subsequent events of this action
       startEventId =
           EventUtils.saveCreatedEvent(
               userId,
               accountId,
               EventVO.LEVEL_INFO,
               actionEvent.eventType(),
               "Successfully created entity for " + eventDescription);
       ctx.setStartEventId(startEventId);
     } else {
       EventUtils.saveEvent(
           userId,
           accountId,
           EventVO.LEVEL_INFO,
           actionEvent.eventType(),
           "Successfully completed " + eventDescription,
           startEventId);
     }
   }
 }
コード例 #12
0
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == m_findBt) {
      if (m_field.equals("employee")) {
        find();

      } else if (m_PayrollPaychequeSubmitPanel != null) {
        PayrollPaychequeSubmitPanel();
      } else if (m_PayrollMealAllowanceSubmitPanel != null) {
        PayrollMealAllowanceSubmitPanel();
      } else if (m_PayrollOvertimeSubmitPanel != null) {
        PayrollOvertimeSubmitPanel();
      } else if (m_PayrollTransportationAllowanceSubmitPanel != null) {
        PayrollTransportationAllowanceSubmitPanel();
      } else if (m_RptFieldAllowances != null) {
        RptFieldAllowances();
      } else if (m_RptPersonalUtilization != null) {
        RptPersonalUtilization();
      } else if (m_PayrollInsuranceAllowanceSubmitPanel != null) {
        PayrollInsuranceAllowanceSubmitPanel();
      } else if (m_PayrollOtherAllowanceSubmitPanel != null) {
        PayrollOtherAllowanceSubmitPanel();
      } else if (m_PayrollTaxArt21SubmitPanel != null) {
        PayrollTaxArt21SubmitPanel();
      } else if (m_PayrollTaxArt21VerificationPanel != null) {
        PayrollTaxArt21VerificationPanel();
      } else if (m_payrollPaychequeVerificationPanel != null) {
        PayrollPaychequesVerivicationPanel();
      }
    } else if (e.getSource() == m_closeBt) {
      if (m_panel != null) m_panel.m_show = false;
      dispose();
    } else if (e.getSource() == m_clearBt) {
      m_table.clear();
    }
  }
コード例 #13
0
  public void actionPerformed(ActionEvent e) {

    if (e.getSource() == creer) {

      this.setVisible(false);
      JFrame fenetremilieu = new FenetreMilieu(this);
      fenetremilieu.setVisible(true);
      fenetremilieu.setLocation(500, 500);
    }

    if (e.getSource() == quitter) {

      this.dispose();
    }

    if (e.getSource() == options) {

      String message = "Choisissez le port";
      numport = Integer.parseInt(JOptionPane.showInputDialog(this, message));

      // JFrame fenetreoptions = new FenetreOptions();
      // fenetreoptions.setVisible(true);

    }
  }
コード例 #14
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == timer) {
     if (finishedFalling) {
       finishedFalling = false;
       makeNewPiece();
     } else {
       dropOneLine();
     }
   }
   if (e.getSource() == timer1 && state.time > 0 && state != null) {
     connection.send("time");
     if (state.time <= 1) {
       paused = true;
     }
     repaint();
   }
   if (e.getSource() == timer2) {
     if (state != null && startDone == false) {
       paused = false;
       start();
       startDone = true;
     }
     if (state != null && state.needToAdd1 && myID == state.player1) addLine(state.addLines1);
     else if (state != null && state.needToAdd2 && myID == state.player2)
       addLine(state.addLines2);
   }
 }
コード例 #15
0
ファイル: ImageJ.java プロジェクト: chrisp87/ImageJA
 /** Handle menu events. */
 public void actionPerformed(ActionEvent e) {
   if ((e.getSource() instanceof MenuItem)) {
     MenuItem item = (MenuItem) e.getSource();
     String cmd = e.getActionCommand();
     commandName = cmd;
     ImagePlus imp = null;
     if (item.getParent() == Menus.getOpenRecentMenu()) {
       new RecentOpener(cmd); // open image in separate thread
       return;
     } else if (item.getParent() == Menus.getPopupMenu()) {
       Object parent = Menus.getPopupMenu().getParent();
       if (parent instanceof ImageCanvas) imp = ((ImageCanvas) parent).getImage();
     }
     int flags = e.getModifiers();
     hotkey = false;
     actionPerformedTime = System.currentTimeMillis();
     long ellapsedTime = actionPerformedTime - keyPressedTime;
     if (cmd != null && (ellapsedTime >= 200L || !cmd.equals(lastKeyCommand))) {
       if ((flags & Event.ALT_MASK) != 0) IJ.setKeyDown(KeyEvent.VK_ALT);
       if ((flags & Event.SHIFT_MASK) != 0) IJ.setKeyDown(KeyEvent.VK_SHIFT);
       new Executer(cmd, imp);
     }
     lastKeyCommand = null;
     if (IJ.debugMode) IJ.log("actionPerformed: time=" + ellapsedTime + ", " + e);
   }
 }
コード例 #16
0
 @Test
 public void testStatusGetterSetter() {
   actionEvent.setStatus(Status.BACKOFF);
   Assert.assertEquals(actionEvent.getStatus(), Status.BACKOFF);
   actionEvent.setStatus(Status.READY);
   Assert.assertEquals(actionEvent.getStatus(), Status.READY);
 }
コード例 #17
0
  public void actionPerformed(ActionEvent ae) {
    if (ae.getSource() == b1) {
      try {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        Connection con =
            DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "system", "123");
        PreparedStatement ps =
            con.prepareStatement("select * from LoginForm where username=? and password=?");
        String UserName = t1.getText();
        String Password = jp1.getText();
        ps.setString(1, UserName);
        ps.setString(2, Password);
        ResultSet rs = ps.executeQuery();
        boolean flag = rs.next();
        if (flag) {
          new Main();
          f.setVisible(false);
        } else {
          JOptionPane.showMessageDialog(null, "Please Enter valid Name And Password");
        }

      } catch (Exception e) {
        System.out.println("Error:" + e);
      }
    } else if (ae.getSource() == b2) {
      t1.setText("");
      jp1.setText("");
    } else if (ae.getSource() == b3) {

      f.setVisible(false);
    }
  }
コード例 #18
0
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() instanceof TextField) {
      TextField tf = (TextField) e.getSource();
      String text = tf.getText();
      String fields[] = FILE.split(text, " ,");
      int r = 0;
      int g = 0;
      int b = 0;
      if (fields.length == 3) {
        // assumed decimal rgb values
        r = FILE.readInteger(fields[0]);
        g = FILE.readInteger(fields[1]);
        b = FILE.readInteger(fields[2]);
      } else if (fields.length == 1) {
        // assume 6 digit hex code
        int crgb = Color32.getColorFromName(fields[0]);
        r = (crgb & 0xff0000) >> 16;
        g = (crgb & 0xff00) >> 8;
        b = (crgb & 0xff);
      } else {
        Log.error("illegal colour format");
        Log.error("should be 0xabcdef or 255 0 255 or colorname");
        return;
      }

      Color c = new Color(r, g, b);

      updateColor(c, e.getSource());
    }
  }
コード例 #19
0
ファイル: jisuanqi.java プロジェクト: leijunye/calculator
 public void actionPerformed(ActionEvent e) {
   Object target = e.getSource();
   String label = e.getActionCommand();
   if (target == reset) handleReset();
   else if ("0123456789.".indexOf(label) > 0) handleNumber(label);
   else handleOperator(label);
 }
コード例 #20
0
ファイル: GUI.java プロジェクト: jhosler0793/Multiuser-Chat
 public void actionPerformed(ActionEvent event) {
   if (event.getSource() == joinButton) {
     if (joinButton.isSelected()) {
       mThread =
           new MulticastThread(
               Integer.valueOf(portField.getText()), chatIPField.getText(), chatroomArea, true);
       (new Thread(mThread)).start();
     }
   }
   if (event.getSource() == sendButton) {
     mThread.send(usernameField.getText(), chatMsgField.getText());
     chatMsgField.setText("");
   }
   if (event.getSource() == leaveButton) {
     try {
       joinButton.setSelected(false);
       mThread.leave();
       System.out.println("Disconnected from chat ");
     } catch (Exception e) {
     }
   }
   if (event.getSource() == exitButton) {
     System.exit(0);
   }
 }
コード例 #21
0
  @Override
  public void actionPerformed(ActionEvent e) {

    if (e.getSource() == salir) {
      JOptionPane.showMessageDialog(null, "Pantalla de Marlon");
    }

    if (e.getSource() == opc1) {
      JOptionPane.showMessageDialog(null, "Respuesta Incorrecta");
      Pregunta14 avance = new Pregunta14(s);
      dispose();
    }

    if (e.getSource() == opc2) {
      score = s + 10;
      JOptionPane.showMessageDialog(null, "Respuesta Correcta :0 ");
      Pregunta14 avance = new Pregunta14(score);
      dispose();
    }

    if (e.getSource() == opc3) {
      JOptionPane.showMessageDialog(null, "Respuesta Incorrecta");
      Pregunta14 avance = new Pregunta14(s);
      dispose();
    }

    if (e.getSource() == opc4) {
      JOptionPane.showMessageDialog(null, "Respuesta Incorrecta");
      Pregunta14 avance = new Pregunta14(s);
      dispose();
    }
  }
コード例 #22
0
ファイル: Main.java プロジェクト: pruebazzz/prueba111
  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("Load Graph")) {
      Explorer explorer = new Explorer();
      String path = explorer.showDialog(this);
      System.out.println("DEBUG: The graph selected is: " + path);
      if (!(path.equals(""))) {
        Vector graphNodes = utils.parseFile(path);
        algorithm_View.setGraphNodes(graphNodes);
        drawer.paintGraph(graphNodes);
        for (int i = 0; i < graphNodes.size(); i++) {
          System.out.print("Service " + (i + 1) + ":    ");
          Vector si = (Vector) graphNodes.elementAt(i);
          for (int j = 0; j < si.size(); j++) {
            String siValue =
                ((ServiceImplementation) si.elementAt(j)).getId()
                    + "-"
                    + ((ServiceImplementation) si.elementAt(j)).getSid();
            System.out.print(siValue);
            System.out.print("    ");
          }
          System.out.println();
        }
        algorithm_View.setGraphPanel(drawer.getGComponent());
      }
    }
    if (e.getActionCommand().equals("Reset View")) {}

    if (e.getActionCommand().equals("About...")) {
      JOptionPane.showMessageDialog(
          frame, "Version v0.2\nPatricia Uriol\nFelipe Ibañez\nDREQUIEM\nUC3M");
    }
    if (e.getActionCommand().equals("Manual")) {
      JOptionPane.showMessageDialog(frame, helpManual);
    }
  }
コード例 #23
0
ファイル: JPicDialog.java プロジェクト: esprayer/EMPPlatform
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == bOk) {
     onOKAction();
   } else if (e.getSource() == bExit) {
     onExitAction();
   }
 }
コード例 #24
0
 public void actionPerformed(ActionEvent evt) {
   if (evt.getSource() == clearButton) {
     textArea.setText("");
   } else if (evt.getSource() == closeButton) {
     setVisible(false);
   }
 }
コード例 #25
0
  public void actionPerformed(ActionEvent e) {

    // Handle open button action.
    if (e.getSource() == openButton) {
      int returnVal = fc.showOpenDialog(FileChooserDemo.this);

      if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        // This is where a real application would open the file.
        log.append("Opening: " + file.getName() + "." + newline);
      } else {
        log.append("Open command cancelled by user." + newline);
      }
      log.setCaretPosition(log.getDocument().getLength());

      // Handle save button action.
    } else if (e.getSource() == saveButton) {
      int returnVal = fc.showSaveDialog(FileChooserDemo.this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        // This is where a real application would save the file.
        log.append("Saving: " + file.getName() + "." + newline);
      } else {
        log.append("Save command cancelled by user." + newline);
      }
      log.setCaretPosition(log.getDocument().getLength());
    }
  }
コード例 #26
0
  /**
   * Closes dialog box when the OK button is pressed and calls the algorithm.
   *
   * @param event Event that triggers function.
   */
  public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    Object source = event.getSource();

    if (command.equals("OK")) {

      if (setVariables()) {
        callAlgorithm();
      }
    } else if (command.equals("Script")) {
      callAlgorithm();
    } else if (command.equals("Cancel")) {
      dispose();
    } else if (source == blueSmoothBox) {
      if (blueSmoothBox.isSelected()) {
        interpolationLabel.setEnabled(true);
        interpolationText.setEnabled(true);
      } else {
        interpolationLabel.setEnabled(false);
        interpolationText.setEnabled(false);
      }
    } else {
      super.actionPerformed(event);
    }
  }
コード例 #27
0
  /**
   * Closes dialog box when the OK button is pressed, sets variables and calls algorithm.
   *
   * @param event Event that triggers function.
   */
  public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    Object source = event.getSource();

    if (command.equals("OK")) {

      if (setVariables()) {
        callAlgorithm();
      }
    } else if (command.equals("Cancel")) {
      dispose();
    } else if (command.equals("Help")) {
      // MipavUtil.showHelp("");
    } else if (source.equals(doRicianCheckBox)) {
      if (doRicianCheckBox.isSelected()) {
        labelDegree.setEnabled(true);
        textDegree.setEnabled(true);
      } else {
        labelDegree.setEnabled(false);
        textDegree.setEnabled(false);
      }
    } else { // else if (source == thresholdCheckbox)
      super.actionPerformed(event);
    }
  }
コード例 #28
0
ファイル: ControlPanel.java プロジェクト: johnperry/Geneva2
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() instanceof JMenuItem) {
     JMenuItem item = (JMenuItem) e.getSource();
     String name = item.getText();
     profiles.delete(name);
   }
 }
コード例 #29
0
 public void actionPerformed(ActionEvent event) {
   if (event.getSource() == bstart) {
     selectframe.setVisible(false);
     for (int i = 0; i < typeButtons.length; i++)
       if (typeButtons[i].isSelected()) {
         new Thread(this).start();
         return;
       }
   } else if (event.getSource() == bcancel) selectframe.setVisible(false);
   else if (event.getSource() == bopen) {
     int row = table.getSelectedRow();
     if (row != -1) {
       ResourceEntry resourceEntry = (ResourceEntry) table.getValueAt(row, 0);
       NearInfinity.getInstance().showResourceEntry(resourceEntry);
       ((AbstractStruct) NearInfinity.getInstance().getViewable())
           .getViewer()
           .selectEntry(((Item) table.getValueAt(row, 2)).getName());
     }
   } else if (event.getSource() == bopennew) {
     int row = table.getSelectedRow();
     if (row != -1) {
       ResourceEntry resourceEntry = (ResourceEntry) table.getValueAt(row, 0);
       Resource resource = ResourceFactory.getResource(resourceEntry);
       new ViewFrame(resultFrame, resource);
       ((AbstractStruct) resource)
           .getViewer()
           .selectEntry(((Item) table.getValueAt(row, 2)).getName());
     }
   }
 }
コード例 #30
0
ファイル: DocumentEditGUI.java プロジェクト: elmerlu/FileEdit
 @Override
 public void actionPerformed(ActionEvent e) {
   if (td.getTabCount() > 0) {
     TextDocument ta = (TextDocument) td.getComponentAt(td.getSelectedIndex());
     Pattern pn = Pattern.compile(tf1.getText());
     Matcher mt = pn.matcher(ta.getText());
     if (e.getSource() == jb2) { // 取代
       ta.setText(mt.replaceAll(tf2.getText()));
     } else if (e.getSource() == jb1) { // 尋找
       Highlighter hl = ta.getHighlighter();
       hl.removeAllHighlights();
       while (mt.find()) {
         try {
           hl.addHighlight(
               mt.start(), mt.end(), new DefaultHighlighter.DefaultHighlightPainter(null));
         } catch (Exception ex) {
         }
       } // 開啟及關閉介面
     } else if (e.getSource() == replace_searchMenuItem) {
       System.out.println("Replace/Search is show:" + !show);
       if (show) {
         getContentPane().remove(jp);
         show = false;
       } else {
         getContentPane().add(jp, BorderLayout.SOUTH);
         show = true;
       }
       validate(); // 刷新容器
     }
   } else if (e.getSource() == replace_searchMenuItem) {
     JOptionPane.showMessageDialog(
         null, "尚無檔案,無法使用!", "Repace/Search error", JOptionPane.ERROR_MESSAGE);
   }
 }