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

public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();

    // Handle the New window button.
    if (CREATE_WINDOW.equals(command)) {
        showNewWindow();/*ww  w .j a v  a2  s.c o m*/

        // Handle the first group of radio buttons.
    } else if (NO_DECORATIONS.equals(command)) {
        noDecorations = true;
        JFrame.setDefaultLookAndFeelDecorated(false);
    } else if (WS_DECORATIONS.equals(command)) {
        noDecorations = false;
        JFrame.setDefaultLookAndFeelDecorated(false);
    } else if (LF_DECORATIONS.equals(command)) {
        noDecorations = false;
        JFrame.setDefaultLookAndFeelDecorated(true);

        // Handle the second group of radio buttons.
    } else if (DEFAULT_ICON.equals(command)) {
        specifyIcon = false;
    } else if (FILE_ICON.equals(command)) {
        specifyIcon = true;
        createIcon = false;
    } else if (PAINT_ICON.equals(command)) {
        specifyIcon = true;
        createIcon = true;
    }
}

From source file:es.emergya.ui.gis.popups.GPSDialog.java

@Override
public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals(i18n.getString("window.gps.button.actualizar"))) {
        last_bandejaSalida = send();/*ww  w  .  j  av a  2 s. c  o m*/
        log.info("bandeja de salida: " + last_bandejaSalida);

        if (last_bandejaSalida == null) {
            return;
        }

        final JButton request = ((JButton) e.getSource());

        request.setEnabled(false);
        progressIcon.setIcon(iconEnviando);
        notification.setForeground(Color.WHITE);

        SolicitudGPSActionListener listener = new SolicitudGPSActionListener(last_bandejaSalida);
        Timer t = new Timer(1000, listener);

        listener.setTimer(t);
        t.start();
    }

    if (e.getActionCommand().equals(i18n.getString("Buttons.cancel"))) {
        if (last_bandejaSalida != null) {
            MessageGenerator.remove(last_bandejaSalida.getId());
        }

        last_bandejaSalida = null;
        dispose();
    }
}

From source file:com.emental.mindraider.ui.dialogs.AttachmentJDialog.java

/**
 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
 *///from   ww w. j  av a 2s.co m
public void actionPerformed(ActionEvent e) {
    if (LOCAL.equals(e.getActionCommand())) {
        enableLocalTypeButtons();
    } else {
        enableWebTypeButtons();
    }
}

From source file:de.rub.syssec.saaf.gui.frame.CfgSelectorFrame.java

/**
 * A frame to generate and open Control Flow Graphs. CFGs are created using mxGraph
 * and are saved as PNGs.//from  www . j  a v  a  2s  . c  om
 * 
 * @param smaliClass the smali class to select methods from
 */
public CfgSelectorFrame(ClassInterface smaliClass) {
    super(smaliClass.getFullClassName(true), true, true, true, true);
    this.smaliClass = smaliClass;

    listModel = new MethodTableModel(smaliClass);
    list.setModel(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    list.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent event) {
            int viewRow = list.getSelectedRow();
            if (viewRow <= 0) {
                showButton.setEnabled(false);
            } else {
                showButton.setEnabled(true);
            }
        }
    });

    JScrollPane listScrollPane = new JScrollPane(list);

    ActionListener al = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (e.getActionCommand().equals(SHOW_OPERATION)) {
                generateAndShowCfg(true);
            } else if (e.getActionCommand().equals(GENERATE_OPERATION)) {
                generateAndShowCfg(false);
            }
        }
    };

    generateButton = new JButton(GENERATE_OPERATION);
    generateButton.setActionCommand(GENERATE_OPERATION);
    generateButton.addActionListener(al);
    showButton = new JButton(SHOW_OPERATION);
    showButton.setEnabled(false);
    showButton.addActionListener(al);

    saveCfgCheckBox = new JCheckBox("Save a copy");
    saveCfgCheckBox.setToolTipText("Save a copy in the configured CFG folder upon generation.");

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.add(generateButton);
    buttonPane.add(saveCfgCheckBox);
    buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JPanel filler = new JPanel();
    filler.setPreferredSize(new Dimension(10, 10));
    buttonPane.add(filler);
    buttonPane.add(showButton);

    add(listScrollPane, BorderLayout.CENTER);
    add(buttonPane, BorderLayout.PAGE_END);

    this.setPreferredSize(new Dimension(500, 250));
    this.pack();
    this.setVisible(true);
}

From source file:com.hexidec.ekit.component.UnicodeDialog.java

public void actionPerformed(ActionEvent ae) {
    if (ae.getActionCommand().equals(CMDCHANGEBLOCK)) {
        populateButtons(jcmbBlockSelector.getSelectedIndex(), jcmbPageSelector.getSelectedIndex());
    } else if (ae.getActionCommand().equals("close")) {
        setVisible(false);//from  w  w  w .j  a v a 2  s.  com
        this.dispose();
    } else if (ae.getActionCommand().equals("")) {
        // ignore
    } else {
        try {
            parentEkit.insertUnicodeChar(ae.getActionCommand());
        } catch (java.io.IOException ioe) {
            log.error("IOException during character insertion", ioe);
        } catch (javax.swing.text.BadLocationException ble) {
            log.error("BadLocationException during character insertion", ble);
        }
    }
}

From source file:com.digitalgeneralists.assurance.ui.components.ScanLaunchPanel.java

public void actionPerformed(ActionEvent e) {
    if (AssuranceActions.scanAction.equals(e.getActionCommand())) {
        this.startScan(this.existingScanDefinitionsListPanel.getSelectedValue());
        return;//  ww w.  ja  va  2  s.  c  o m
    }
    if (AssuranceActions.scanAndMergeAction.equals(e.getActionCommand())) {
        this.startScan(this.existingScanDefinitionsListPanel.getSelectedValue(), true);
        return;
    }
    this.existingScanDefinitionsListPanel.actionPerformed(e);
}

From source file:com.floreantpos.ui.OrderFilterPanel.java

private void createPaymentStatusFilterPanel() {
    btnFilterByOpenStatus = new POSToggleButton(PaymentStatusFilter.OPEN.toString());
    btnFilterByPaidStatus = new POSToggleButton(PaymentStatusFilter.PAID.toString());
    btnFilterByUnPaidStatus = new POSToggleButton(PaymentStatusFilter.CLOSED.toString());

    final ButtonGroup paymentGroup = new ButtonGroup();
    paymentGroup.add(btnFilterByOpenStatus);
    paymentGroup.add(btnFilterByPaidStatus);
    paymentGroup.add(btnFilterByUnPaidStatus);

    PaymentStatusFilter paymentStatusFilter = TerminalConfig.getPaymentStatusFilter();

    switch (paymentStatusFilter) {
    case OPEN:/*from   ww  w  .j  a  v  a2  s  . c om*/
        btnFilterByOpenStatus.setSelected(true);
        break;

    case PAID:
        btnFilterByPaidStatus.setSelected(true);
        break;

    case CLOSED:
        btnFilterByUnPaidStatus.setSelected(true);
        break;

    }

    ActionListener psFilterHandler = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            String actionCommand = e.getActionCommand();

            if (actionCommand.equals("CLOSED")
                    && !Application.getCurrentUser().hasPermission(UserPermission.VIEW_ALL_CLOSE_TICKETS)) {

                String password = PasswordEntryDialog.show(Application.getPosWindow(),
                        "Please enter privileged password");
                if (StringUtils.isEmpty(password)) {
                    updateButton();
                    return;
                }

                User user2 = UserDAO.getInstance().findUserBySecretKey(password);
                if (user2 == null) {
                    POSMessageDialog.showError(Application.getPosWindow(),
                            "No user found with that secret key");
                    updateButton();
                    return;
                } else {
                    if (!user2.hasPermission(UserPermission.VIEW_ALL_CLOSE_TICKETS)) {
                        POSMessageDialog.showError(Application.getPosWindow(), "No permission");
                        updateButton();
                        return;
                    }
                }
            }

            String filter = actionCommand.replaceAll("\\s", "_"); //$NON-NLS-1$ //$NON-NLS-2$
            TerminalConfig.setPaymentStatusFilter(filter);

            ticketList.updateTicketList();
            ticketLists.updateButtonStatus();

        }
    };

    btnFilterByOpenStatus.addActionListener(psFilterHandler);
    btnFilterByPaidStatus.addActionListener(psFilterHandler);
    btnFilterByUnPaidStatus.addActionListener(psFilterHandler);

    JPanel filterByPaymentStatusPanel = new JPanel(new MigLayout("", "fill, grow", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    filterByPaymentStatusPanel.setBorder(new TitledBorder(Messages.getString("SwitchboardView.3"))); //$NON-NLS-1$
    filterByPaymentStatusPanel.add(btnFilterByOpenStatus);
    filterByPaymentStatusPanel.add(btnFilterByPaidStatus);
    filterByPaymentStatusPanel.add(btnFilterByUnPaidStatus);

    getContentPane().add(filterByPaymentStatusPanel);
}

From source file:Cal.java

/** Build the GUI. Assumes that setYYMMDD has been called. */
private void buildGUI() {
    getAccessibleContext().setAccessibleDescription("Calendar not accessible yet. Sorry!");
    setBorder(BorderFactory.createEtchedBorder());

    setLayout(new BorderLayout());

    JPanel tp = new JPanel();
    tp.add(monthChoice = new JComboBox());
    for (int i = 0; i < months.length; i++)
        monthChoice.addItem(months[i]);//from   ww w  .  j a  v  a  2 s  .  co m
    monthChoice.setSelectedItem(months[mm]);
    monthChoice.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            int i = monthChoice.getSelectedIndex();
            if (i >= 0) {
                mm = i;
                // System.out.println("Month=" + mm);
                recompute();
            }
        }
    });
    monthChoice.getAccessibleContext().setAccessibleName("Months");
    monthChoice.getAccessibleContext().setAccessibleDescription("Choose a month of the year");

    tp.add(yearChoice = new JComboBox());
    yearChoice.setEditable(true);
    for (int i = yy - 5; i < yy + 5; i++)
        yearChoice.addItem(Integer.toString(i));
    yearChoice.setSelectedItem(Integer.toString(yy));
    yearChoice.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            int i = yearChoice.getSelectedIndex();
            if (i >= 0) {
                yy = Integer.parseInt(yearChoice.getSelectedItem().toString());
                // System.out.println("Year=" + yy);
                recompute();
            }
        }
    });
    add(BorderLayout.CENTER, tp);

    JPanel bp = new JPanel();
    bp.setLayout(new GridLayout(7, 7));
    labs = new JButton[6][7]; // first row is days

    bp.add(b0 = new JButton("S"));
    bp.add(new JButton("M"));
    bp.add(new JButton("T"));
    bp.add(new JButton("W"));
    bp.add(new JButton("R"));
    bp.add(new JButton("F"));
    bp.add(new JButton("S"));

    ActionListener dateSetter = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String num = e.getActionCommand();
            if (!num.equals("")) {
                // set the current day highlighted
                setDayActive(Integer.parseInt(num));
                // When this becomes a Bean, you can
                // fire some kind of DateChanged event here.
                // Also, build a similar daySetter for day-of-week btns.
            }
        }
    };

    // Construct all the buttons, and add them.
    for (int i = 0; i < 6; i++)
        for (int j = 0; j < 7; j++) {
            bp.add(labs[i][j] = new JButton(""));
            labs[i][j].addActionListener(dateSetter);
        }

    add(BorderLayout.SOUTH, bp);
}

From source file:com.reelfx.model.PostProcessor.java

/**
 * Called when a stream gobbler finds a line that relevant to this wrapper.
 *//*from   www .ja v  a2 s .  c o m*/
public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().contains("frame")) {
        //double total_frames = (Double)metadata.get(Metadata.TOTAL_FRAMES);
        //logger.info("Found frame! Total frames="+total_frames); // TODO exact the frame number
        fireProcessUpdate(ENCODING_PROGRESS, null);
    }
}

From source file:com.haskins.cloudtrailviewer.feature.MetricsFeature.java

@Override
public void actionPerformed(ActionEvent e) {
    showChart(e.getActionCommand());
}