List of usage examples for java.awt.event ActionEvent getActionCommand
public String getActionCommand()
From source file:com.egangotri.transliteratorAsSwing.TransliteratorJFrame.java
public void actionPerformed(ActionEvent e) { String actionCommand = e.getActionCommand(); Log.info("actionCommand: " + actionCommand); if (actionCommand.equals("clear")) { clear();// w w w . j a v a 2s . com this.repaint(); } else if (actionCommand.equals("clipboard-1")) { copyToClipBoard("cb1"); } else if (actionCommand.equals("clipboard-2")) { copyToClipBoard("cb2"); } else if (actionCommand.equals("clipboard-3")) { copyToClipBoard("cb3"); } else if (actionCommand.equals("comboBox1")) { inputEncoding = comboBox1.getSelectedItem().toString(); Log.info("inputEncoding: " + inputEncoding); setText(); } else if (actionCommand.equals("comboBox2")) { outputEncoding1 = comboBox2.getSelectedItem().toString(); Log.info("outputEncoding1: " + outputEncoding1); setText(); } else if (actionCommand.equals("comboBox3")) { outputEncoding2 = comboBox3.getSelectedItem().toString(); Log.info("outputEncoding2: " + outputEncoding2); setText(); } else if (actionCommand.equals("open")) { chooseFile(tb1); } else if (actionCommand.equals("convert")) { setText(); } else if (actionCommand.equals("refresh")) { this.repaint(); } else if (actionCommand.equals("about_item")) { String copyright = "Released Under MIT License. eGangotri Digital Preservation Trust\n" + "Pls. Contact egagotritrust@gmail.com for questions and suggestions."; JOptionPane.showMessageDialog(this, copyright, "eGangotri Indic Transliterator", JOptionPane.PLAIN_MESSAGE); } else if (actionCommand.equals("save_1")) { FileIO.saveText(this, tb1, p2); } else if (actionCommand.equals("save_2")) { FileIO.saveText(this, tb2, p2); } else if (actionCommand.equals("save_3")) { FileIO.saveText(this, tb3, p2); } else if (actionCommand.equals("open_1")) { chooseFile(tb1); setText(); } else if (actionCommand.equals("capitalize")) { if (capitalize.isSelected()) { capitalizeIAST = true; tb3.setText(WordUtils.capitalizeFully(tb3.getText())); } else { capitalizeIAST = false; tb3.setText(WordUtils.uncapitalize(tb3.getText())); } } else { CommonActions.performActions(actionCommand); } }
From source file:org.jfree.chart.demo.CompassDemo.java
/** * Handles an action event.//from w w w .j ava 2s. c om * * @param e the event. */ void pick1PointerActionPerformed(final ActionEvent e) { if (CompassDemo.DEBUG) { System.out.println("compassDemo:pick1PointActionPerformed " + e.getActionCommand() + ","); } this.compassPlot.setSeriesNeedle(0, this.pick1Pointer.getSelectedIndex()); this.compassPlot.setSeriesPaint(0, Color.blue); this.compassPlot.setSeriesOutlinePaint(0, Color.blue); }
From source file:com.game.ui.views.PlayerEditor.java
@Override public void actionPerformed(ActionEvent ae) { validationMess.setText(""); validationMess.setVisible(false);//from ww w. j a v a2s .c o m if (ae.getActionCommand().equalsIgnoreCase("dropDown")) { JComboBox comboBox = (JComboBox) ae.getSource(); String type = comboBox.getSelectedItem().toString(); for (GameCharacter user : GameBean.playerDetails) { Player player = (Player) user; if (player.getType().equalsIgnoreCase(type)) { ((JTextField) leftPanel.getComponent(2)).setText(player.getName()); ((JTextField) leftPanel.getComponent(4)).setText(player.getImagePath()); ((JTextField) leftPanel.getComponent(6)).setText(new Integer(player.getHealth()).toString()); ((JTextField) leftPanel.getComponent(8)).setText(new Integer(player.getAttackPts()).toString()); ((JTextField) leftPanel.getComponent(10)).setText(new Integer(player.getArmor()).toString()); ((JTextField) leftPanel.getComponent(12)) .setText(new Integer(player.getAttackRange()).toString()); ((JTextField) leftPanel.getComponent(14)).setText(new Integer(player.getMovement()).toString()); ((JTextField) leftPanel.getComponent(16)).setText(player.getType()); JComboBox cBox = (JComboBox) leftPanel.getComponent(18); cBox.setSelectedItem(player.getInventory().getEquippedWeapon().getName()); lvlPanel.txtFields[0].setText("" + player.getLevel()); lvlPanel.txtFields[1].setText("" + player.getExp()); lvlPanel.txtFields[2].setText("" + player.getStrength()); lvlPanel.txtFields[3].setText("" + player.getVitality()); lvlPanel.txtFields[4].setText("" + player.getDexterity()); lvlPanel.txtFields[5].setText("" + player.getWisdom()); break; // return; } } } else { String name = ((JTextField) leftPanel.getComponent(2)).getText(); String image = ((JTextField) leftPanel.getComponent(4)).getText(); String health = ((JTextField) leftPanel.getComponent(6)).getText(); String attackPts = ((JTextField) leftPanel.getComponent(8)).getText(); String armourPts = ((JTextField) leftPanel.getComponent(10)).getText(); String attackRnge = ((JTextField) leftPanel.getComponent(12)).getText(); String movement = ((JTextField) leftPanel.getComponent(14)).getText(); String type = ((JTextField) leftPanel.getComponent(16)).getText(); String weapon = ((JComboBox) leftPanel.getComponent(18)).getSelectedItem().toString(); int attr[] = new int[6]; attr[0] = Integer.parseInt(lvlPanel.txtFields[0].getText()); attr[1] = Integer.parseInt(lvlPanel.txtFields[1].getText()); attr[2] = Integer.parseInt(lvlPanel.txtFields[2].getText()); attr[3] = Integer.parseInt(lvlPanel.txtFields[3].getText()); attr[4] = Integer.parseInt(lvlPanel.txtFields[4].getText()); attr[5] = Integer.parseInt(lvlPanel.txtFields[5].getText()); // validationMess.setText(""); // validationMess.setVisible(false); if (StringUtils.isNotBlank(image) && StringUtils.isNotBlank(health) && StringUtils.isNotBlank(attackPts) && StringUtils.isNotBlank(armourPts) && StringUtils.isNotBlank(attackRnge) && StringUtils.isNotBlank(movement) && StringUtils.isNotBlank(type) && StringUtils.isNotBlank(weapon)) { validationMess.setVisible(false); Player player = new Player(); //have to remove the following statement later.. player.setName(name); player.setAttackPts(Integer.parseInt(attackPts)); player.setAttackRange(Integer.parseInt(attackRnge)); player.setHealth(Integer.parseInt(health)); player.setImagePath(image); player.setMovement(Integer.parseInt(movement)); player.setArmor(Integer.parseInt(armourPts)); player.setType(type); Inventory inventory = new Inventory(); int position = GameUtils.getPositionOfWeaponItem(weapon); Weapon weaponObj = (Weapon) GameBean.weaponDetails.get(position); inventory.setEquippedWeapon(weaponObj); player.setInventory(inventory); player.setLevel(attr[0]); player.setExp(attr[1]); player.setStrength(attr[2]); player.setVitality(attr[3]); player.setDexterity(attr[4]); player.setWisdom(attr[5]); boolean characterAlrdyPresent = false; for (int i = 0; i < GameBean.playerDetails.size(); i++) { Player charFromList = (Player) GameBean.playerDetails.get(i); if (charFromList.getType().equalsIgnoreCase(type)) { GameBean.playerDetails.remove(i); characterAlrdyPresent = true; } } GameBean.playerDetails.add(player); try { GameUtils.writeCharactersToXML(GameBean.playerDetails, Configuration.PATH_FOR_USER_CHARACTERS); validationMess.setText("Saved Successfully.."); validationMess.setVisible(true); if (!characterAlrdyPresent) { comboBox.addItem(type); comboBox.removeActionListener(this); comboBox.setSelectedItem(type); comboBox.addActionListener(this); } } catch (Exception e) { System.out.println("PlayerEditor : actionPerformed() : Some error occured " + e); validationMess.setText("Some error occured.."); validationMess.setVisible(true); e.printStackTrace(); } } else { validationMess.setText("Pls enter all the fields or pls choose a character from the drop down"); validationMess.setVisible(true); } } this.revalidate(); // JFrame frame = (JFrame)SwingUtilities.getAncestorNamed("Frame", this); // frame.revalidate(); }
From source file:TextInputDemo.java
/** * Called when the user clicks the button or presses * Enter in a text field./* w w w. jav a 2s . c o m*/ */ public void actionPerformed(ActionEvent e) { if ("clear".equals(e.getActionCommand())) { addressSet = false; streetField.setText(""); cityField.setText(""); //We can't just setText on the formatted text //field, since its value will remain set. zipField.setValue(null); } else { addressSet = true; } updateDisplays(); }
From source file:MultiView.java
public void actionPerformed(ActionEvent event) { if (event.getActionCommand().equals("Add View") != false) { // create a new ViewPlatform ViewPlatform vp = createViewPlatform(); // create the BranchGroup for the ViewPlatform BranchGroup viewBranchGroup = createViewBranchGroup(getViewTransformGroupArray(), vp); // add the ViewPlatform BranchGroup to the default Locale addViewBranchGroup(getFirstLocale(), viewBranchGroup); // create the View (including Canvas3D) and attach to the // ViewPlatform createView(vp);//from w w w . j a v a 2 s . c o m } }
From source file:eu.hydrologis.jgrass.charting.impl.JGrassXYBarChart.java
/** * Actions called be registered Objects/*w w w .j a v a 2s .c o m*/ * * @param e the action event. */ public void actionPerformed(ActionEvent e) { // if the hide Checkboxes are toggled if (e.getSource() instanceof JCheckBox) { int series = -1; for (int i = 0; i < chartSeries.length; i++) { if (e.getActionCommand().equals(chartSeries[i].getDescription())) { series = i; } } if (series >= 0) { boolean visible = this.renderer.getItemVisible(series, 0); this.renderer.setSeriesVisible(series, new Boolean(!visible)); } } }
From source file:PeerPanel.java
private void transferButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transferButtonActionPerformed switch (evt.getActionCommand()) { case "receive": transfer = new ReceiveTransferableFiles("localhost", //serverValue.getText(), 12345//Integer.parseInt(portValue.getText()) );//w w w . j a v a 2s . c o m transfer.execute(); mainFrame.jTabbedPane1.setEnabledAt(0, false); saveLocationButton.setEnabled(false); mainFrame.setTitle( "JavaP2P - Listening on: " + serverValue.getText() + ":" + portValue.getText() + "..."); transferButton.setText("Cancel"); transferButton.setActionCommand("cancel"); break; case "cancel": if (transfer != null) transfer.cancel(true); break; } }
From source file:Data.c_CardDB.java
public void actionPerformed(ActionEvent e) { /* ID Language Name Alt Cost Type Set Rarity P T Oracle Rules Printed Name Printed Type Printed Rules Flavor Text Card # Artist Printings */ if (!e.getActionCommand().startsWith("ID") && e.getID() == Action.ACTION_CARDS_DB_LOAD_LINE) { String ary[] = e.getActionCommand().split("\t"); c_Card card = new c_Card(ary); if (card.Name != null) { addCard(card);/*from ww w .ja va 2s . co m*/ if (m_loadingListener != null) { m_loadingListener.actionPerformed(e); } card = null; } } else { if (m_loadingListener != null) { m_loadingListener.actionPerformed(e); } } }
From source file:HostPanel.java
private void transferButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transferButtonActionPerformed switch (evt.getActionCommand()) { case "host": mainFrame.jTabbedPane1.setEnabledAt(1, false); dropTargetClear.setEnabled(false); transferButton.setText("Cancel"); transferButton.setActionCommand("cancel"); try {//from w ww. j av a2s.c o m int port = (int) ((Math.random() * 8999) + 1000); mainFrame.setTitle( "JavaP2P - Listening on: " + InetAddress.getLocalHost().getHostAddress() + ":" + port); transfer = new SendTransferableFiles(port); transfer.execute(); } catch (UnknownHostException ex) { Logger.getLogger(HostPanel.class.getName()).log(Level.SEVERE, null, ex); } break; case "cancel": if (transfer != null) transfer.cancel(true); break; } }
From source file:de.tor.tribes.ui.views.DSWorkbenchMarkerFrame.java
@Override public void actionPerformed(ActionEvent e) { MarkerTableTab activeTab = getActiveTab(); if (e.getActionCommand() != null && activeTab != null) { switch (e.getActionCommand()) { case "BBCopy": activeTab.transferSelection(MarkerTableTab.TRANSFER_TYPE.CLIPBOARD_BB); break; case "Cut": activeTab.transferSelection(MarkerTableTab.TRANSFER_TYPE.CUT_TO_INTERNAL_CLIPBOARD); break; case "Copy": activeTab.transferSelection(MarkerTableTab.TRANSFER_TYPE.COPY_TO_INTERNAL_CLIPBOARD); break; case "Paste": activeTab.transferSelection(MarkerTableTab.TRANSFER_TYPE.FROM_INTERNAL_CLIPBOARD); break; case "Delete": activeTab.deleteSelection(true); break; default:/*from w w w .j av a 2 s .c o m*/ break; } } }