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:IconDemoApplet.java

public void actionPerformed(ActionEvent e) {
    //Show loading message.
    photographLabel.setIcon(null);//from   w  w w  .  j  a  va 2  s .  c o  m
    photographLabel.setText("Loading image...");

    //Compute index of photograph to view.
    if (e.getActionCommand().equals("next")) {
        current += 1;
        if (!previousButton.isEnabled())
            previousButton.setEnabled(true);
        if (current == pictures.size() - 1)
            nextButton.setEnabled(false);
    } else {
        current -= 1;
        if (!nextButton.isEnabled())
            nextButton.setEnabled(true);
        if (current == 0)
            previousButton.setEnabled(false);
    }

    //Get the photo object.
    Photo pic = (Photo) pictures.elementAt(current);

    //Update the caption and number labels.
    captionLabel.setText(pic.caption);
    numberLabel.setText("Picture " + (current + 1) + " of " + pictures.size());

    //Update the photograph.
    ImageIcon icon = pic.getIcon();
    if (icon == null) { //haven't viewed this photo before
        loadImage(imagedir + pic.filename, current);
    } else {
        updatePhotograph(current, pic);
    }
}

From source file:Align_Projections.java

public void actionPerformed(ActionEvent e) {
    String label = e.getActionCommand();
    if (label == null) {
        return;//  w  w  w  .j a  va2  s  .com
    }
    if (label.equals("Update")) {
        updateAction();
    } else if (label.equals("Optimize")) {
        tune();
    } else if (label.equals("Stop Optimizing")) {
        optimizeButton.setLabel("Stopping. Please wait...");
        optimizeButton.setEnabled(false);
        stopTuning = true;
    } else if (label.equals("Apply to stack and save"))
        applyAction();
    else if (label.equals("Reset"))
        reset();
}

From source file:org.gumtree.vis.hist2d.Hist2DChartEditor.java

@Override
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (command.equals(CHANGE_ROI_COMMAND)) {
        Object obj = roiCombo.getSelectedItem();
        if (obj instanceof Abstract2DMask) {
            newMask = null;/*  w w  w .j  ava 2s  .c o m*/
            chooseROI((Abstract2DMask) obj);
        }
    } else if (command.equals(CREATE_NEW_RECT_REGION_COMMAND)) {
        createNewRectangleROI();
    } else if (command.equals(CREATE_NEW_ELLIPSE_REGION_COMMAND)) {
        createNewEllipseROI();
    } else if (command.equals(REMOVE_CHANGE_ACTION)) {
        removeROI();
    } else if (command.equals(APPLY_CHANGE_ACTION)) {
        applyROIChange();
        applyButton.setEnabled(false);
    } else if (command.equals(CHANGE_ROI_NAME_COMMAND)) {
        applyButton.setEnabled(true);
    } else if (command.equals(USE_INCLUSIVE_COMMAND)) {
        applyButton.setEnabled(true);
    } else if (command.equals(USE_EXCLUSIVE_COMMAND)) {
        applyButton.setEnabled(true);
    } else if (command.equals(CHANGE_XMIN_COMMAND)) {
        applyButton.setEnabled(true);
    } else if (command.equals(CHANGE_XMAX_COMMAND)) {
        applyButton.setEnabled(true);
    } else if (command.equals(CHANGE_YMIN_COMMAND)) {
        applyButton.setEnabled(true);
    } else if (command.equals(CHANGE_YMAX_COMMAND)) {
        applyButton.setEnabled(true);
    }
}

From source file:org.micromanager.CRISP.CRISPFrame.java

private void LockButton_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LockButton_ActionPerformed
    if ("Lock".equals(evt.getActionCommand())) {
        LockButton_.setText("Unlock");
        // lock the device
        try {/*from w ww.j a v  a2 s.c  om*/
            core_.enableContinuousFocus(true);
        } catch (Exception ex) {
            ReportingUtils.displayNonBlockingMessage("Failed to lock");
        }

        LockButton_.setSelected(true);
    } else if ("Unlock".equals(evt.getActionCommand())) {
        LockButton_.setText("Lock");
        // unlock the device
        try {
            core_.enableContinuousFocus(false);
        } catch (Exception ex) {
            ReportingUtils.displayNonBlockingMessage("Failed to lock");
        }

        LockButton_.setSelected(false);
    }
}

From source file:PlatformTest.java

public void actionPerformed(ActionEvent event) {
    KeyNavigatorBehavior key = (KeyNavigatorBehavior) m_KeyHashtable.get(event.getActionCommand());
    Object[] keysArray = m_KeyHashtable.values().toArray();

    for (int n = 0; n < keysArray.length; n++) {
        KeyNavigatorBehavior keyAtIndex = (KeyNavigatorBehavior) keysArray[n];
        keyAtIndex.setEnable(keyAtIndex == key);

        if (keyAtIndex == key)
            System.out.println("Enabled: " + event.getActionCommand());
    }// w w  w.j a  v  a 2  s.co m
}

From source file:com.funambol.json.admin.NoteSyncSourceAdminPanel.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() {
    // set layout
    this.setLayout(null);
    // set properties of label, position and border
    //  referred to the title of the panel
    titledBorder = new TitledBorder("");
    panelName.setFont(titlePanelFont);
    panelName.setText(getPanelName());
    panelName.setBounds(new Rectangle(14, 5, 316, 28));
    panelName.setAlignmentX(SwingConstants.CENTER);
    panelName.setBorder(titledBorder);

    final int LABEL_X = 14;
    final int VALUE_X = 170;
    int y = 60;
    final int GAP_X = 150;
    final int GAP_Y = 30;

    sourceUriLabel.setText("Source URI: ");
    sourceUriLabel.setFont(defaultFont);
    sourceUriLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    sourceUriValue.setFont(defaultFont);
    sourceUriValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));

    y += GAP_Y; // New line

    nameLabel.setText("Name: ");
    nameLabel.setFont(defaultFont);
    nameLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    nameValue.setFont(defaultFont);
    nameValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));
    y += GAP_Y; // New line

    typeLabel.setText("Client Type: ");
    typeLabel.setFont(defaultFont);
    typeLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    typeCombo.setFont(defaultFont);
    typeCombo.setBounds(new Rectangle(VALUE_X, y, 350, 18));

    y += GAP_Y; // New line
    int x = LABEL_X;

    confirmButton.setFont(defaultFont);
    confirmButton.setText("Add");
    confirmButton.setBounds(VALUE_X, y, 70, 25);

    // What happens when the confirmButton is pressed?
    confirmButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                if (getState() == STATE_INSERT) {
                    NoteSyncSourceAdminPanel.this.actionPerformed(new ActionEvent(NoteSyncSourceAdminPanel.this,
                            ACTION_EVENT_INSERT, event.getActionCommand()));
                } else {
                    NoteSyncSourceAdminPanel.this.actionPerformed(new ActionEvent(NoteSyncSourceAdminPanel.this,
                            ACTION_EVENT_UPDATE, event.getActionCommand()));
                }
            } catch (Exception e) {
                notifyError(new AdminException(e.getMessage(), e));
            }
        }
    });

    // Adds all components to the panel
    this.add(panelName, null);
    this.add(nameLabel, null);
    this.add(sourceUriLabel, null);
    this.add(sourceUriValue, null);
    this.add(nameValue, null);
    this.add(typeLabel, null);
    this.add(typeCombo, null);
    this.add(confirmButton, null);

}

From source file:HiResCoordTest.java

public void actionPerformed(ActionEvent event) {
    if (event.getActionCommand() == "Sun") {
        m_TranslateZ = m_TranslateSunZ;/*from   ww  w .  j  a  v a  2  s  .  c om*/
        m_View.attachViewPlatform(m_ViewPlatformArray[0]);
    } else if (event.getActionCommand() == "Earth" && m_ViewPlatformArray[1] != null) {
        m_TranslateZ = m_TranslateEarthZ;
        m_View.attachViewPlatform(m_ViewPlatformArray[1]);
    } else if (event.getActionCommand() == "House" && m_ViewPlatformArray[1] != null) {
        m_TranslateZ = m_TranslateHouseZ;
        m_View.attachViewPlatform(m_ViewPlatformArray[2]);
    }

    m_View.setBackClipDistance(getBackClipDistance());
    m_View.setFrontClipDistance(getFrontClipDistance());
}

From source file:com.ibm.issw.odc.gui.BPMArgumentsPanel.java

/**
 * Invoked when an action occurs. This implementation supports the add and
 * delete buttons./*from  w ww.ja  v a2s.  com*/
 *
 * @param e
 *            the event that has occurred
 */
@Override
public void actionPerformed(ActionEvent e) {
    String action = e.getActionCommand();
    if (action.equals(DELETE)) {
        deleteArgument();
    } else if (action.equals(ADD)) {
        addArgument();
    } else if (action.equals(ADD_FROM_CLIPBOARD)) {
        addFromClipboard();
    } else if (action.equals(UP)) {
        moveUp();
    } else if (action.equals(DOWN)) {
        moveDown();
    } else if (action.equals(DETAIL)) {
        showDetail();
    }
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.navegacao_cego.PainelSimuladorNavegacao.java

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    if (cmd.equals("Abrir")) {
        AbrirActionPerformed(null);/*  w  w w.j  a  va2 s  . c o m*/
    } else if (cmd == "AbrirURL") {
        openUrl();
    } else if (cmd == "Creditos") {
        new Creditos();
    } else if (cmd.equals("SelecionarTudo")) {
        textAreaSourceCode.getTextPane().selectAll();
        textAreaSourceCode.getTextPane().requestFocus();
    } else if (cmd == "AumentaFonte") {
        textAreaSourceCode.aumentaFontSize();
    } else if (cmd == "DiminuiFonte") {
        textAreaSourceCode.diminuiFontSize();
    } else if (cmd == "Contraste") {
        textAreaSourceCode.autoContraste();
    }
}

From source file:net.mariottini.swing.JFontChooser.java

/**
 * Show a "Choose Font" dialog with the specified title and modality.
 * //from  w w  w . jav  a 2  s .  c  om
 * @param parent
 *          the parent component, or null to use a default root frame as parent.
 * @param title
 *          the title for the dialog.
 * @param modal
 *          true to show a modal dialog, false to show a non-modal dialog (in this case the
 *          function will return immediately after making visible the dialog).
 * @return <code>APPROVE_OPTION</code> if the user chose a font, <code>CANCEL_OPTION</code> if the
 *         user canceled the operation. <code>CANCEL_OPTION</code> is always returned for a
 *         non-modal dialog, use an ActionListener to be notified when the user approves/cancels
 *         the dialog.
 * @see #APPROVE_OPTION
 * @see #CANCEL_OPTION
 * @see #addActionListener
 */
public int showDialog(Component parent, String title, boolean modal) {
    final int[] result = new int[] { CANCEL_OPTION };
    while (parent != null && !(parent instanceof Window)) {
        parent = parent.getParent();
    }
    final JDialog d;
    if (parent instanceof Frame) {
        d = new JDialog((Frame) parent, title, modal);
    } else if (parent instanceof Dialog) {
        d = new JDialog((Dialog) parent, title, modal);
    } else {
        d = new JDialog();
        d.setTitle(title);
        d.setModal(modal);
    }
    final ActionListener[] listener = new ActionListener[1];
    listener[0] = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (e.getActionCommand().equals(APPROVE_SELECTION)) {
                result[0] = APPROVE_OPTION;
            }
            removeActionListener(listener[0]);
            d.setContentPane(new JPanel());
            d.setVisible(false);
            d.dispose();
        }
    };
    addActionListener(listener[0]);
    d.setComponentOrientation(getComponentOrientation());
    d.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
    d.getContentPane().add(this, BorderLayout.CENTER);
    d.pack();
    d.setLocationRelativeTo(parent);
    d.setVisible(true);
    return result[0];
}