Example usage for java.awt.event ActionEvent getSource

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

Introduction

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

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

From source file:it.illinois.adsc.ema.softgrid.monitoring.ui.SPMainFrame.java

@Override
public void actionPerformed(ActionEvent e) {
    if (e.getSource() == exitButton) {
        windowClosing(null);//from  w w w  .j a va 2 s  .co m
    } else if (e.getSource() == monitorButton) {
        executeMonitorQuery();
    } else if (e.getSource() == clearButton) {
        alertPanel.removeAll();
        stopIEDServers();
        logAreaScrollPane.setVisible(true);
        chartPanel.setVisible(false);
        runButton.setEnabled(true);
        clearButton.setEnabled(false);

    } else if (e.getSource() == runButton && logAreaScrollPane.isVisible()) {
        System.out.println("Initializing...!");
        loadConfigurations();
        switch (ConfigUtil.SERVER_TYPE.toUpperCase()) {
        case "IED":
            System.out.println("Starting IEDs...!");
            startIEDs(null);
            break;
        case "PRX":
        case "ACM":
            startPRXs();
            break;
        }
        runButton.setEnabled(false);
        clearButton.setEnabled(true);
    }
}

From source file:dk.dma.epd.shore.gui.views.SendRouteDialog.java

/**
 * Called when one of the buttons are clicked or if one of the combo-boxes changes value
 *//*ww  w. j  a  v a 2 s .  com*/
@Override
public void actionPerformed(ActionEvent ae) {
    if (loading) {
        return;
    }

    if (ae.getSource() == nameComboBox) {
        nameSelectionChanged();

    } else if (ae.getSource() == mmsiListComboBox) {
        mmsiSelectionChanged();

    } else if (ae.getSource() == routeListComboBox) {
        routeSelectionChanged();

    } else if (ae.getSource() == zoomBtn && route.getWaypoints() != null) {
        if (EPD.getInstance().getMainFrame().getActiveChartPanel() != null) {
            EPD.getInstance().getMainFrame().getActiveChartPanel().zoomToWaypoints(route.getWaypoints());
        }

    } else if (ae.getSource() == sendBtn) {
        sendRoute();

    } else if (ae.getSource() == chatBtn) {
        chat();

    } else if (ae.getSource() == cancelBtn || ae.getSource() == getRootPane()) {
        this.setVisible(false);
    }
}

From source file:net.sf.firemox.Magic.java

public void actionPerformed(ActionEvent e) {
    final String command = e.getActionCommand();
    final Object obj = e.getSource();
    if (obj == sendButton) {
        if (sendTxt.getText().length() != 0) {
            MChat.getInstance().sendMessage(sendTxt.getText() + "\n");
            sendTxt.setText("");
        }/*from w w w  .  j  av  a2s  .  co m*/
    } else if (command != null && command.startsWith("border-")) {
        for (int i = cardBorderMenu.getComponentCount(); i-- > 0;) {
            ((JRadioButtonMenuItem) cardBorderMenu.getComponent(i)).setSelected(false);
        }
        ((JRadioButtonMenuItem) obj).setSelected(true);
        CardFactory.updateColor(command.substring("border-".length()));
        CardFactory.updateAllCardsUI();
        magicForm.repaint();
    } else if ("menu_help_mailing".equals(command)) {
        try {
            WebBrowser.launchBrowser(
                    "http://lists.sourceforge.net/lists/listinfo/" + IdConst.PROJECT_NAME + "-user");
        } catch (Exception e1) {
            JOptionPane.showOptionDialog(this, LanguageManager.getString("error") + " : " + e1.getMessage(),
                    LanguageManager.getString("web-pb"), JOptionPane.OK_OPTION, JOptionPane.INFORMATION_MESSAGE,
                    UIHelper.getIcon("wiz_update_error.gif"), null, null);
        }
    } else if ("menu_options_settings".equals(command)) {
        // Setting panel
        final Wizard settingsPanel = new Settings();
        settingsPanel.setVisible(true);
    } else if ("menu_help_check-update".equals(command)) {
        VersionChecker.checkVersion(this);
    } else if ("menu_game_new_client".equals(command)) {
        new net.sf.firemox.ui.wizard.Client().setVisible(true);
    } else if ("menu_game_new_server".equals(command)) {
        new net.sf.firemox.ui.wizard.Server().setVisible(true);
    } else if ("menu_tools_log".equals(command)) {
        new net.sf.firemox.ui.wizard.Log().setVisible(true);
    } else if ("menu_tools_featurerequest".equals(command)) {
        new Feature().setVisible(true);
    } else if ("menu_tools_bugreport".equals(command)) {
        new Bug().setVisible(true);
    } else if ("menu_game_skip".equals(command)) {
        if (ConnectionManager.isConnected() && skipButton.isEnabled() && StackManager.idHandedPlayer == 0) {
            StackManager.noReplayToken.take();
            try {
                manualSkip();
            } catch (Throwable t) {
                t.printStackTrace();
            } finally {
                StackManager.noReplayToken.release();
            }
        }
    } else if ("menu_game_disconnect".equals(command)) {
        ConnectionManager.closeConnexions();
    } else if ("menu_tools_jdb".equals(command)) {
        DeckBuilder.loadFromMagic();
    } else if ("menu_game_exit".equals(command)) {
        exitForm(null);
    } else if (obj == autoManaMenu) {
        /*
         * invoked you click directly on the "auto-mana option" of the menu
         * "options". The opponent has to know that we are in "auto colorless mana
         * use", since player will no longer click on the mana icon to define
         * which colored mana active player has used as colorless mana, then the
         * opponent have not to wait for active player choice, but apply the same
         * Algorithm calculating which colored manas are used as colorless manas.
         * This information is not sent immediately, but will be sent with the
         * next action of active player.
         */
        MCommonVars.autoMana = autoManaMenu.isSelected();
    } else if (obj == autoPlayMenu) {
        /*
         * invoked you click directly on the "auto-play option" of the menu
         * "options".
         */
        MCommonVars.autoStack = autoPlayMenu.isSelected();
    } else if ("menu_tools_jcb".equals(command)) {
        // TODO cardBuilderMenu -> not yet implemented
        Log.info("cardBuilderMenu -> not yet implemented");
    } else if ("menu_game_proxy".equals(command)) {
        new ProxyConfiguration().setVisible(true);
    } else if ("menu_help_help".equals(command)) {
        /*
         * Invoked you click directly on youLabel. Opponent will receive this
         * information.
         */
        try {
            WebBrowser.launchBrowser("http://prdownloads.sourceforge.net/" + IdConst.PROJECT_NAME
                    + "/7e_rulebook_EN.pdf?download");
        } catch (Exception e1) {
            JOptionPane.showOptionDialog(this, LanguageManager.getString("error") + " : " + e1.getMessage(),
                    LanguageManager.getString("web-pb"), JOptionPane.OK_OPTION, JOptionPane.INFORMATION_MESSAGE,
                    UIHelper.getIcon("wiz_update_error.gif"), null, null);
        }
    } else if ("menu_help_about".equals(command)) {
        new About(this).setVisible(true);
    } else if ("menu_help_about.tbs".equals(command)) {
        new AboutMdb(this).setVisible(true);
    } else if (obj == reverseArtCheck || obj == reverseSideCheck) {
        Configuration.setProperty("reverseArt", reverseArtCheck.isSelected());
        Configuration.setProperty("reverseSide", reverseSideCheck.isSelected());
        ZoneManager.updateReversed();
        StackManager.PLAYERS[1].updateReversed();
        repaint();
        SwingUtilities.invokeLater(SkinLF.REFRESH_RUNNER);
    } else if (obj == soundMenu) {
        Configuration.setProperty("sound", soundMenu.isSelected());
        soundMenu.setIcon(
                soundMenu.isSelected() ? UIHelper.getIcon("sound.gif") : UIHelper.getIcon("soundoff.gif"));
    } else if ("menu_lf_randomAngle".equals(command)) {
        Configuration.setProperty("randomAngle", ((AbstractButton) e.getSource()).isSelected());
        CardFactory.updateAllCardsUI();
    } else if ("menu_lf_powerToughnessColor".equals(command)) {
        final Color powerToughnessColor = JColorChooser.showDialog(this,
                LanguageManager.getString("menu_lf_powerToughnessColor"), CardFactory.powerToughnessColor);
        if (powerToughnessColor != null) {
            Configuration.setProperty("powerToughnessColor", powerToughnessColor.getRGB());
            CardFactory.updateColor(null);
            repaint();
        }
    } else if (obj == initialdelayMenu) {
        // TODO factor this code with the one of Magic.class
        final ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
        new InputNumber(LanguageManager.getString("initialdelay"),
                LanguageManager.getString("initialdelay.tooltip"), 0, Integer.MAX_VALUE,
                toolTipManager.getInitialDelay()).setVisible(true);
        if (Wizard.optionAnswer == JOptionPane.YES_OPTION) {
            toolTipManager.setEnabled(Wizard.indexAnswer != 0);
            toolTipManager.setInitialDelay(Wizard.indexAnswer);
            initialdelayMenu.setText(LanguageManager.getString("initialdelay")
                    + (toolTipManager.isEnabled() ? " : " + Wizard.indexAnswer + " ms" : "(disabled)"));
            Configuration.setProperty("initialdelay", Wizard.indexAnswer);
        }
    } else if (obj == dismissdelayMenu) {
        // TODO factor this code with the one of Magic.class
        final ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
        new InputNumber(LanguageManager.getString("dismissdelay"),
                LanguageManager.getString("dismissdelay.tooltip"), 0, Integer.MAX_VALUE,
                toolTipManager.getDismissDelay()).setVisible(true);
        if (Wizard.optionAnswer == JOptionPane.YES_OPTION) {
            toolTipManager.setDismissDelay(Wizard.indexAnswer);
            Configuration.setProperty("dismissdelay", Wizard.indexAnswer);
            dismissdelayMenu.setText(LanguageManager.getString("dismissdelay") + Wizard.indexAnswer + " ms");
        }
    }

}

From source file:logdruid.ui.chart.GraphPanel.java

public void loadGroupCheckbox(final JPanel panel_2) {
    panel_1.removeAll();/*from w w w  .j a  va  2 s  . co  m*/
    //Iterator mineResultSetIterator = mineResultSet.mineResults.entrySet().iterator();

    Map<Source, Map<String, MineResult>> treeMap = new TreeMap<Source, Map<String, MineResult>>(
            mineResultSet.mineResults);
    Iterator mineResultSetIterator = treeMap.entrySet().iterator();

    logger.debug("mineResultSet size: " + mineResultSet.mineResults.size());
    while (mineResultSetIterator.hasNext()) {

        int groupCount = 0;
        int totalGroupCount = 0;
        Map.Entry pairs = (Map.Entry) mineResultSetIterator.next();
        Map mrArrayList = (Map<String, MineResult>) pairs.getValue();
        ArrayList<String> mineResultGroup = new ArrayList<String>();
        Set<String> mrss = mrArrayList.keySet();
        mineResultGroup.addAll(mrss);
        Collections.sort(mineResultGroup, new AlphanumComparator());

        Iterator mrArrayListIterator = mineResultGroup.iterator();
        while (mrArrayListIterator.hasNext()) {
            String key = (String) mrArrayListIterator.next();
            final MineResult mr = (MineResult) mrArrayList.get(key);
            Map<String, ExtendedTimeSeries> statMap = mr.getStatTimeseriesMap();
            Map<String, ExtendedTimeSeries> eventMap = mr.getEventTimeseriesMap();
            if (!statMap.entrySet().isEmpty() || !eventMap.entrySet().isEmpty()) {
                if (mr.getStartDate() != null && mr.getEndDate() != null) {
                    if ((mr.getStartDate().before((Date) endDateJSPinner.getValue()))
                            && (mr.getEndDate().after((Date) startDateJSpinner.getValue()))) {
                        groupCount++;
                    }
                }
            }
        }
        Iterator mrArrayListIterator2 = mineResultGroup.iterator();
        while (mrArrayListIterator2.hasNext()) {
            String key = (String) mrArrayListIterator2.next();
            final MineResult mr = (MineResult) mrArrayList.get(key);
            Map<String, ExtendedTimeSeries> statMap = mr.getStatTimeseriesMap();
            Map<String, ExtendedTimeSeries> eventMap = mr.getEventTimeseriesMap();
            if (!statMap.entrySet().isEmpty() || !eventMap.entrySet().isEmpty()) {
                if (mr.getStartDate() != null && mr.getEndDate() != null) {
                    if ((mr.getStartDate().before((Date) maximumDate))
                            && (mr.getEndDate().after((Date) minimumDate))) {
                        totalGroupCount++;
                    }
                }
            }
        }
        boolean selected = true;
        if (groupCheckBox.containsKey(((Source) pairs.getKey()).getSourceName())) {
            selected = groupCheckBox.get(((Source) pairs.getKey()).getSourceName());
        } else {
            groupCheckBox.put(((Source) pairs.getKey()).getSourceName(), selected);

        }

        JCheckBox chckbxGroup = new JCheckBox(
                ((Source) pairs.getKey()).getSourceName() + "(" + groupCount + "/" + totalGroupCount + ")");
        chckbxGroup.setFont(new Font("Dialog", Font.BOLD, 11));
        chckbxGroup.setSelected(selected);
        panel_1.add(chckbxGroup);
        chckbxGroup.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                JCheckBox chkBox = ((JCheckBox) e.getSource());
                groupCheckBox.put(
                        (String) chkBox.getText().substring(0, ((String) chkBox.getText()).indexOf("(")),
                        !groupCheckBox.get((String) chkBox.getText().substring(0,
                                ((String) chkBox.getText()).indexOf("("))));
                loadGroupCheckbox(panel_2);
                load(panel_2);
                //logger.info("checkBox:"+ chkBox.getText()+","+chkBox.isSelected()+","+groupCheckBox);
                //logger.info("checkBox2:"+((String)chkBox.getText())+", "+((String)chkBox.getText()).indexOf("(")+", "+groupCheckBox.get((String)chkBox.getText().substring(0, ((String)chkBox.getText()).indexOf("(")))); 
            }
        });
    }
}

From source file:com.view.TradeWindow.java

public void SelectBlockActionPerformed(ActionEvent e) {
    if (!((JCheckBox) e.getSource()).isSelected()) {
        TraderSelectAllBlocks.setSelected(false);
    }/*from  w w  w . j  av  a2 s .c  om*/
    int n = Integer.parseInt(((JComponent) e.getSource()).getName());
    PopulateBlocks(n);
}

From source file:gui.DownloadManagerGUI.java

@Override
public void actionPerformed(ActionEvent e) {
    JMenuItem clicked = (JMenuItem) e.getSource();

    if (clicked == exportDataItem) {
        //    addNewDownloadDialog.setVisible(true);
    } else if (clicked == importDataItem) {
        //    addNewDownloadDialog.setVisible(true);
    } else if (clicked == exitItem) {
        WindowListener[] listeners = getWindowListeners();
        for (WindowListener listener : listeners)
            listener.windowClosing(new WindowEvent(DownloadManagerGUI.this, 0));
    } else if (clicked == prefsItem) {
        preferenceDialog.setVisible(true);
    } else if (clicked == newDownloadItem) {
        addNewDownloadDialog.setVisible(true);
        addNewDownloadDialog.onPaste();/*w w  w. j ava2  s .c  o m*/
    } else if (clicked == openItem) {
        downloadPanel.actionOpenFile();
    } else if (clicked == openFolderItem) {
        downloadPanel.actionOpenFolder();
    } else if (clicked == resumeItem) {
        downloadPanel.actionResume();
    } else if (clicked == pauseItem) {
        downloadPanel.actionPause();
        mainToolbar.setStateOfButtonsControl(false, false, false, false, false, true); // canceled
    } else if (clicked == pauseAllItem) {
        int action = JOptionPane.showConfirmDialog(DownloadManagerGUI.this,
                "Do you realy want to pause all downloads?", "Confirm pause all", JOptionPane.OK_CANCEL_OPTION); ////***********
        if (action == JOptionPane.OK_OPTION) {
            downloadPanel.actionPauseAll();
        }
    } else if (clicked == clearItem) {
        downloadPanel.actionClear();
    } else if (clicked == clearAllCompletedItem) {
        downloadPanel.actionClearAllCompleted();
    } else if (clicked == reJoinItem) {
        downloadPanel.actionReJoinFileParts();
    } else if (clicked == reDownloadItem) {
        downloadPanel.actionReDownload();
    } else if (clicked == moveToQueueItem) {
        //        mainToolbarListener.preferencesEventOccured();
    } else if (clicked == removeFromQueueItem) {
        //        mainToolbarListener.preferencesEventOccured();
    } else if (clicked == propertiesItem) {
        downloadPanel.actionProperties();
    } else if (clicked == aboutItem) {
        if (!aboutDialog.isVisible())
            aboutDialog.setVisible(true);
    }
}

From source file:ToolBarDemo2.java

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    String description = null;/*from  w w  w . ja v a 2  s. c o m*/

    // Handle each button.
    if (PREVIOUS.equals(cmd)) { //first button clicked
        description = "taken you to the previous <something>.";
    } else if (UP.equals(cmd)) { // second button clicked
        description = "taken you up one level to <something>.";
    } else if (NEXT.equals(cmd)) { // third button clicked
        description = "taken you to the next <something>.";
    } else if (SOMETHING_ELSE.equals(cmd)) { // fourth button clicked
        description = "done something else.";
    } else if (TEXT_ENTERED.equals(cmd)) { // text field
        JTextField tf = (JTextField) e.getSource();
        String text = tf.getText();
        tf.setText("");
        description = "done something with this text: " + newline + "  \"" + text + "\"";
    }

    displayResult("If this were a real app, it would have " + description);
}

From source file:de.codesourcery.eve.skills.ui.components.impl.BlueprintBrowserComponent.java

@Override
public void actionPerformed(ActionEvent e) {

    final Object src = e.getSource();

    if (src == quantity) {
        final String q = quantity.getText();
        if (!isNumeric(q) || Integer.parseInt(q) < 1) {
            quantity.setText("1");
        }//from w  ww.  j  a  va 2s  .  c  o m
        // adjust quantity so that numberOfRuns = ( quantity / blueprint.portionSize) is an even number
        final double currentQuantity = Integer.parseInt(q);
        final int portionSize = getCurrentlySelectedBlueprint().getPortionSize();

        final int adjustedQuantity = (int) (Math.ceil(currentQuantity / portionSize) * portionSize);

        if (adjustedQuantity != currentQuantity) {
            quantity.setText(Integer.toString(adjustedQuantity));
        }

        refresh();
    } else if (src == selectedME) {
        final String me = selectedME.getText();
        if (!isNumeric(me)) {
            selectedME.setText("0");
        }
        refresh();
    } else if (src == selectedPE) {
        final String pe = selectedPE.getText();
        if (!isNumeric(pe)) {
            selectedPE.setText("0");
        }
        refresh();
    } else if (src == posButton || src == npcStationButton) {
        refresh();
    }
}

From source file:com.mightypocket.ashot.Mediator.java

void addDevice(final String deviceStr) {
    if (!devices.containsKey(deviceStr)) {
        try {//www. ja va2  s . co m
            SwingUtilities.invokeAndWait(new Runnable() {
                @Override
                public void run() {
                    JRadioButtonMenuItem item = new JRadioButtonMenuItem(deviceStr);
                    item.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            JRadioButtonMenuItem source = (JRadioButtonMenuItem) e.getSource();
                            String device = source.getText();
                            demon.connectTo(device);
                        }
                    });
                    devicesGroup.add(item);
                    devices.put(deviceStr, item);
                    menuFileDevices.add(item);
                    pcs.firePropertyChange(PROP_DEVICES, null, null);
                }
            });
        } catch (Exception ignore) {
        }
    }
}

From source file:st.jigasoft.dbutil.view.DUReport.java

private void btWindowsBtRigthActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btWindowsBtRigthActionPerformed
    this.closeAreaCommand((JButton) evt.getSource());
}