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:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java

/**
 * Performs actions when typing timer has expired.
 *
 * @param e the <tt>ActionEvent</tt> that notified us
 *//*from   ww  w.ja  v a2 s  .com*/
public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();

    if (typingTimer.equals(source)) {
        if (typingState == OperationSetTypingNotifications.STATE_TYPING) {
            chatPanel.getChatSession().getCurrentChatTransport()
                    .sendTypingNotification(OperationSetTypingNotifications.STATE_TYPING);
        }
    } else if (stoppedTypingTimer.equals(source)) {
        typingTimer.stop();
        if (typingState == OperationSetTypingNotifications.STATE_TYPING) {
            try {
                typingState = OperationSetTypingNotifications.STATE_PAUSED;

                int result = chatPanel.getChatSession().getCurrentChatTransport()
                        .sendTypingNotification(typingState);

                if (result == ChatPanel.TYPING_NOTIFICATION_SUCCESSFULLY_SENT)
                    stoppedTypingTimer.setDelay(3 * 1000);
            } catch (Exception ex) {
                logger.error("Failed to send typing notifications.", ex);
            }
        } else if (typingState == OperationSetTypingNotifications.STATE_PAUSED) {
            stopTypingTimer();
        }
    }
}

From source file:com.gele.tools.wow.wdbearmanager.WDBearManager.java

public void actionPerformed(ActionEvent arg0) {
    JMenuItem source = (JMenuItem) (arg0.getSource());

    if (source.getText().equals(MENU_ABOUT)) {
        JOptionPane.showMessageDialog(this, WDBearManager.VERSION_INFO + "\n" + "by kizura\n"
                + WDBearManager.EMAIL + "\n\n" + "\n" + "Supports any WDB version\n" + "\n" + "Thanks to:\n"
                + "DarkMan for testing,\n" + "John for the 1.10 specs, Annunaki for helping with the header,\n"
                + "Andrikos for the 1.6.x WDB specs, Pyro's WDBViewer, WDDG Forum,\n"
                + "blizzhackers, etc etc\n\n" + "This program uses: \n"
                + "JGoodies from http://www.jgoodies.com/\n" + "Hypersonic SQL database 1.7.3\n"
                + "Apache Log4J, Xerces\n" + "Jakarta Commons Logging and CLI\n" + "Castor from ExoLab\n"
                + "MySQL JDBC connector 3.1.7\n" + "HTTPUNIT from Russell Gold\n" + "Jython 2.1\n"
                + "Refer to directory 'licenses' for more details about the software used\n" + "PLEASE:\n"
                + "If you like this program and find it usefull:\n"
                + "Please donate money to a charity oranization of your choice.\n"
                + "I recommend any organization that fights cancer.\n\n" + "License:\n"
                + "WDBearMgr is placed under the GNU GPL. \n" + "For further information, see the page :\n"
                + "http://www.gnu.org/copyleft/gpl.html.\n" + "See licenses/GPL_license.html\n" + "\n"
                + "For a different license please contact the author.", "Info " + VERSION_INFO,
                JOptionPane.INFORMATION_MESSAGE);
        return;//from   w  w  w  .ja v  a  2s.  c o m
    } else if (source.getText().equals(MENU_HELP)) {
        JFrame myFrame = new JFrame("doc/html/index.html");
        //myFrame.setFont(   );
        URL urlHTML = null;
        try {
            JEditorPane htmlPane = new JEditorPane();
            //htmlPane.setFont(sourceFont);
            // .out.println("/scripts/"+source.getName()+".py");
            File scriptFile = new File("doc/html/index.html");
            urlHTML = scriptFile.toURL();//this.getClass().getResource("/scripts/"+source.getName()+".py");
            //          .out.println( urlHTML );
            //          .out.println( urlHTML.toExternalForm() );
            htmlPane.setPage(urlHTML);
            htmlPane.setEditable(false);
            JEPyperlinkListener myJEPHL = new JEPyperlinkListener(htmlPane);
            htmlPane.addHyperlinkListener(myJEPHL);
            myFrame.getContentPane().add(new JScrollPane(htmlPane));
            myFrame.pack();
            myFrame.setSize(640, 480);
            myFrame.show();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this,
                    VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n"
                            + "Could not open 'doc/html/index.html'",
                    "Warning " + VERSION_INFO, JOptionPane.WARNING_MESSAGE);
        }
    } else if (source.getText().equals(MENU_JDOCS)) {
        JFrame myFrame = new JFrame("doc/javadoc/index.html");
        //myFrame.setFont(   );
        URL urlHTML = null;
        try {
            JEditorPane htmlPane = new JEditorPane();
            //htmlPane.setFont(sourceFont);
            // .out.println("/scripts/"+source.getName()+".py");
            File scriptFile = new File("doc/javadoc/index.html");
            urlHTML = scriptFile.toURL();
            htmlPane.setPage(urlHTML);
            htmlPane.setEditable(false);
            JEPyperlinkListener myJEPHL = new JEPyperlinkListener(htmlPane);
            htmlPane.addHyperlinkListener(myJEPHL);
            myFrame.getContentPane().add(new JScrollPane(htmlPane));
            myFrame.pack();
            myFrame.setSize(640, 480);
            myFrame.show();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this,
                    VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n"
                            + "Could not open 'doc/javadoc/index.html'",
                    "Warning " + VERSION_INFO, JOptionPane.WARNING_MESSAGE);
        }
    } else if (source.getText().equals(MENU_CHECKUPDATE)) {
        Properties dbProps = null;
        String filName = PROPS_CHECK_UPDATE;
        try {
            dbProps = ReadPropertiesFile.readProperties(filName);
            String updFile = dbProps.getProperty(KEY_UPD_FILE);
            if (updFile == null) {
                JOptionPane.showMessageDialog(this,
                        VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n"
                                + "Could not find update information",
                        "Warning " + VERSION_INFO, JOptionPane.WARNING_MESSAGE);
                return;
            }
            String updSite = dbProps.getProperty(KEY_WDBMGR_SITE);
            if (updFile == null) {
                JOptionPane.showMessageDialog(this,
                        VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n"
                                + "Could not find SITE information",
                        "Warning " + VERSION_INFO, JOptionPane.WARNING_MESSAGE);
                return;
            }

            URL urlUpdScript = new URL(updFile);
            BufferedReader in = new BufferedReader(new InputStreamReader(urlUpdScript.openStream()));

            String versionTXT = in.readLine();
            String downloadName = in.readLine();
            in.close();

            if (versionTXT.equals(WDBearManager.VERSION_INFO)) {
                JOptionPane.showMessageDialog(this,
                        VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n"
                                + "You are using the latest version, no updates available",
                        "Info " + VERSION_INFO, JOptionPane.INFORMATION_MESSAGE);
                return;
            } else {
                // Read version.txt
                String versionInfo = (String) dbProps.getProperty(KEY_VERSION_INFO);
                URL urlversionInfo = new URL(versionInfo);
                BufferedReader brVInfo = new BufferedReader(new InputStreamReader(urlversionInfo.openStream()));
                StringBuffer sbuVInfo = new StringBuffer();
                String strLine = "";
                boolean foundStart = false;
                while ((strLine = brVInfo.readLine()) != null) {
                    if (strLine.startsWith("---")) {
                        break;
                    }
                    if (foundStart == true) {
                        sbuVInfo.append(strLine);
                        sbuVInfo.append("\n");
                        continue;
                    }
                    if (strLine.startsWith(versionTXT)) {
                        foundStart = true;
                        continue;
                    }
                }
                brVInfo.close();

                int n = JOptionPane.showConfirmDialog(this,
                        "New version available - Please visit " + updSite + "\n\n" + versionTXT + "\n" + "\n"
                                + "You are using version:\n" + WDBearManager.VERSION_INFO + "\n" + "\n"
                                + "Do you want to download this version?\n\n" + "Version information:\n"
                                + sbuVInfo.toString(),
                        VERSION_INFO + "by kizura", JOptionPane.YES_NO_OPTION);
                //          JOptionPane.showMessageDialog(this, VERSION_INFO + "\n"
                //              + "by kizura\n" + WDBManager.EMAIL + "\n\n"
                //              + "New version available - Please visit " + updSite,
                //              "Warning "
                //              + VERSION_INFO, JOptionPane.WARNING_MESSAGE);
                if (n == 0) {
                    JFileChooser chooser = new JFileChooser(new File("."));
                    chooser.setDialogTitle("Please select download location");
                    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

                    int returnVal = chooser.showOpenDialog(this);
                    if (returnVal == JFileChooser.APPROVE_OPTION) {
                        try {
                            URL urlUpd = new URL(downloadName);
                            BufferedInputStream bin = new BufferedInputStream(urlUpd.openStream());
                            System.out.println(
                                    new File(chooser.getSelectedFile(), urlUpd.getFile()).getAbsolutePath());
                            File thisFile = new File(chooser.getSelectedFile(), urlUpd.getFile());
                            BufferedOutputStream bout = new BufferedOutputStream(
                                    new FileOutputStream(thisFile));

                            byte[] bufFile = new byte[102400];
                            int bytesRead = 0;
                            while ((bytesRead = bin.read(bufFile)) != -1) {
                                bout.write(bufFile, 0, bytesRead);
                            }
                            bin.close();
                            bout.close();

                            JOptionPane.showMessageDialog(this,
                                    "Update downloaded successfully" + "\n" + "Please check '"
                                            + thisFile.getAbsolutePath() + "'",
                                    "Success " + WDBearManager.VERSION_INFO, JOptionPane.INFORMATION_MESSAGE);
                            //String msg = WriteCSV.writeCSV(chooser.getSelectedFile(), this.items);
                        } catch (Exception ex) {
                            String msg = ex.getMessage();
                            JOptionPane.showMessageDialog(this, msg + "\n" + "Error downloading update",
                                    "Error " + WDBearManager.VERSION_INFO, JOptionPane.ERROR_MESSAGE);
                        }
                    }
                } // user selected "download"
                return;
            }

        } catch (Exception ex) {
            ex.printStackTrace();
        }

    } else {
        System.exit(0);
    }

}

From source file:de.dmarcini.submatix.pclogger.gui.spx42LogGraphPanel.java

@Override
public void actionPerformed(ActionEvent ev) {
    String cmd = ev.getActionCommand();
    String entry = null;/*  w  w  w. j a va  2s.c o  m*/
    int dbId;
    String device;
    //
    // /////////////////////////////////////////////////////////////////////////
    // Button
    if (ev.getSource() instanceof JButton) {
        // JButton srcButton = ( JButton )ev.getSource();
        // /////////////////////////////////////////////////////////////////////////
        // Anzeigebutton?
        if (cmd.equals("show_log_graph")) {
            lg.debug("show log graph initiated.");
            // welches Device ?
            if (deviceComboBox.getSelectedIndex() < 0) {
                // kein Gert ausgewhlt
                lg.warn("no device selected.");
                return;
            }
            // welchen Tauchgang?
            if (diveSelectComboBox.getSelectedIndex() < 0) {
                lg.warn("no dive selected.");
                return;
            }
            device = ((DeviceComboBoxModel) deviceComboBox.getModel())
                    .getDeviceSerialAt(deviceComboBox.getSelectedIndex());
            dbId = ((LogListComboBoxModel) diveSelectComboBox.getModel())
                    .getDatabaseIdAt(diveSelectComboBox.getSelectedIndex());
            lg.debug("Select Device-Serial: " + device + ", DBID: " + dbId);
            if (dbId < 0) {
                lg.error("can't find database id for dive.");
                return;
            }
            makeGraphForLog(dbId, device);
            return;
        } else if (cmd.equals("set_detail_for_show_graph")) {
            lg.debug("select details for log selected.");
            SelectGraphDetailsDialog sgd = new SelectGraphDetailsDialog();
            if (sgd.showModal()) {
                lg.debug("dialog returned 'true' => change propertys...");
                computeGraphButton.doClick();
            }
        } else if (cmd.equals("edit_notes_for_dive")) {
            if (chartPanel == null || showingDbIdForDiveWasShowing == -1) {
                lg.warn("it was not showing a dive! do nothing!");
                return;
            }
            lg.debug("edit a note for this dive...");
            showNotesEditForm(showingDbIdForDiveWasShowing);
        } else {
            lg.warn("unknown button command <" + cmd + "> recived.");
        }
        return;
    }
    // /////////////////////////////////////////////////////////////////////////
    // Combobox
    else if (ev.getSource() instanceof JComboBox<?>) {
        @SuppressWarnings("unchecked")
        JComboBox<String> srcBox = (JComboBox<String>) ev.getSource();
        // /////////////////////////////////////////////////////////////////////////
        // Gert zur Grafischen Darstellung auswhlen
        if (cmd.equals("change_device_to_display")) {
            if (srcBox.getModel() instanceof DeviceComboBoxModel) {
                entry = ((DeviceComboBoxModel) srcBox.getModel()).getDeviceSerialAt(srcBox.getSelectedIndex());
                lg.debug("device <" + entry + ">...Index: <" + srcBox.getSelectedIndex() + ">");
                fillDiveComboBox(entry);
            }
        }
        // /////////////////////////////////////////////////////////////////////////
        // Dive zur Grafischen Darstellung auswhlen
        else if (cmd.equals("change_dive_to_display")) {
            entry = (String) srcBox.getSelectedItem();
            lg.debug("dive <" + entry + ">...Index: <" + srcBox.getSelectedIndex() + ">");
            // fillDiveComboBox( entry );
        } else {
            lg.warn("unknown combobox command <" + cmd + "> recived.");
        }
        return;
    } else {
        lg.warn("unknown action command <" + cmd + "> recived.");
    }
}

From source file:es.emergya.ui.gis.CustomMapView.java

public CustomMapView() {
    super();/*from   ww w.  j ava 2 s .c om*/
    menu = new MainMenu();
    contentPane.add(panel, BorderLayout.CENTER);

    // iniciar los controles mostrar/ocultar capas
    layerControls = new LinkedList<JToggleButton>();

    JToggleButton botonMostrarOcultarBotones = new JToggleButton(getI18n().getString("map.layers.hideButtons"),
            LogicConstants.getIcon("capas_button_mostrar"), false);
    botonMostrarOcultarBotones.setSelected(true);
    botonMostrarOcultarBotones.setActionCommand("#hide");
    // b.setVerticalTextPosition(SwingConstants.BOTTOM);
    // b.setHorizontalTextPosition(SwingConstants.CENTER);
    botonMostrarOcultarBotones.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JToggleButton b = (JToggleButton) e.getSource();
            if (e.getActionCommand().equals("#hide")) {
                layerControlPanel.removeAll();
                layerControlPanel.add(Box.createHorizontalStrut(10));
                layerControlPanel.add(b);
                b.setActionCommand("#show");
                b.setText(getI18n().getString("map.layers.showButtons"));
            } else {
                layerControlPanel.removeAll();
                layerControlPanel.add(Box.createHorizontalStrut(10));
                for (JToggleButton bt : layerControls) {
                    layerControlPanel.add(bt);
                    layerControlPanel.add(Box.createHorizontalGlue());
                }
                b.setActionCommand("#hide");
                b.setText(getI18n().getString("map.layers.hideButtons"));
            }
            layerControlPanel.updateUI();
        }
    });
    layerControls.add(botonMostrarOcultarBotones);

    final JToggleButton botonTodoasLasCapas = new JToggleButton(getI18n().getString("map.layers.allLayers"),
            LogicConstants.getIcon("capas_button_mostrar"), false);
    layerDialog = new LayerSelectionDialog(this);
    layerDialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            botonTodoasLasCapas.setSelected(false);
        }
    });
    botonTodoasLasCapas.setSelected(false);
    botonTodoasLasCapas.setActionCommand("#all");
    // all.setVerticalTextPosition(SwingConstants.BOTTOM);
    // all.setHorizontalTextPosition(SwingConstants.CENTER);
    botonTodoasLasCapas.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            layerDialog.setLocationRelativeTo((Component) e.getSource());
            layerDialog.setVisible(!layerDialog.isShowing());
        }
    });
    layerControls.add(botonTodoasLasCapas);

    layerControlPanel = new JPanel();
    layerControlPanel.setLayout(new BoxLayout(layerControlPanel, BoxLayout.X_AXIS));

    Main.main.menu = this.menu;
    toolbar = new ToolbarPreferences();
    toolbar.refreshToolbarControl();
    // toolbar.control.updateUI();
    // contentPane.add(toolbar.control, BorderLayout.NORTH);

    contentPane.updateUI();
    panel.updateUI();
}

From source file:TransformExplorer.java

JPanel configPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(0, 1));
    panel.add(new JLabel("Display annotation:"));

    // create the check boxes
    rotAxisCheckBox = new JCheckBox(rotAxisString);
    rotAxisCheckBox.setSelected(showRotAxis);
    rotAxisCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Object source = e.getSource();
            showRotAxis = ((JCheckBox) source).isSelected();
            if (showRotAxis) {
                rotAxis.setWhichChild(Switch.CHILD_ALL);
            } else {
                rotAxis.setWhichChild(Switch.CHILD_NONE);
            }/*www  .j a  v a2 s.  c om*/
        }
    });
    panel.add(rotAxisCheckBox);

    coordSysCheckBox = new JCheckBox(coordSysString);
    coordSysCheckBox.setSelected(showCoordSys);
    coordSysCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Object source = e.getSource();
            showCoordSys = ((JCheckBox) source).isSelected();
            if (showCoordSys) {
                coordSys.setWhichChild(Switch.CHILD_ALL);
            } else {
                coordSys.setWhichChild(Switch.CHILD_NONE);
            }
        }
    });
    panel.add(coordSysCheckBox);

    if (isApplication) {
        JButton snapButton = new JButton(snapImageString);
        snapButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Point loc = canvas.getLocationOnScreen();
                offScreenCanvas.setOffScreenLocation(loc);
                Dimension dim = canvas.getSize();
                dim.width *= offScreenScale;
                dim.height *= offScreenScale;
                nf.setMinimumIntegerDigits(3);
                nf.setMaximumFractionDigits(0);
                offScreenCanvas.snapImageFile(outFileBase + nf.format(outFileSeq++), dim.width, dim.height);
                nf.setMinimumIntegerDigits(0);
            }
        });
        panel.add(snapButton);
    }

    return panel;
}

From source file:SoundManagerTest.java

/**
 * Performs actions when a button is pressed.
 *///from  w  w w  .j a v  a2  s  .com
public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();
    AbstractButton button = (AbstractButton) e.getSource();
    if (command == EXIT) {
        midiPlayer.close();
        soundManager.close();
        stop();
    } else if (command == PAUSE) {
        // pause the sound
        soundManager.setPaused(button.isSelected());
        midiPlayer.setPaused(button.isSelected());
    } else if (command == PLAY_MUSIC) {
        // toggle music on or off
        if (button.isSelected()) {
            midiPlayer.play(music, true);
        } else {
            midiPlayer.stop();
        }
    } else if (command == MUSIC_DRUMS) {
        // toggle drums on or off
        Sequencer sequencer = midiPlayer.getSequencer();
        if (sequencer != null) {
            boolean mute = sequencer.getTrackMute(DRUM_TRACK);
            sequencer.setTrackMute(DRUM_TRACK, !mute);
        }
    } else if (command == PLAY_SOUND) {
        // play a normal sound
        soundManager.play(boop);
    } else if (command == PLAY_ECHO_SOUND) {
        // play a sound with an echo
        EchoFilter filter = new EchoFilter(11025, .6f);
        soundManager.play(boop, filter, false);
    } else if (command == PLAY_LOOPING_SOUND) {
        // play or stop the looping sound
        if (button.isSelected()) {
            lastloopingSound = soundManager.play(bzz, null, true);
        } else if (lastloopingSound != null) {
            try {
                lastloopingSound.close();
            } catch (IOException ex) {
            }
            lastloopingSound = null;
        }
    } else if (command == PLAY_MANY_SOUNDS) {
        // play several sounds at once, to test the system
        for (int i = 0; i < MANY_SOUNDS_COUNT; i++) {
            soundManager.play(boop);
        }
    }
}

From source file:edu.ku.brc.af.ui.db.TextFieldWithQuery.java

/**
 *
 * @param advanceFocus// w ww .  j  av a  2  s.  c  o m
 */
protected void showPopup(final int advanceFocus) {
    final Vector<Integer> idListClosure = (Vector<Integer>) idList.clone();
    if (!isEnabled()) {
        return;
    }

    if (hasNewText || currentText.length() == 0) {
        ActionListener al = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                itemSelected((JMenuItem) e.getSource(), advanceFocus, idListClosure);
            }
        };

        popupMenu = new JPopupMenu();
        if (popupMenuListener != null) {
            popupMenu.addPopupMenuListener(popupMenuListener);
        }

        popupMenu.addPopupMenuListener(new PopupMenuListener() {
            public void popupMenuCanceled(PopupMenuEvent e) {
                isPopupShowing = false;

                cachedPrevText = null;

                if (selectedId == null) {
                    setText(""); //$NON-NLS-1$
                }
            }

            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                isPopupShowing = false;

                cachedPrevText = prevEnteredText;

                if (selectedId == null) {
                    setText(""); //$NON-NLS-1$
                }
                //textField.requestFocus();
            }

            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                cachedPrevText = null;
                isPopupShowing = true;
            }
        });

        if (doAddAddItem) {
            JMenuItem mi = new JMenuItem(UIRegistry.getResourceString("TFWQ_ADD_LABEL")); //$NON-NLS-1$
            setControlSize(mi);

            popupMenu.add(mi);
            mi.addActionListener(al);
        }

        for (String str : list) {
            String label = str;
            if (uiFieldFormatter != null) {
                label = uiFieldFormatter.formatToUI(label).toString();
            }
            JMenuItem mi = new JMenuItem(label);
            setControlSize(mi);

            popupMenu.add(mi);
            mi.addActionListener(al);
        }
    }

    if (popupMenu != null) {
        if (list.size() > 0 || doAddAddItem) {
            UIHelper.addSpecialKeyListenerForPopup(popupMenu);

            final Point location = getLocation();
            final Dimension size = getSize();

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    popupMenu.setInvoker(TextFieldWithQuery.this);
                    popupMenu.show(TextFieldWithQuery.this, location.x, location.y + size.height);
                    Dimension popupSize = popupMenu.getPreferredSize();
                    popupMenu.setPopupSize(Math.max(size.width, popupSize.width), popupSize.height);
                    popupMenu.requestFocus();
                }
            });
        } else {
            popupMenu = null;
        }
    }

}

From source file:edu.ucla.stat.SOCR.applications.demo.BinomialTradingApplication.java

public void actionPerformed(ActionEvent evt) {
    /* Here we need the action listeners for all of the user-specified parameters in the COntrol-Panel
     * See init() method!!!//from w ww.  j  a  v  a 2 s . co m
     *       1.a Floating-point Text-Field for So = Price of the stock at time zero, So>=0.
     *       1.b Floating-Point Text-Field for EP = Exercise price (it is exercised at the end if price of stock at the end > EP), EP>=0.
     *       1.c Integer Slider for t = Time until expiration in years, 0<=t<=365.
     *       1.d Floating-Point Text-Field for r = Interest rate per year (0.000<=r).
     *       1.e Floating Point Text-Field for sigma = Annual volatility (0.000<=sigma).
     *       1.f Integer Slider for n = Number of periods that we divide the time to expiration (0<=n<=1000).
    */
    //System.out.println(evt.getActionCommand());

    if (evt.getSource() instanceof JComboBox) {
        JComboBox JCB = (JComboBox) evt.getSource();
        choice = (String) JCB.getSelectedItem();
        choice = choice.toLowerCase();
        chartPanel2.validate();
        inputPanel.validate();
    } else if (evt.getActionCommand().equals("S0")) {
        So = Double.parseDouble(inSo.getText());
    } else if (evt.getActionCommand().equals("EP")) {
        EP = Double.parseDouble(inEP.getText());
    } else if (evt.getActionCommand().equals("Sigma")) {
        sigma = Double.parseDouble(inSigma.getText());
    } else if (evt.getActionCommand().equals("Rate")) {
        rate = Double.parseDouble(inR.getText());
    }

    updateAllNodes();
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.DataImportDialog.java

public void actionPerformed(ActionEvent e) {
    JComboBox cb = (JComboBox) e.getSource();
    //Object source = e.g
    String str = (String) cb.getSelectedItem();
    log.debug("actionPerformed");
    if (str.equals("\"")) {
        stringQualifierChar = '\"';
        changeQualifier(str);//w w w . j av  a 2  s  .  c o  m
    } else if (str.equals("\'")) {
        stringQualifierChar = '\'';
        changeQualifier(str);
    } else if (str.equals("{" + getResourceString("NONE") + "}")) {
        changeQualifier(str);
    } else if (str.equals("US-ASCII") || str.equals("ISO-8859-1") || str.equals("UTF-8")) {
        charset = Charset.forName(str);
    } else if (str.equals(getResourceString("DEFAULT"))) {
        charset = Charset.defaultCharset();
    } else if (str.equals(getResourceString("BACKSLASH"))) {
        escapeMode = CsvReader.ESCAPE_MODE_BACKSLASH;
    } else if (str.equals(getResourceString("DOUBLED"))) {
        escapeMode = CsvReader.ESCAPE_MODE_DOUBLED;
    }
    updateTableDisplay();
}

From source file:edu.ucla.stat.SOCR.chart.demo.SOCR_EM_MixtureModelChartDemo.java

public void actionPerformed(ActionEvent event) {
    if (event.getSource() == addButton1) {
        addButtonDependent();/*from   ww  w . ja va 2s.  co m*/
        return;
    } else if (event.getSource() == removeButton1) {
        removeButtonDependent();
        return;
    } else if (event.getSource() == addButton2) {
        addButtonIndependent();
        return;
    } else if (event.getSource() == removeButton2) {
        removeButtonIndependent();
        return;
    }

    if (event.getSource() == stepJButton) {
        stop();
        for (int s = 0; s < num_series; s++) {
            mEMexperiment[s].EM(ws);
        }
    } else if (event.getSource() == runJButton) {
        stop();
        start();
        return;
    } else if (event.getSource() == stopJButton) {
        stop();
    } else if (event.getSource() == segmentJButton) {

        stop();
        if (mixSelected == GL_MIX)
            return;

        XYDataset[] ds1 = new XYDataset[num_series];
        for (int s = 0; s < num_series; s++)
            ds1[s] = mEMexperiment[s].getSegmentedPoints();
        //   resultsTable = mEMexperiment.getResultsTable();
        segment_flag = true;

        if (ds1 != null) {
            setTable(storage_ds);
            //if (redoTable)
            kernels = addKernels();
            chart = createChart(ds1);
            refreshChartPanel();
            setChart();
        }
        return;
    } else if (event.getSource() instanceof JComboBox) {
        JComboBox JCB = (JComboBox) event.getSource();
        String JCB_Value = (String) JCB.getSelectedItem();
        //  System.out.println("JCB_Value = " + JCB_Value);

        if (JCB_Value.indexOf("Together") != -1) {
            // System.out.println("GaussMix");
            modelAllSelected = TOGETHER;
            setEM();
            updateKernels();
        } else if (JCB_Value.indexOf("independently") != -1) {
            // System.out.println("GaussMix");
            modelAllSelected = SEPARATE;
            setEM();
            updateKernels();
        } else if (JCB_Value.equals("GaussMix")) {
            // System.out.println("GaussMix");
            setMixtureSelect(CG_MIX);
            updateKernels();
        } else if (JCB_Value.equals("LineMix")) {
            //  System.out.println("LinearMix");
            setMixtureSelect(GL_MIX);
            updateKernels();
        } else if (JCB_Value.equals("Fast")) {
            // System.out.println("Speed selected: Fast");
            setSpeed("Fast");
        } else if (JCB_Value.equals("Normal")) {
            // System.out.println("Speed selected: Normal");
            setSpeed("Normal");
        } else if (JCB_Value.equals("Slow")) {
            // System.out.println("Speed selected: Slow");
            setSpeed("Slow");
        } else // Number of Kernels
        {
            stop();
            nkSelected = Integer.parseInt(JCB_Value);
            for (int s = 0; s < num_series; s++) {
                mEMexperiment[s].setNumOfKernels(nkSelected);
            }
            updateKernels();
            if (EM_Thread != null)
                start();
        }
    } else if (event.getActionCommand().equals("ClearPts")) {
        resetMappingList();
        for (int s = 0; s < num_series; s++) {
            mEMexperiment[s].getDB().clearPoints();
            mEMexperiment[s].resetSize();
        }
    } else if (event.getActionCommand().equals("RandomPts")) {
        for (int s = 0; s < num_series; s++) {
            mEMexperiment[s].getDB().randomPoints(NUM_RANDOM_PTS);
            mEMexperiment[s].resetSize();
        }
        addRandomPts2Storage();
        //updateKernels();
        // System.out.println("ButtonRandomPts::DB.nPoints()=" + mEMexperiment.getDB().nPoints());
    } else if (event.getActionCommand().equals("InitKernels")) {
        updateKernels();
    } else if (event.getActionCommand().equals("AutoInitKernels")) {
        manualKernel = false;
        isPressingAlt = false;
        for (int s = 0; s < num_series; s++) {
            mEMexperiment[s].setManualKernel(false);
        }
        initControlPanel();
        this.getContentPane().add(toolContainer, BorderLayout.NORTH);
        updateKernels();
    } else if (event.getActionCommand().equals("RemoveLastKernel")) {
        removeLastManualKernel();

    }

    // System.out.println("Action performed : inde="+independentVarLength);
    redoChart(); // redotable
    //  System.out.println("Action performed after redoChart : inde="+independentVarLength);
    return;
}