Example usage for java.awt.event ActionEvent getActionCommand

List of usage examples for java.awt.event ActionEvent getActionCommand

Introduction

In this page you can find the example usage for java.awt.event ActionEvent getActionCommand.

Prototype

public String getActionCommand() 

Source Link

Document

Returns the command string associated with this action.

Usage

From source file:SwingTest.java

/**
 * AWT callback to indicate that an items has been selected from a menu.
 *//*from w ww  .  j av  a  2  s  .co  m*/
public void actionPerformed(ActionEvent ae) {
    System.out.println("Action Performed: " + ae.getActionCommand());

    java.util.StringTokenizer toker = new java.util.StringTokenizer(ae.getActionCommand(), "|");

    String menu = toker.nextToken();
    String command = toker.nextToken();

    if (menu.equals("File")) {
        if (command.equals("Exit")) {
            System.exit(0);
        } else if (command.equals("Save Image")) {
            onSaveImage();
        }
    } else if (menu.equals("View")) {
        if (command.equals("Cube")) {
            removeShape("Sphere");
            sceneBranchGroup.addChild(createCube());
        } else if (command.equals("Sphere")) {
            removeShape("Cube");
            sceneBranchGroup.addChild(createSphere());
        }
    } else if (menu.equals("Rotate")) {
        if (command.equals("On")) {
            rotator.setEnable(true);
        } else if (command.equals("Off")) {
            rotator.setEnable(false);
        }
    }
}

From source file:de.tor.tribes.ui.views.DSWorkbenchFormFrame.java

@Override
public void actionPerformed(ActionEvent e) {

    if (e.getActionCommand().equals("Copy")) {
        copySelectionToInternalClipboard();
    } else if (e.getActionCommand().equals("BBCopy")) {
        copySelectionToInternalClipboardAsBBCodes();
    } else if (e.getActionCommand().equals("Delete")) {
        deleteSelection();//from w  ww  .j  av  a 2 s  .  c o m
    }
}

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 . j  a v a2 s . c  o  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.att.aro.ui.view.menu.datacollector.DeviceDialogOptions.java

private void showHideOptions(ActionEvent e) {
    String ac = e.getActionCommand();

    // Video Option
    if (ac.equals(txtLREZ)) {
        videoOption = VideoOption.LREZ;/*w  w w .  j a  v  a  2s .c  om*/
        showVideoOrientation(false);
        return;
    } else if (ac.equals(txtHDEF)) {
        videoOption = VideoOption.HDEF;
        if (getApi(selectedDevice) > AndroidApiLevel.K19.levelNumber()) {
            showVideoOrientation(true);
        } else {
            showVideoOrientation(false);
        }
        return;
    } else if (ac.equals(txtSDEF) && getApi(selectedDevice) > AndroidApiLevel.K19.levelNumber()) {
        videoOption = VideoOption.SDEF;
        if (getApi(selectedDevice) > AndroidApiLevel.K19.levelNumber()) {
            showVideoOrientation(true);
        } else {
            showVideoOrientation(false);
        }
        return;
    } else if (ac.equals(txtNONE)) {
        videoOption = VideoOption.NONE;
        showVideoOrientation(false);
        return;
    } else if (ac.equals(txtPortrait)) {
        videoOrient = Orientation.PORTRAIT;
        SettingsImpl.getInstance().setAndSaveAttribute("orientation", videoOrient.toString().toLowerCase());
        return;
    } else if (ac.equals(txtLandscape)) {
        videoOrient = Orientation.LANDSCAPE;
        SettingsImpl.getInstance().setAndSaveAttribute("orientation", videoOrient.toString().toLowerCase());
        return;
    }

    // Collector
    else if (ac.equals(rooted)) {
        collector = rootCollector;
        if (btnRooted.isSelected()) {

            enableFullVideo(false);
        }
        return;

    } else if (ac.equals(vpn)) {
        collector = vpnCollector;
        if (btnVpn.isSelected()) {
            enableFullVideo(true);
        }

        return;

    }
}

From source file:net.sf.mzmine.modules.visualization.tic.TICPlot.java

@Override
public void actionPerformed(final ActionEvent event) {

    super.actionPerformed(event);

    final String command = event.getActionCommand();

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

        switchDataPointsVisible();/*from w  w w.  j a  v  a  2s.  co  m*/
    }

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

        switchItemLabelsVisible();
    }

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

        new AxesSetupDialog(getXYPlot()).setVisible(true);
    }

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

        getXYPlot().getDomainAxis().resizeRange(1.0 / ZOOM_FACTOR);
    }

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

        getXYPlot().getDomainAxis().resizeRange(ZOOM_FACTOR);
    }

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

        // Get current axes range.
        final NumberAxis xAxis = (NumberAxis) getXYPlot().getDomainAxis();
        final NumberAxis yAxis = (NumberAxis) getXYPlot().getRangeAxis();
        final double xMin = xAxis.getRange().getLowerBound();
        final double xMax = xAxis.getRange().getUpperBound();
        final double xTick = xAxis.getTickUnit().getSize();
        final double yMin = yAxis.getRange().getLowerBound();
        final double yMax = yAxis.getRange().getUpperBound();
        final double yTick = yAxis.getTickUnit().getSize();

        // Set the range of these frames
        for (final Window frame : JFrame.getWindows()) {
            if (frame instanceof TICVisualizerWindow) {

                final TICVisualizerWindow ticFrame = (TICVisualizerWindow) frame;
                ticFrame.setAxesRange(xMin, xMax, xTick, yMin, yMax, yTick);
            }
        }
    }

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

        visualizer.actionPerformed(event);
    }

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

        // Toggle legend visibility.
        final LegendTitle legend = getChart().getLegend();
        legend.setVisible(!legend.isVisible());
    }
}

From source file:com.wet.wired.jsr.player.JPlayer.java

public void actionPerformed(ActionEvent ev) {

    if (ev.getActionCommand().equals("open")) {
        UIManager.put("FileChooser.readOnly", true);
        JFileChooser fileChooser = new JFileChooser();
        FileExtensionFilter filter = new FileExtensionFilter();

        filter = new FileExtensionFilter();
        filter.addExtension("owl");
        filter.setDescription("TestingOwl File");

        if (target != null) {
            fileChooser.setSelectedFile(new File(target + ".owl"));
        }//ww  w. jav  a2  s  .c  o  m
        fileChooser.setFileFilter(filter);
        fileChooser.setCurrentDirectory(new File("."));
        fileChooser.showOpenDialog(this);

        if (fileChooser.getSelectedFile() != null) {
            // target = fileChooser.getSelectedFile().getAbsolutePath();
            String targetCapOwl = fileChooser.getSelectedFile().getAbsolutePath();
            target = targetCapOwl.substring(0, targetCapOwl.lastIndexOf(".owl"));
            open();
        }
    } else if (ev.getActionCommand().equals("play")) {
        play();
    } else if (ev.getActionCommand().equals("reset")) {
        reset();
    } else if (ev.getActionCommand().equals("fastForward")) {
        fastForward();
    } else if (ev.getActionCommand().equals("pause")) {
        pause();
    } else if (ev.getActionCommand().equals("close")) {
        close();
    } else if (ev.getActionCommand().equals("recorder")) {
        closePlayer();
        Main.getRecorder().init(new String[0]);
    }
}

From source file:livecanvas.mesheditor.MeshEditor.java

@Override
public boolean handleEvent(ActionEvent e) {
    switch (Integer.parseInt(e.getActionCommand())) {
    case EXIT:/*from  w w w.  j  a  v a 2  s  . c om*/
        exit();
        break;
    case NEW:
        clear();
        break;
    case OPEN:
        open(null);
        break;
    case SAVE:
        save(null);
        break;
    case SETTINGS:
        showSettingsDialog();
        break;
    case SEE_THROUGH:
        toggleOnionSkin();
        break;
    case SHOW_MESH:
        toggleShowMesh();
        break;
    case RENDER_SETTINGS:
        renderSettings();
        break;
    case RENDER:
        showImage(render());
        break;
    case TOOLS_BRUSH:
        setSelectedToolType(TOOLS_BRUSH);
        break;
    case TOOLS_PEN:
        setSelectedToolType(TOOLS_PEN);
        break;
    case TOOLS_MAGICWAND:
        setSelectedToolType(TOOLS_MAGICWAND);
        break;
    case TOOLS_SETCONTROLPOINTS:
        setSelectedToolType(TOOLS_SETCONTROLPOINTS);
        break;
    case TOOLS_POINTER:
        setSelectedToolType(TOOLS_POINTER);
        break;
    case TOOLS_PANZOOM:
        setSelectedToolType(TOOLS_PANZOOM);
        break;
    default:
        return false;
    }
    repaint();
    return true;
}

From source file:edu.ucla.stat.SOCR.chart.SuperXYChart_QQ.java

public void actionPerformed(ActionEvent evt) {
    if (evt.getActionCommand().equals(NORMAL)) {
        try {// w ww .  jav a2s.  c  o  m
            disChoice = NORMAL;
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if (evt.getActionCommand().equals(POISSON)) {
        try {
            disChoice = POISSON;
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if (evt.getSource() == addButton1) {
        addButtonDependent();
    } else if (evt.getSource() == removeButton1) {
        removeButtonDependent();
    }

}

From source file:ca.inverse.sogo.admin.SOGoSyncSourceConfigPanel.java

/**
 * //from w  w w .  jav  a 2  s  .c om
 */
private void init() {
    this.setLayout(null);

    titledBorder1 = new TitledBorder("");

    panelName.setFont(titlePanelFont);
    panelName.setText("Edit SOGo SyncSource");
    panelName.setBounds(new Rectangle(14, 5, 316, 28));
    panelName.setAlignmentX(SwingConstants.CENTER);
    panelName.setBorder(titledBorder1);

    int y = 60;
    int dy = 30;
    sourceURILabel.setText("Source URI: ");
    sourceURILabel.setFont(defaultFont);
    sourceURILabel.setBounds(new Rectangle(14, y, 150, 18));
    sourceURIValue.setFont(defaultFont);
    sourceURIValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;
    nameLabel.setText("Name: ");
    nameLabel.setFont(defaultFont);
    nameLabel.setBounds(new Rectangle(14, y, 150, 18));
    nameValue.setFont(defaultFont);
    nameValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;
    typeLabel.setText("Supported type: ");
    typeLabel.setFont(defaultFont);
    typeLabel.setBounds(new Rectangle(14, y, 150, 18));
    typeValue.setFont(defaultFont);
    typeValue.setBounds(new Rectangle(170, y, 150, 18));

    y += dy;
    dbURLLabel.setText("Database URL: ");
    dbURLLabel.setFont(defaultFont);
    dbURLLabel.setBounds(new Rectangle(14, y, 150, 18));
    dbURLValue.setFont(defaultFont);
    dbURLValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;
    dbUsernameLabel.setText("Database username:");
    dbUsernameLabel.setFont(defaultFont);
    dbUsernameLabel.setBounds(new Rectangle(14, y, 150, 18));
    dbUsernameValue.setFont(defaultFont);
    dbUsernameValue.setBounds(new Rectangle(170, y, 150, 18));

    y += dy;
    dbPasswordLabel.setText("Database password:");
    dbPasswordLabel.setFont(defaultFont);
    dbPasswordLabel.setBounds(new Rectangle(14, y, 150, 18));
    dbPasswordValue.setFont(defaultFont);
    dbPasswordValue.setBounds(new Rectangle(170, y, 150, 18));

    y += dy;
    button.setFont(defaultFont);
    button.setText("Add");
    button.setBounds(170, y, 70, 25);

    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                if (getState() == STATE_INSERT) {
                    SOGoSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(
                            SOGoSyncSourceConfigPanel.this, ACTION_EVENT_INSERT, event.getActionCommand()));
                } else {
                    SOGoSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(
                            SOGoSyncSourceConfigPanel.this, ACTION_EVENT_UPDATE, event.getActionCommand()));
                }
            } catch (Exception e) {
                notifyError(new AdminException(e.getMessage()));
            }
        }
    });

    this.add(panelName, null);
    this.add(nameLabel, null);
    this.add(nameValue, null);
    this.add(typeLabel, null);
    this.add(typeValue, null);
    this.add(sourceURILabel, null);
    this.add(sourceURIValue, null);
    this.add(dbURLLabel);
    this.add(dbURLValue);
    this.add(dbUsernameLabel);
    this.add(dbUsernameValue);
    this.add(dbPasswordLabel);
    this.add(dbPasswordValue);
    this.add(button, null);
}

From source file:com.funambol.admin.settings.panels.EditRollingFileAppender.java

/**
 * Create the panel// w w  w. ja  va  2  s.  c  o m
 * @throws Exception if error occures during creation of the panel.
 */
private void init() throws Exception {

    final int h = 18;
    final int x1 = 15;
    final int x2 = 150;
    final int w1 = 100;
    final int w2 = 310;

    int y = 40;
    int dy = 25;

    setLayout(null);
    setName(Bundle.getMessage(Bundle.EDIT_ROLLING_FILE_APPENDER_PANEL_NAME));

    panelNameLabel.setText(Bundle.getMessage(Bundle.EDIT_ROLLING_FILE_APPENDER_PANEL_NAME));
    panelNameLabel.setBounds(new Rectangle(14, 5, 245, 28));
    panelNameLabel.setAlignmentX(SwingConstants.CENTER);
    panelNameLabel.setBorder(new TitledBorder(""));

    nameLabel.setText(Bundle.getMessage(Bundle.LABEL_APPENDER_NAME) + " :");
    nameLabel.setBounds(new Rectangle(x1, y, w1, h));
    nameLabel2.setBounds(new Rectangle(x2, y, w2, h));

    y += dy;

    fileNameLabel.setText(Bundle.getMessage(Bundle.LABEL_FILE_NAME) + " :");
    fileNameLabel.setBounds(new Rectangle(x1, y, w1, h));
    fileNameValue.setBounds(new Rectangle(x2, y, w2, h));

    y += dy;

    fileSizeLabel.setText(Bundle.getMessage(Bundle.LABEL_MAX_FILE_SIZE) + " :");
    fileSizeLabel.setBounds(new Rectangle(x1, y, w1, h));
    fileSizeValue.setBounds(new Rectangle(x2, y, w2, h));
    fileSizeValue.setHorizontalAlignment(JTextField.RIGHT);
    limitMBLabel.setBounds(new Rectangle(x2 + w2 + 10, y, 50, h));

    y += dy;

    fileRotationCountLabel.setText(Bundle.getMessage(Bundle.LABEL_MAX_BACKUP_INDEX) + " :");
    fileRotationCountLabel.setBounds(new Rectangle(x1, y, w1, h));
    fileRotationCountValue.setBounds(new Rectangle(x2, y, w2, h));
    fileRotationCountValue.setHorizontalAlignment(JTextField.RIGHT);

    y += dy;

    conversionPatternLabel.setText(Bundle.getMessage(Bundle.LABEL_PATTERN_LAYOUT) + " :");
    conversionPatternLabel.setBounds(new Rectangle(x1, y, w1, h));
    conversionPattern.setBounds(new Rectangle(x2, y, w2, h));

    y += dy;

    noteLabel.setText(Bundle.getMessage(Bundle.LABEL_FILE_APPENDER_NOTE));
    noteLabel.setBounds(new Rectangle(x1, y, 500, h));

    y += dy;
    y += dy;

    confirmButton.setText(Bundle.getMessage(Bundle.LABEL_BUTTON_SAVE));
    confirmButton.setBounds(new Rectangle(401, y, 60, 25));

    confirmButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                EditRollingFileAppender.this.actionPerformed(new ActionEvent(EditRollingFileAppender.this,
                        ACTION_EVENT_UPDATE, event.getActionCommand()));
            } catch (Exception e) {
                notifyError(new AdminException(e.getMessage()));
            }
        }
    });

    add(panelNameLabel, null);
    add(nameLabel, null);
    add(nameLabel2, null);
    add(fileNameLabel, null);
    add(fileNameValue, null);
    add(fileRotationCountLabel, null);
    add(fileRotationCountValue, null);
    add(fileSizeLabel, null);
    add(fileSizeValue, null);
    add(limitMBLabel, null);
    add(conversionPatternLabel, null);
    add(conversionPattern, null);
    add(noteLabel, null);

    add(confirmButton, null);

    GuiFactory.setDefaultFont(this);
    panelNameLabel.setFont(GuiFactory.titlePanelFont);

}