List of usage examples for java.awt.event ActionEvent getSource
public Object getSource()
From source file:graphics.MainWindow.java
public void actionPerformed(ActionEvent arg0) { if (arg0.getSource() == this.buttonDifusion[0]) { this.DifusionRates(0, "Cell 1"); }//from w w w . j a v a 2 s . c o m if (arg0.getSource() == this.buttonDifusion[1]) { this.DifusionRates(1, "Cell 2"); } if (arg0.getSource() == this.buttonDifusion[2]) { this.DifusionRates(2, "Cell 3"); } if (arg0.getSource() == this.buttonDifusion[3]) { this.DifusionRates(3, "Cell 4"); } if (arg0.getSource() == this.buttonDifusion[4]) { this.DifusionRates(4, "Cell 5"); } if (arg0.getSource() == this.buttonDifusion[5]) { this.DifusionRates(5, "Cell 6"); } if (arg0.getSource() == this.buttonDifusion[6]) { this.DifusionRates(6, "Cell 7"); } if (arg0.getSource() == this.buttonDifusion[7]) { this.DifusionRates(7, "Cell 8"); } if (arg0.getSource() == this.buttonDifusion[8]) { this.DifusionRates(8, "Cell 9"); } if (arg0.getSource() == this.buttonDifusion[9]) { this.DifusionRates(9, "Cell 10"); } if (arg0.getSource() == this.buttonDifusion[10]) { this.DifusionRates(10, "Cell 11"); } if (arg0.getSource() == this.buttonDifusion[11]) { this.DifusionRates(11, "Cell 12"); } if (arg0.getSource() == this.buttonDifusion[12]) { this.DifusionRates(12, "Cell 13"); } if (arg0.getSource() == this.buttonDifusion[13]) { this.DifusionRates(13, "Cell 14"); } if (arg0.getSource() == this.buttonDifusion[14]) { this.DifusionRates(14, "Cell 15"); } if (arg0.getSource() == this.buttonDifusion[15]) { this.DifusionRates(15, "Cell 1"); } }
From source file:com.game.ui.views.CharacterEditor.java
@Override public void actionPerformed(ActionEvent ae) { if (ae.getActionCommand().equalsIgnoreCase("dropDown")) { JComboBox cbox = (JComboBox) ae.getSource(); String nameTxt = cbox.getSelectedItem().toString(); character = charMap.get(nameTxt); name.setText(nameTxt);/*w ww . ja v a 2 s. co m*/ imgPath.setText(character.getImagePath()); hitPoints.setText("" + character.getHealth()); level.setText("" + character.getLevel()); Inventory inv = character.getInventory(); if (inv != null) { Weapon dummy = inv.getEquippedWeapon(); if (dummy != null) { meleeWeapon.setSelectedItem(dummy.getName()); } for (Item item : inv.getItems()) { if (item instanceof Weapon) { Weapon wpn = (Weapon) item; if (wpn.getWeaponType().equalsIgnoreCase(Configuration.weaponTypes[1])) { { rangedWeapon.setSelectedItem(wpn.getName()); break; } } } } Armour chest = inv.getChest(); Armour shld = inv.getShield(); if (chest != null) { armour.setSelectedItem(chest.getName()); } if (shld != null) { shield.setSelectedItem(shld.getName()); } } ta.setText(""); ta.append("Strength : " + character.getStrength()); ta.append("\nDexterity : " + character.getDexterity()); ta.append("\nConstitution : " + character.getConstitution()); ta.append("\nIntelligence : " + character.getIntelligence()); ta.append("\nCharisma: " + character.getCharisma()); ta.append("\nWisdom : " + character.getWisdom()); ta.append("\nType :" + character.getType()); ta.append("\nStrength Modifier :" + character.getStrengthModifier()); ta.append("\nConstitution Modifier :" + character.getConstitutionModifier()); ta.append("\nDexterity Modifier :" + character.getDexterityModifier()); validationMess.setText(""); // validationMess.setvi builder = new CharacterBuilder(character); generated = true; this.revalidate(); } else { String nameTxt = name.getText(); String img = imgPath.getText(); String lvl = level.getText(); String melWpn = meleeWeapon.getSelectedItem().toString(); String health = hitPoints.getText(); String rngdWpn = rangedWeapon.getSelectedItem().toString(); String armr = armour.getSelectedItem().toString(); String shld = shield.getSelectedItem().toString(); if (StringUtils.isNotBlank(nameTxt) && StringUtils.isNotBlank(img) && StringUtils.isNotBlank(lvl) && StringUtils.isNotBlank(melWpn) && StringUtils.isNotBlank(rngdWpn) && StringUtils.isNotBlank(armr) && StringUtils.isNotBlank(shld) && StringUtils.isNotBlank(health)) { if (generated) { if (isEnemy) { persistEnemyWrapper(nameTxt, img, lvl, melWpn, rngdWpn, armr, shld, health); } else { persistPlayerWrapper(nameTxt, img, lvl, melWpn, rngdWpn, armr, shld, health); } } else { validationMess.setText("Pls hit generate button before you submit.."); } } else { validationMess.setText("All the fields are mandatory.."); } validationMess.setVisible(true); this.revalidate(); } }
From source file:com.ssn.event.controller.SSNUntaggedMediaController.java
@Override public void actionPerformed(ActionEvent e) { Object actionEventObj = e.getSource(); if (actionEventObj != null && actionEventObj instanceof JButton) { JButton button = (JButton) actionEventObj; String actionCommand = button.getActionCommand(); if (actionCommand != null && actionCommand.equals("Cancel")) { SSNHomeController.isUnTaggedOpen = false; untaggedMediaForm.dispose(); }/*from www. j a v a2s . c o m*/ } }
From source file:edu.ku.brc.specify.datamodel.busrules.AgentBusRules.java
@Override public void initialize(Viewable viewableArg) { super.initialize(viewableArg); if (formViewObj != null) { typeComp = formViewObj.getCompById("0"); lastLabel = formViewObj.getLabelFor("3"); lastNameText = formViewObj.getCompById("3"); if (typeComp instanceof ValComboBox) { ValComboBox typeCBX = ((ValComboBox) typeComp); typeCBX.getComboBox().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!ignoreSet) { fixUpTypeCBX((JComboBox<?>) e.getSource()); }/*from w w w. j a v a2 s .c o m*/ } }); // Fill Type CBX with localized strings if (typeCBX.getComboBox().getModel().getSize() == 0) { for (String t : typeTitles) { typeCBX.getComboBox().addItem(t); } } } } }
From source file:gui.DownloadPanel.java
@Override public void actionPerformed(ActionEvent e) { JMenuItem clicked = (JMenuItem) e.getSource(); if (clicked == openItem) { actionOpenFile();// w w w . j a v a 2 s. c o m } else if (clicked == openFolderItem) { actionOpenFolder(); } else if (clicked == resumeItem) { actionResume(); // todo may need mainToolbar.setStateOfButtonsControl(false, false, false); // canceled } else if (clicked == pauseItem) { actionPause(); } else if (clicked == clearItem) { actionClear(); } else if (clicked == reJoinItem) { actionReJoinFileParts(); } else if (clicked == reDownloadItem) { actionReDownload(); } else if (clicked == moveToQueueItem) { // mainToolbarListener.preferencesEventOccured(); } else if (clicked == removeFromQueueItem) { // mainToolbarListener.preferencesEventOccured(); } else if (clicked == propertiesItem) { actionProperties(); } }
From source file:de.juwimm.cms.Main.java
private void showToolPanel(boolean withSelection, ActionEvent e) throws Exception { if (Constants.CMS_CLIENT_VIEW != Constants.CLIENT_VIEW_CONTENT) { panRibbon.setView(true);/* ww w .j a v a2 s . c om*/ try { panTool = PanTool.getInstance(); panTool.reload(withSelection, e.getSource()); } catch (UserHasNoUnitsException ex) { JOptionPane.showMessageDialog(UIConstants.getMainFrame(), ex.getMessage(), rb.getString("msgbox.title.loginFailed"), JOptionPane.ERROR_MESSAGE); ActionHub.fireActionPerformed( new ActionEvent(this, ActionEvent.ACTION_PERFORMED, Constants.ACTION_LOGOFF)); return; } catch (NullPointerException npe) { panTool.setTreeToEmpty(); JOptionPane.showMessageDialog(UIConstants.getMainFrame(), rb.getString("exception.SiteIsEmpty"), rb.getString("dialog.title"), JOptionPane.ERROR_MESSAGE); } setCenterPanel(panTool); } }
From source file:com.windows.MainJFrame.java
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton1ActionPerformed // TODO add your handling code here: JRadioButton temp = (JRadioButton) evt.getSource(); if (temp.isSelected()) { scanDirection = temp.getText();// w ww . j a v a2 s . com } }
From source file:com.windows.MainJFrame.java
private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton2ActionPerformed // TODO add your handling code here: JRadioButton temp = (JRadioButton) evt.getSource(); if (temp.isSelected()) { scanDirection = temp.getText();/*from w w w .j av a2 s. co m*/ } }
From source file:e3fraud.gui.MainWindow.java
public void actionPerformed(ActionEvent e) { //Handle open button action. if (e.getSource() == openButton) { int returnVal = fc.showOpenDialog(MainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); //parse file this.baseModel = FileParser.parseFile(file); log.append(currentTime.currentTime() + " Opened: " + file.getName() + "." + newline); } else {//w w w . ja v a 2 s. c o m log.append(currentTime.currentTime() + " Open command cancelled by user." + newline); } log.setCaretPosition(log.getDocument().getLength()); //handle Generate button } else if (e.getSource() == generateButton) { if (this.baseModel != null) { //have the user indicate the ToA via pop-up JFrame frame1 = new JFrame("Select Target of Assessment"); Map<String, Resource> actorsMap = this.baseModel.getActorsMap(); String selectedActorString = (String) JOptionPane.showInputDialog(frame1, "Which actor's perspective are you taking?", "Choose main actor", JOptionPane.QUESTION_MESSAGE, null, actorsMap.keySet().toArray(), actorsMap.keySet().toArray()[0]); if (selectedActorString == null) { log.append(currentTime.currentTime() + " Attack generation cancelled!" + newline); } else { lastSelectedActorString = selectedActorString; //have the user select a need via pop-up JFrame frame2 = new JFrame("Select graph parameter"); Map<String, Resource> needsMap = this.baseModel.getNeedsMap(); String selectedNeedString = (String) JOptionPane.showInputDialog(frame2, "What do you want to use as parameter?", "Choose need to parametrize", JOptionPane.QUESTION_MESSAGE, null, needsMap.keySet().toArray(), needsMap.keySet().toArray()[0]); if (selectedNeedString == null) { log.append("Attack generation cancelled!" + newline); } else { lastSelectedNeedString = selectedNeedString; //have the user select occurence interval via pop-up JTextField xField = new JTextField("1", 4); JTextField yField = new JTextField("500", 4); JPanel myPanel = new JPanel(); myPanel.add(new JLabel("Mininum occurences:")); myPanel.add(xField); myPanel.add(Box.createHorizontalStrut(15)); // a spacer myPanel.add(new JLabel("Maximum occurences:")); myPanel.add(yField); int result = JOptionPane.showConfirmDialog(null, myPanel, "Please Enter occurence rate interval", JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.CANCEL_OPTION) { log.append("Attack generation cancelled!" + newline); } else if (result == JOptionPane.OK_OPTION) { startValue = Integer.parseInt(xField.getText()); endValue = Integer.parseInt(yField.getText()); selectedNeed = needsMap.get(selectedNeedString); selectedActor = actorsMap.get(selectedActorString); //Have a Worker thread to the time-consuming generation and raking (to not freeze the GUI) GenerationWorker generationWorker = new GenerationWorker(baseModel, selectedActorString, selectedActor, selectedNeed, selectedNeedString, startValue, endValue, log, lossButton, gainButton, lossGainButton, gainLossButton, groupingButton, collusionsButton) { //make it so that when Worker is done @Override protected void done() { try { progressBar.setVisible(false); System.err.println("I made it invisible"); //the Worker's result is retrieved treeModel.setRoot(get()); tree.setModel(treeModel); tree.updateUI(); tree.collapseRow(1); //tree.expandRow(0); tree.setRootVisible(false); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } catch (InterruptedException | ExecutionException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); log.append("Out of memory; please increase heap size of JVM"); PopUps.infoBox( "Encountered an error. Most likely out of memory; try increasing the heap size of JVM", "Error"); } } }; this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); progressBar.setVisible(true); progressBar.setIndeterminate(true); progressBar.setString("generating..."); generationWorker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("phase".equals(evt.getPropertyName())) { progressBar.setMaximum(100); progressBar.setIndeterminate(false); progressBar.setString("ranking..."); } else if ("progress".equals(evt.getPropertyName())) { progressBar.setValue((Integer) evt.getNewValue()); } } }); generationWorker.execute(); } } } } else { log.append("Load a model file first!" + newline); } } //handle the refresh button else if (e.getSource() == refreshButton) { if (lastSelectedNeedString != null && lastSelectedActorString != null) { Map<String, Resource> actorsMap = this.baseModel.getActorsMap(); Map<String, Resource> needsMap = this.baseModel.getNeedsMap(); selectedNeed = needsMap.get(lastSelectedNeedString); selectedActor = actorsMap.get(lastSelectedActorString); //Have a Worker thread to the time-consuming generation and raking (to not freeze the GUI) GenerationWorker generationWorker = new GenerationWorker(baseModel, lastSelectedActorString, selectedActor, selectedNeed, lastSelectedNeedString, startValue, endValue, log, lossButton, gainButton, lossGainButton, gainLossButton, groupingButton, collusionsButton) { //make it so that when Worker is done @Override protected void done() { try { progressBar.setVisible(false); //the Worker's result is retrieved treeModel.setRoot(get()); tree.setModel(treeModel); tree.updateUI(); tree.collapseRow(1); //tree.expandRow(0); tree.setRootVisible(false); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } catch (InterruptedException | ExecutionException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); log.append("Most likely out of memory; please increase heap size of JVM"); PopUps.infoBox( "Encountered an error. Most likely out of memory; try increasing the heap size of JVM", "Error"); } } }; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); progressBar.setVisible(true); progressBar.setIndeterminate(true); progressBar.setString("generating..."); generationWorker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("phase".equals(evt.getPropertyName())) { progressBar.setMaximum(100); progressBar.setIndeterminate(false); progressBar.setString("ranking..."); } else if ("progress".equals(evt.getPropertyName())) { progressBar.setValue((Integer) evt.getNewValue()); } } }); generationWorker.execute(); } else { log.append(currentTime.currentTime() + " Nothing to refresh. Generate models first" + newline); } } //handle show ideal graph button else if (e.getSource() == idealGraphButton) { if (this.baseModel != null) { graph1 = GraphingTool.generateGraph(baseModel, selectedNeed, startValue, endValue, true);//expected graph ChartFrame chartframe1 = new ChartFrame("Ideal results", graph1); chartframe1.setPreferredSize(new Dimension(CHART_WIDTH, CHART_HEIGHT)); chartframe1.pack(); chartframe1.setLocationByPlatform(true); chartframe1.setVisible(true); } else { log.append(currentTime.currentTime() + " Load a model file first!" + newline); } } //Handle the graph extend button//Handle the graph extend button else if (e.getSource() == expandButton) { //make sure there is a graph to show if (graph2 == null) { log.append(currentTime.currentTime() + " No graph to display. Select one first." + newline); } else { //this makes sure both graphs have the same y axis: // double lowerBound = min(graph1.getXYPlot().getRangeAxis().getRange().getLowerBound(), graph2.getXYPlot().getRangeAxis().getRange().getLowerBound()); // double upperBound = max(graph1.getXYPlot().getRangeAxis().getRange().getUpperBound(), graph2.getXYPlot().getRangeAxis().getRange().getUpperBound()); // graph1.getXYPlot().getRangeAxis().setRange(lowerBound, upperBound); // graph2.getXYPlot().getRangeAxis().setRange(lowerBound, upperBound); chartPane.removeAll(); chartPanel = new ChartPanel(graph2); chartPanel.setPreferredSize(new Dimension(CHART_WIDTH, CHART_HEIGHT)); chartPane.add(chartPanel); chartPane.add(collapseButton); extended = true; this.setPreferredSize(new Dimension(this.getWidth() + CHART_WIDTH, this.getHeight())); JFrame frame = (JFrame) getRootPane().getParent(); frame.pack(); } } //Handle the graph collapse button//Handle the graph collapse button else if (e.getSource() == collapseButton) { System.out.println("resizing by -" + CHART_WIDTH); chartPane.removeAll(); chartPane.add(expandButton); this.setPreferredSize(new Dimension(this.getWidth() - CHART_WIDTH, this.getHeight())); chartPane.repaint(); chartPane.revalidate(); extended = false; JFrame frame = (JFrame) getRootPane().getParent(); frame.pack(); } }
From source file:com.mirth.connect.connectors.tcp.TcpListener.java
@Override public void actionPerformed(ActionEvent evt) { if (evt.getSource().equals(transmissionModeProvider)) { if (evt.getActionCommand().equals(TransmissionModeClientProvider.CHANGE_SAMPLE_LABEL_COMMAND)) { sampleLabel.setText(transmissionModeProvider.getSampleLabel()); } else if (evt.getActionCommand().equals(TransmissionModeClientProvider.CHANGE_SAMPLE_VALUE_COMMAND)) { sampleValue.setText(transmissionModeProvider.getSampleValue()); }/*w w w .java 2s. c o m*/ } }