/** Listener to handle button actions */ public void actionPerformed(ActionEvent e) { // Check if the user changed the service filter option if (e.getSource() == service_box) { service_list.setEnabled(service_box.isSelected()); service_list.clearSelection(); remove_service_button.setEnabled(false); add_service_field.setEnabled(service_box.isSelected()); add_service_field.setText(""); add_service_button.setEnabled(false); } // Check if the user pressed the add service button if ((e.getSource() == add_service_button) || (e.getSource() == add_service_field)) { String text = add_service_field.getText(); if ((text != null) && (text.length() > 0)) { service_data.addElement(text); service_list.setListData(service_data); } add_service_field.setText(""); add_service_field.requestFocus(); } // Check if the user pressed the remove service button if (e.getSource() == remove_service_button) { Object[] sels = service_list.getSelectedValues(); for (int i = 0; i < sels.length; i++) { service_data.removeElement(sels[i]); } service_list.setListData(service_data); service_list.clearSelection(); } }
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(); } }
/** Action listener method that reacts to the checkbox being clicked or button pushed */ public void actionPerformed(ActionEvent e) { if (e.getSource() == stateCB) { if (currentPerson instanceof CustomerAgent) { CustomerAgent c = (CustomerAgent) currentPerson; c.setHungry(hunger); stateCB.setEnabled(false); } } else if (e.getSource() == changeOrder) { if (currentPerson instanceof CustomerAgent) { CustomerAgent c = (CustomerAgent) currentPerson; c.waiter.msgIWantToChangeOrder(c); // changeOrder.setEnabled(false); } } else if (e.getSource() == requestBreak) { if (currentPerson instanceof WaiterAgent) { WaiterAgent w = (WaiterAgent) currentPerson; w.requestBreak(); } } else if (e.getSource() == addTable) { try { System.out.println("[Gautam] Add Table!"); // String XPos = JOptionPane.showInputDialog("Please enter X Position: "); // String YPos = JOptionPane.showInputDialog("Please enter Y Position: "); // String size = JOptionPane.showInputDialog("Please enter Size: "); // restPanel.addTable(10, 5, 1); // restPanel.addTable(Integer.valueOf(YPos).intValue(), Integer.valueOf(XPos).intValue(), // Integer.valueOf(size).intValue()); restPanel.addTable(); } catch (Exception ex) { System.out.println("Unexpected exception caught in during setup:" + ex); } } }
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; } } }
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(); } }
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)); } }
@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(); } }
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); }
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); } }
@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); } }
/** Listener to handle button actions */ public void actionPerformed(ActionEvent e) { // Check if the user pressed the ok button if (e.getSource() == ok_button) { filter_include_list = include_panel.getServiceList(); filter_exclude_list = exclude_panel.getServiceList(); if (status_box.isSelected()) { filter_active = status_active.isSelected(); filter_complete = status_complete.isSelected(); } else { filter_active = false; filter_complete = false; } ok_pressed = true; dialog.dispose(); } // Check if the user pressed the cancel button if (e.getSource() == cancel_button) { dialog.dispose(); } // Check if the user changed the status filter option if (e.getSource() == status_box) { status_active.setEnabled(status_box.isSelected()); status_complete.setEnabled(status_box.isSelected()); } }
public void actionPerformed(ActionEvent ae) { try { if (ae.getSource() == b7) { rs = st.executeQuery("select count(*) from employeemaster"); if (rs.next()) { t6.setText(rs.getString(1)); } rs = st.executeQuery("select * from Head"); if (rs.next()) { t1.setText(rs.getString(1)); t2.setText(rs.getString(2)); t7.setText(rs.getString(3)); t4.setText(rs.getString(4)); t5.setText(rs.getString(5)); t3.setText(rs.getString(6)); } } else if (ae.getSource() == b6) { dispose(); } } catch (Exception e) { JOptionPane.showMessageDialog(this, "Error is" + e); } }
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == add) { // int sel = userTable.getSelectedRow(); // if (sel < 0) // sel = 0; nameTf.setText(""); abbrTf.setText(""); if (JOptionPane.showConfirmDialog( dialog, journalEditPanel, Localization.lang("Edit journal"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { journals.add(new JournalEntry(nameTf.getText(), abbrTf.getText())); // setValueAt(nameTf.getText(), sel, 0); // setValueAt(abbrTf.getText(), sel, 1); Collections.sort(journals); fireTableDataChanged(); } } else if (e.getSource() == remove) { int[] rows = userTable.getSelectedRows(); if (rows.length > 0) { for (int i = rows.length - 1; i >= 0; i--) { journals.remove(rows[i]); } fireTableDataChanged(); } } }
public void actionPerformed(ActionEvent e) { if (e.getSource() == this.jbGenerate) // 生成地圖代碼 { String s = "public static final int[][] MAP=//0 可通過 1 不可通過\n{"; for (int i = 0; i < mdp.row; i++) { s = s + "\n\t{"; for (int j = 0; j < mdp.col; j++) { s = s + mdp.mapData[i][j] + ","; } s = s.substring(0, s.length() - 1) + "},"; } s = s.substring(0, s.length() - 1) + "\n};"; new CodeFrame(s, "3D重力球遊戲地圖"); } else if (e.getSource() == this.jbGenerateD) { // 生成圓孔位置代碼 String s = "public static final int[][] MAP_OBJECT=//表示可遇圓孔位置的矩陣\n{"; for (int i = 0; i < mdp.row; i++) { s = s + "\n\t{"; for (int j = 0; j < mdp.col; j++) { s = s + mdp.diamondMap[i][j] + ","; } s = s.substring(0, s.length() - 1) + "},"; // 去掉最後的逗號 } s = s.substring(0, s.length() - 1) + "\n};"; new CodeFrame(s, "圓孔分佈矩陣"); } }
public void actionPerformed(ActionEvent evt) { if (evt.getSource() != null) { // Commented by Balan on 15/03/03 // TreeNode selectedTreeNode = findNode((DefaultMutableTreeNode)frame.model.getRoot() , (( // (TreeCombo)evt.getSource() ).getSelectedNode()).toString() ); // Comment Ends // Added by Balan on 15/03/03 Object tempObject = ((DefaultMutableTreeNode) ((TreeCombo) evt.getSource()).getSelectedNode()) .getUserObject(); String strMatchNode = "" + ((Hashtable) tempObject).get("TREE-NAME"); TreeNode selectedTreeNode = findNode((DefaultMutableTreeNode) frame.model.getRoot(), strMatchNode); // Add Ends if (selectedTreeNode != null) { fromCombo = true; TreeNode tempNode[] = frame.model.getPathToRoot(selectedTreeNode); frame.JTree1.setSelectionPath(new TreePath(tempNode)); } else { // This case should n't occur } } }
/** * 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); } }
public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JMenuItem) { JMenuItem item = (JMenuItem) e.getSource(); String name = item.getText(); profiles.delete(name); } }
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); } }
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); } }
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); } }
public void actionPerformed(ActionEvent ev) { if (ev.getSource() == newg) { dialog.hide(); resetBoard(); } if (ev.getSource() == quitg) System.exit(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(); } }
public void actionPerformed(ActionEvent e) { if (e.getSource() == bOk) { onOKAction(); } else if (e.getSource() == bExit) { onExitAction(); } }
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); } }
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()); } }
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); } }
/** * 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); } }
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); } }
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()); } } }
public void actionPerformed(ActionEvent e) { if (e.getSource() == enableDefaultEncryption) { loadStates(); } else if (e.getSource() == cmdExpandAdvancedSettings) { pnlAdvancedSettings.setVisible(!pnlAdvancedSettings.isVisible()); } }