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:de.dmarcini.submatix.pclogger.gui.MainCommGUI.java

/**
 * Bearbeitet Combobox actions Project: SubmatixBTConfigPC Package: de.dmarcini.submatix.pclogger.gui
 * /* w  w w. ja  v a 2 s  .c om*/
 * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 07.01.2012
 * @param ev
 *          Avtion event
 */
private void processComboBoxActions(ActionEvent ev) {
    String cmd = ev.getActionCommand();
    String entry = null;
    JComboBox<?> srcBox = (JComboBox<?>) ev.getSource();
    // /////////////////////////////////////////////////////////////////////////
    // Letzter Decostop auf 3 oder 6 Meter
    if (cmd.equals("deco_last_stop")) {
        entry = (String) srcBox.getSelectedItem();
        lg.debug("deco last stop <" + entry + ">...");
        currentConfig.setLastStop(srcBox.getSelectedIndex());
    }
    // /////////////////////////////////////////////////////////////////////////
    // Preset fr Deco-Gradienten ausgewhlt
    else if (cmd.equals("deco_gradient_preset")) {
        entry = (String) srcBox.getSelectedItem();
        lg.debug("gradient preset <" + entry + ">, Index: <" + srcBox.getSelectedIndex() + ">...");
        currentConfig.setDecoGfPreset(srcBox.getSelectedIndex());
        // Spinner setzen
        setGradientSpinnersAfterPreset(srcBox.getSelectedIndex());
    }
    // /////////////////////////////////////////////////////////////////////////
    // Autosetpoint Voreinstellung
    else if (cmd.equals("set_autosetpoint")) {
        entry = (String) srcBox.getSelectedItem();
        lg.debug("autosetpoint preset <" + entry + ">...");
        currentConfig.setAutoSetpoint(srcBox.getSelectedIndex());
    }
    // /////////////////////////////////////////////////////////////////////////
    // Setpoint fr hchsten PPO2 Wert einstellen
    else if (cmd.equals("set_highsetpoint")) {
        entry = (String) srcBox.getSelectedItem();
        lg.debug("hightsetpoint <" + entry + ">...");
        currentConfig.setMaxSetpoint(srcBox.getSelectedIndex());
    }
    // /////////////////////////////////////////////////////////////////////////
    // Helligkeit des Displays
    else if (cmd.equals("set_disp_brightness")) {
        entry = (String) srcBox.getSelectedItem();
        lg.debug("brightness <" + entry + ">...");
        currentConfig.setDisplayBrithtness(srcBox.getSelectedIndex());
    }
    // /////////////////////////////////////////////////////////////////////////
    // Ausrichtung des Displays
    else if (cmd.equals("set_display_orientation")) {
        entry = (String) srcBox.getSelectedItem();
        lg.debug("orientation <" + entry + ">...");
        currentConfig.setDisplayOrientation(srcBox.getSelectedIndex());
    }
    // /////////////////////////////////////////////////////////////////////////
    // Grad Celsius oder Fahrenheit einstellen
    else if (cmd.equals("set_temperature_unit")) {
        entry = (String) srcBox.getSelectedItem();
        lg.debug("temperature unit <" + entry + ">...");
        currentConfig.setUnitTemperature(srcBox.getSelectedIndex());
    }
    // /////////////////////////////////////////////////////////////////////////
    // Maeinheit fr Tiefe festlegen
    else if (cmd.equals("set_depth_unit")) {
        entry = (String) srcBox.getSelectedItem();
        lg.debug("depth unit <" + entry + ">...");
        currentConfig.setUnitDepth(srcBox.getSelectedIndex());
        configPanel.setUnitDepth(srcBox.getSelectedIndex());
    }
    // /////////////////////////////////////////////////////////////////////////
    // Swasser oder Salzwasser
    else if (cmd.equals("set_salnity")) {
        entry = (String) srcBox.getSelectedItem();
        lg.debug("salnity <" + entry + ">...");
        currentConfig.setUnitSalnyty(srcBox.getSelectedIndex());
    }
    // /////////////////////////////////////////////////////////////////////////
    // Loginterval einstellen
    else if (cmd.equals("set_loginterval")) {
        entry = (String) srcBox.getSelectedItem();
        lg.debug("loginterval <" + entry + ">...");
        currentConfig.setLogInterval(srcBox.getSelectedIndex());
    }
    // /////////////////////////////////////////////////////////////////////////
    // Anzahl der sensoren fr Messung/Warung einstellen
    else if (cmd.equals("set_sensorwarnings")) {
        entry = (String) srcBox.getSelectedItem();
        lg.debug("sensorwarnings <" + entry + ">...Index: <" + srcBox.getSelectedIndex() + ">");
        currentConfig.setSensorsCount(srcBox.getSelectedIndex());
    }
    // /////////////////////////////////////////////////////////////////////////
    // Temperatur Sensor Version umstellen
    else if (cmd.equals("set_tempstickversion")) {
        entry = (String) srcBox.getSelectedItem();
        lg.debug("tempstickversion <" + entry + ">...Index: <" + srcBox.getSelectedIndex() + ">");
        currentConfig.setTempStickVersion(srcBox.getSelectedIndex());
    } else {
        lg.warn("unknown combobox command <" + cmd + "> recived.");
    }
}

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

/**
 * /*from ww w .j a v a  2 s . c  o m*/
 * */
public void actionPerformed(ActionEvent event) {
    if (event.getActionCommand().equals(LEGENDON)) {
        turnLegendPanelOn();
    } else if (event.getActionCommand().equals(LEGENDOFF)) {
        turnLegendPanelOff();
    } else if (event.getSource() == addButton1) {
        addButtonDependent();
    } else if (event.getSource() == removeButton1) {
        removeButtonDependent();
    } else if (event.getSource() == addButton2) {
        addButtonIndependent();
    } else if (event.getSource() == removeButton2) {
        removeButtonIndependent();
    } else
        ;

}

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

/**
 * Bearbeitet Button Actions Project: SubmatixBTConfigPC Package: de.dmarcini.submatix.pclogger.gui
 * /*from   w ww. j  av a2 s  . c o  m*/
 * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 07.01.2012
 * @param ev
 *          Avtion event
 */
private void processButtonActions(ActionEvent ev) {
    String cmd = ev.getActionCommand();
    // /////////////////////////////////////////////////////////////////////////
    // lese Config aus Device
    if (cmd.equals("read_config")) {
        if (btComm != null) {
            if (btComm.isConnected()) {
                wDial = new PleaseWaitDialog(LangStrings.getString("PleaseWaitDialog.title"),
                        LangStrings.getString("PleaseWaitDialog.readSpxConfig"));
                wDial.setMax(BTCommunication.CONFIG_READ_KDO_COUNT);
                wDial.setVisible(true);
                wDial.setTimeout(90 * 1000);
                btComm.readConfigFromSPX42();
                // warte auf diese Nachricht....
                waitForMessage = ProjectConst.MESSAGE_SPXALIVE;
            } else {
                showWarnBox(LangStrings.getString("MainCommGUI.warnDialog.notConnected.text"));
            }
        }
    }
    // /////////////////////////////////////////////////////////////////////////
    // schreibe Config auf SPX42
    else if (cmd.equals("write_config")) {
        if (btComm != null) {
            if (!currentConfig.isInitialized() || savedConfig == null) {
                showWarnBox(LangStrings.getString("MainCommGUI.warnDialog.notConfig.text"));
                return;
            }
            writeConfigToSPX(savedConfig);
        }
    }
    // /////////////////////////////////////////////////////////////////////////
    // Alias editor zeigen
    else if (cmd.equals("alias_bt_devices_on")) {
        lg.info("alias editor show...");
        connectionPanel.setAliasesEditable(true);
    }
    // /////////////////////////////////////////////////////////////////////////
    // Alias editor zeigen
    else if (cmd.equals("alias_bt_devices_off")) {
        lg.info("alias editor hide...");
        connectionPanel.setAliasesEditable(false);
    }
    // /////////////////////////////////////////////////////////////////////////
    // ich will die Gasliste haben!
    else if (cmd.equals("read_gaslist")) {
        lg.info("call read gaslist from device...");
        if (btComm != null) {
            if (btComm.isConnected()) {
                wDial = new PleaseWaitDialog(LangStrings.getString("PleaseWaitDialog.title"),
                        LangStrings.getString("PleaseWaitDialog.readGaslist"));
                wDial.setMax(BTCommunication.CONFIG_READ_KDO_COUNT);
                wDial.setTimeout(90 * 1000);
                wDial.setVisible(true);
                btComm.readGaslistFromSPX42();
            } else {
                showWarnBox(LangStrings.getString("MainCommGUI.warnDialog.notConnected.text"));
            }
        }
    }
    // /////////////////////////////////////////////////////////////////////////
    // ich will die Gasliste schreiben!
    else if (cmd.equals("write_gaslist")) {
        lg.info("call write gaslist to device...");
        SPX42GasList currGasList = gasConfigPanel.getCurrGasList();
        if (currGasList == null) {
            lg.warn("Not gaslist in gaseditPanle created!");
            return;
        }
        if (btComm != null) {
            if (btComm.isConnected() && currGasList.isInitialized()) {
                wDial = new PleaseWaitDialog(LangStrings.getString("PleaseWaitDialog.title"),
                        LangStrings.getString("PleaseWaitDialog.writeGasList"));
                wDial.setMax(BTCommunication.CONFIG_READ_KDO_COUNT);
                wDial.setTimeout(90 * 1000);
                wDial.setVisible(true);
                btComm.writeGaslistToSPX42(currGasList, currentConfig.isOldParamSorting());
            } else {
                if (!btComm.isConnected()) {
                    showWarnBox(LangStrings.getString("MainCommGUI.warnDialog.notConnected.text"));
                } else {
                    showWarnBox(LangStrings.getString("MainCommGUI.warnDialog.gasNotLoaded.text"));
                }
            }
        }
    }
    // /////////////////////////////////////////////////////////////////////////
    // lese Logdir aus Device
    else if (cmd.equals("read_logdir_from_spx")) {
        if (btComm != null) {
            if (btComm.isConnected()) {
                if (logListPanel.prepareReadLogdir(btComm.getConnectedDevice())) {
                    // Die Liste direkt vom SPX einlesen!
                    // an dieser Stelle muss ich sicherstellen, da ich die Masseinheiten des SPX42 kenne
                    // ich gehe mal von den Lngeneinheiten aus!
                    // also Meter/Fuss
                    wDial = new PleaseWaitDialog(LangStrings.getString("PleaseWaitDialog.title"),
                            LangStrings.getString("PleaseWaitDialog.readLogDir"));
                    wDial.setTimeout(90 * 1000);
                    wDial.setVisible(true);
                    if (!currentConfig.isInitialized()) {
                        // jetzt wird es schwierig. erfrage erst mal die Config!
                        btComm.readConfigFromSPX42();
                    }
                    // Sag dem SPX er soll alles schicken
                    btComm.readLogDirectoryFromSPX();
                }
            } else {
                showWarnBox(LangStrings.getString("MainCommGUI.warnDialog.notConnected.text"));
            }
        }
    }
    // /////////////////////////////////////////////////////////////////////////
    // lese Logfile aus Device
    else if (cmd.equals("read_logfile_from_spx")) {
        if (btComm != null) {
            if (btComm.isConnected()) {
                int logListLen = logListPanel.prepareDownloadLogdata(btComm.getConnectedDevice());
                if (logListLen == 0) {
                    showWarnBox(LangStrings.getString("MainCommGUI.warnDialog.notLogentrySelected.text"));
                    return;
                }
                if (!currentConfig.isInitialized()) {
                    showWarnBox(LangStrings.getString("MainCommGUI.warnDialog.notConfig.text"));
                    return;
                }
                Integer[] logListEntry = logListPanel.getNextEntryToRead();
                if (logListEntry != null) {
                    computeLogRequest(logListEntry);
                }
            } else {
                showWarnBox(LangStrings.getString("MainCommGUI.warnDialog.notConnected.text"));
            }
        }
    }
    // /////////////////////////////////////////////////////////////////////////
    // Virtual Coms neu einlesen
    else if (cmd.equals("renew_virt_buttons")) {
        connectionPanel.setVirtDevicesBoxEnabled(false);
        startVirtualPortFinder(null);
    }
    // /////////////////////////////////////////////////////////////////////////
    // Da hab ich nix passendes gefunden!
    else {
        lg.warn("unknown button command <" + cmd + "> recived.");
    }
    return;
}

From source file:JDAC.JDAC.java

public JDAC() {
    setTitle("JDAC");

    ImageIcon img = new ImageIcon("logo.png");
    setIconImage(img.getImage());/*from www .  j  a  v  a2s .  co m*/

    //setLayout(new FlowLayout());

    mDataset = createDataset("A");

    mChart = ChartFactory.createXYLineChart("Preview", "Time (ms)", "Value", mDataset, PlotOrientation.VERTICAL,
            false, true, false);

    mLastChart = ChartFactory.createXYLineChart("Last n values", "Time (ms)", "Value", createLastDataset("B"),
            PlotOrientation.VERTICAL, false, true, false);
    mChart.getXYPlot().getDomainAxis().setLowerMargin(0);
    mChart.getXYPlot().getDomainAxis().setUpperMargin(0);
    mLastChart.getXYPlot().getDomainAxis().setLowerMargin(0);
    mLastChart.getXYPlot().getDomainAxis().setUpperMargin(0);

    ChartPanel chartPanel = new ChartPanel(mChart);
    ChartPanel chartLastPanel = new ChartPanel(mLastChart);
    //chartPanel.setPreferredSize( new java.awt.Dimension( 560 , 367 ) );

    XYPlot plot = mChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.GREEN);
    renderer.setSeriesStroke(0, new BasicStroke(1.0f));
    plot.setRenderer(renderer);

    XYPlot lastPlot = mLastChart.getXYPlot();
    XYLineAndShapeRenderer lastRenderer = new XYLineAndShapeRenderer();
    lastRenderer.setSeriesPaint(0, Color.RED);
    lastRenderer.setSeriesStroke(0, new BasicStroke(1.0f));
    lastPlot.setRenderer(lastRenderer);

    resetChartButton = new JButton("Reset");
    resetChartButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            resetChart();
        }
    });

    mMenuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    JMenu sensorMenu = new JMenu("Sensor");
    JMenu deviceMenu = new JMenu("Device");
    portSubMenu = new JMenu("Port");
    JMenu helpMenu = new JMenu("Help");

    serialStatusLabel = new JLabel("Disconnected");
    statusLabel = new JLabel("Ready");
    clearStatus = new LabelClear(statusLabel);
    clearStatus.resetTime();

    connectButton = new JMenuItem("Connect");
    disconnectButton = new JMenuItem("Disconnect");
    startButton = new JButton("Start");
    stopButton = new JButton("Stop");
    scanButton = new JMenuItem("Refresh port list");
    exportCSVButton = new JMenuItem("Export data to CSV");
    exportCSVButton.setAccelerator(KeyStroke.getKeyStroke("control S"));
    exportCSVButton.setMnemonic(KeyEvent.VK_S);
    exportPNGButton = new JMenuItem("Export chart to PNG");

    JPanel optionsPanel = new JPanel(new BorderLayout());

    JMenuItem exitItem = new JMenuItem("Exit");
    exitItem.setAccelerator(KeyStroke.getKeyStroke("control X"));
    exitItem.setMnemonic(KeyEvent.VK_X);

    JMenuItem aboutItem = new JMenuItem("About");
    JMenuItem helpItem = new JMenuItem("Help");
    JMenuItem quickStartItem = new JMenuItem("Quick start");

    lastSpinner = new JSpinner(new SpinnerNumberModel(10, 0, 1000, 1));

    ActionListener mSensorListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setSensor(e.getActionCommand());
        }
    };
    ButtonGroup sensorGroup = new ButtonGroup();
    JRadioButtonMenuItem tmpRadioButton = new JRadioButtonMenuItem("Temperature");
    sensorGroup.add(tmpRadioButton);
    sensorMenu.add(tmpRadioButton);
    tmpRadioButton.addActionListener(mSensorListener);
    tmpRadioButton = new JRadioButtonMenuItem("Distance");
    sensorGroup.add(tmpRadioButton);
    sensorMenu.add(tmpRadioButton);
    tmpRadioButton.addActionListener(mSensorListener);
    tmpRadioButton = new JRadioButtonMenuItem("Voltage");
    sensorGroup.add(tmpRadioButton);
    sensorMenu.add(tmpRadioButton);
    tmpRadioButton.addActionListener(mSensorListener);
    tmpRadioButton = new JRadioButtonMenuItem("Generic");
    tmpRadioButton.setSelected(true);
    setSensor("Generic");
    sensorGroup.add(tmpRadioButton);
    sensorMenu.add(tmpRadioButton);
    tmpRadioButton.addActionListener(mSensorListener);

    connectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (selectedPortName == null) {
                setStatus("No port selected");
                return;
            }
            connect(selectedPortName);
        }
    });
    disconnectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            serialStatusLabel.setText("Disconnecting...");
            if (serialPort == null) {
                serialStatusLabel.setText("Disconnected");
                serialConnected = false;
                return;
            }

            stopCollect();
            disconnect();
        }
    });
    scanButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            searchForPorts();
        }
    });
    exportCSVButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            saveData();
        }
    });
    exportPNGButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            exportPNG();
        }
    });
    startButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            startCollect();
        }
    });
    stopButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            stopCollect();
        }
    });
    lastSpinner.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            numLastValues = (Integer) lastSpinner.getValue();
            updateLastTitle();
        }
    });
    updateLastTitle();
    exitItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    helpItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            new HelpFrame();
        }
    });
    aboutItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            new AboutFrame();
        }
    });
    quickStartItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            new StartFrame();
        }
    });

    fileMenu.add(exportCSVButton);
    fileMenu.add(exportPNGButton);
    fileMenu.addSeparator();
    fileMenu.add(exitItem);
    deviceMenu.add(connectButton);
    deviceMenu.add(disconnectButton);
    deviceMenu.addSeparator();
    deviceMenu.add(portSubMenu);
    deviceMenu.add(scanButton);
    helpMenu.add(quickStartItem);
    helpMenu.add(helpItem);
    helpMenu.add(aboutItem);

    mMenuBar.add(fileMenu);
    mMenuBar.add(sensorMenu);
    mMenuBar.add(deviceMenu);
    mMenuBar.add(helpMenu);

    JPanel controlsPanel = new JPanel();
    controlsPanel.add(startButton);
    controlsPanel.add(stopButton);
    controlsPanel.add(resetChartButton);
    optionsPanel.add(controlsPanel, BorderLayout.LINE_START);

    JPanel lastPanel = new JPanel(new FlowLayout());
    lastPanel.add(new JLabel("Shown values: "));
    lastPanel.add(lastSpinner);
    optionsPanel.add(lastPanel);

    JPanel serialPanel = new JPanel(new FlowLayout());
    serialPanel.add(serialStatusLabel);
    optionsPanel.add(serialPanel, BorderLayout.LINE_END);

    add(optionsPanel, BorderLayout.PAGE_START);

    JPanel mainPanel = new JPanel(new GridLayout(0, 2));
    mainPanel.add(chartPanel);
    mainPanel.add(chartLastPanel);
    add(mainPanel);

    add(statusLabel, BorderLayout.PAGE_END);
    setJMenuBar(mMenuBar);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent we) {
            dispose();
        }
    });

    setSize(800, 800);
    pack();
    new StartFrame();

    //center on screen
    Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (int) ((dimension.getWidth() - getWidth()) / 2);
    int y = (int) ((dimension.getHeight() - getHeight()) / 2);
    setLocation(x, y);

    setVisible(true);
}

From source file:org.rdv.viz.chart.ChartPanel.java

/**
 * Handles action events generated by the popup menu.
 *
 * @param event  the event.//from  w ww  .jav  a 2 s.  c  o  m
 */
public void actionPerformed(ActionEvent event) {

    String command = event.getActionCommand();

    // many of the zoom methods need a screen location - all we have is
    // the zoomPoint, but it might be null.  Here we grab the x and y
    // coordinates, or use defaults...
    double screenX = -1.0;
    double screenY = -1.0;
    if (this.zoomPoint != null) {
        screenX = this.zoomPoint.getX();
        screenY = this.zoomPoint.getY();
    }

    if (command.equals(PROPERTIES_COMMAND)) {
        doEditChartProperties();
    } else if (command.equals(SAVE_COMMAND)) {
        try {
            doSaveAs();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else if (command.equals(PRINT_COMMAND)) {
        createChartPrintJob();
    } else if (command.equals(ZOOM_IN_BOTH_COMMAND)) {
        zoomInBoth(screenX, screenY);
    } else if (command.equals(ZOOM_IN_DOMAIN_COMMAND)) {
        zoomInDomain(screenX, screenY);
    } else if (command.equals(ZOOM_IN_RANGE_COMMAND)) {
        zoomInRange(screenX, screenY);
    } else if (command.equals(ZOOM_OUT_BOTH_COMMAND)) {
        zoomOutBoth(screenX, screenY);
    } else if (command.equals(ZOOM_OUT_DOMAIN_COMMAND)) {
        zoomOutDomain(screenX, screenY);
    } else if (command.equals(ZOOM_OUT_RANGE_COMMAND)) {
        zoomOutRange(screenX, screenY);
    } else if (command.equals(ZOOM_RESET_BOTH_COMMAND)) {
        restoreAutoBounds();
    } else if (command.equals(ZOOM_RESET_DOMAIN_COMMAND)) {
        restoreAutoDomainBounds();
    } else if (command.equals(ZOOM_RESET_RANGE_COMMAND)) {
        restoreAutoRangeBounds();
    }

}

From source file:Unicode.java

/** Construct the object including its GUI */
public Unicode() {
    super("Unicode");

    Container cp = getContentPane();

    // Used both for Buttons and Menus
    ResourceBundle b = ResourceBundle.getBundle("UnicodeWidgets");

    JButton quitButton, nextButton, prevButton;
    Panel p = new Panel();
    // Make a grid, add one for labels.
    p.setLayout(new GridLayout(ROWS + 1, COLUMNS + 1));
    DecimalFormat df2d = new DecimalFormat("00");

    // Add first row, just column labels.
    p.add(new JLabel(""));
    for (int i = 0; i < COLUMNS; i++)
        p.add(new JLabel(Integer.toString(i, 16), JLabel.CENTER));

    // Add subsequent rows, each with an offset label
    for (int i = 0; i < ROWS; i++) {
        JLabel l = new JLabel("0000"); // room for max, i.e. \uFFFF
        p.add(l);/*from  w ww. j av a  2 s.c  o m*/
        rowLabs[i] = l;
        for (int j = 0; j < COLUMNS; j++) {
            JLabel pb = new JLabel(" ");
            buttons[j][i] = pb;
            p.add(pb);
        }
    }

    // ActionListeners for jumping around; used by buttons and menus
    ActionListener firster = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            gotoPage(startNum = 0);
        }
    };
    ActionListener previouser = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (startNum > 0)
                gotoPage(startNum -= QUADSIZE);
        }
    };
    ActionListener nexter = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (startNum < 65535)
                gotoPage(startNum += QUADSIZE);
        }
    };
    ActionListener laster = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            gotoPage(65536 - QUADSIZE);
        }
    };

    cp.add(BorderLayout.NORTH, p);
    fontName = new JLabel("Default font", JLabel.CENTER);
    cp.add(BorderLayout.CENTER, fontName);
    Panel q = new Panel();
    cp.add(BorderLayout.SOUTH, q);
    q.add(prevButton = mkButton(b, "page.prev"));
    prevButton.addActionListener(previouser);

    q.add(nextButton = mkButton(b, "page.next"));
    nextButton.addActionListener(nexter);

    q.add(quitButton = mkButton(b, "exit"));
    quitButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
            dispose();
            System.exit(0);
        }
    });
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            setVisible(false);
            dispose();
            System.exit(0);
        }
    });

    MenuItem mi; // used in various spots

    MenuBar mb = new MenuBar();
    setMenuBar(mb);

    String titlebar;
    try {
        titlebar = b.getString("program" + ".title");
    } catch (MissingResourceException e) {
        titlebar = "Unicode Demo";
    }
    setTitle(titlebar);

    ActionListener fontSelector = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String font = e.getActionCommand();
            mySetFont(font, FONTSIZE);
        }
    };

    Menu fontMenu = mkMenu(b, "font");
    // String[] fontList = Toolkit.getDefaultToolkit().getFontList();
    String[] fontList = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
    for (int i = 0; i < fontList.length; i++) {
        fontMenu.add(mi = new MenuItem(fontList[i]));
        mi.addActionListener(fontSelector);
    }
    mb.add(fontMenu);

    gotoPageUI = new GoToPage("Unicode Page");
    centre(gotoPageUI);

    Menu vm = mkMenu(b, "page");
    vm.add(mi = mkMenuItem(b, "page", "first"));
    mi.addActionListener(firster);
    vm.add(mi = mkMenuItem(b, "page", "prev"));
    mi.addActionListener(previouser);
    vm.add(mi = mkMenuItem(b, "page", "next"));
    mi.addActionListener(nexter);
    vm.add(mi = mkMenuItem(b, "page", "last"));
    mi.addActionListener(laster);
    vm.add(mi = mkMenuItem(b, "page", "goto"));
    mi.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Unicode.this.gotoPageUI.setVisible(true);
        }
    });
    mb.add(vm);

    Menu hm = mkMenu(b, "help");
    hm.add(mi = mkMenuItem(b, "help", "about"));
    mb.setHelpMenu(hm); // needed for portability (Motif, etc.).

    pack();
    // After packing the Frame, centre it on the screen.
    centre(this);

    // start at a known place
    mySetFont(fontList[0], FONTSIZE);
    gotoPage(startNum);
}

From source file:AppearanceTest.java

public void actionPerformed(ActionEvent event) {
    // (primitive) menu command dispatch
    Class classObject = getClass();

    Method[] methodArray = classObject.getMethods();

    for (int n = methodArray.length - 1; n >= 0; n--) {
        if (("on" + event.getActionCommand()).equals(methodArray[n].getName())) {
            try {
                methodArray[n].invoke(this, null);
            } catch (InvocationTargetException ie) {
                System.err.println("Warning. Menu handler threw exception: " + ie.getTargetException());
            } catch (Exception e) {
                System.err.println("Warning. Menu dispatch exception: " + e);
            }/*  w w  w.j av a  2  s  . co m*/

            return;
        }
    }
}

From source file:com.att.aro.diagnostics.GraphPanel.java

/**
 * This method is invoked when an ActionEvent occurs in the GraphPanel.
 *//*www.  j  a  v  a 2s. c o  m*/
public void actionPerformed(ActionEvent e) {
    if (SAVE_AS_ACTION.equals(e.getActionCommand())) {
        try {
            saveAs();
        } catch (IOException e1) {
            JOptionPane.showMessageDialog(this, rb.getString("chart.saveError"));
            logger.fine("An error occurred trying to save the chart: " + e1.getMessage());
        }
    } else if (ZOOM_IN_ACTION.equals(e.getActionCommand())) {
        zoomIn();
    } else if (ZOOM_OUT_ACTION.equals(e.getActionCommand())) {
        zoomOut();
    } else if (REFRESH_AS_ACTION.equals(e.getActionCommand())) { //Greg Story

        refreshGraph();
    }
}

From source file:edu.harvard.i2b2.query.ui.GroupPanel.java

public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equalsIgnoreCase("Constrain Item ...")) {
        // JOptionPane.showMessageDialog(this, "Constrain Item ...");
        // DefaultMutableTreeNode node = (DefaultMutableTreeNode)
        // jTree1.getSelectionPath().getLastPathComponent();
        // QueryConceptTreeNodeData ndata = (QueryConceptTreeNodeData)
        // node.getUserObject();
        // final QueryConstrainFrame cframe = new
        // QueryConstrainFrame(ndata);
        // cframe.setTitle("Constrain Item: "+ndata.name());
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                // cframe.setVisible(true);
            }//  w ww  .ja  v  a  2 s  .c o  m
        });
    } else if (e.getActionCommand().equalsIgnoreCase("Delete Item")) {
        // JOptionPane.showMessageDialog(this, "Delete Item");
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        treeModel.removeNodeFromParent(node);
        data().getItems().remove(node.getUserObject());
    } else if (e.getActionCommand().equalsIgnoreCase("Set Value ...")) {
        final DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath()
                .getLastPathComponent();
        final QueryConceptTreeNodeData ndata = (QueryConceptTreeNodeData) node.getUserObject();
        final GroupPanel parent = this;

        int index = data().getItems().indexOf(node.getUserObject());
        currentData = data().getItems().get(index);

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                if (ndata.valuePropertyData().hasEnumValue()) {
                    EnumValueConstraintFrame vDialog = new EnumValueConstraintFrame(parent);
                    vDialog.setSize(410, 330);
                    //StringValueConstraintFrame vDialog = new StringValueConstraintFrame(
                    //parent);
                    //vDialog.setSize(380, 250);
                    vDialog.setLocation(300, 300);
                    vDialog.setTitle("Choose value of " + ndata.titleName());
                    vDialog.setVisible(true);
                } else if (ndata.valuePropertyData().hasStringValue()) {
                    StringValueConstraintFrame vDialog = new StringValueConstraintFrame(parent);
                    vDialog.setSize(380, 250);
                    vDialog.setLocation(300, 300);
                    vDialog.setTitle("Search within the " + ndata.titleName());
                    vDialog.setVisible(true);
                } else {
                    NumericValueConstraintFrame vDialog = new NumericValueConstraintFrame(parent);
                    vDialog.setSize(410, 215);
                    vDialog.setLocation(300, 300);
                    vDialog.setTitle("Choose value of " + ndata.titleName());
                    vDialog.setVisible(true);
                }
            }
        });
    } else if (e.getActionCommand().equalsIgnoreCase("Set Modifier Value ...")) {
        /*final DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1
              .getSelectionPath().getLastPathComponent();
        final QueryConceptTreeNodeData ndata = (QueryConceptTreeNodeData) node
              .getUserObject();
        final GroupPanel parent = this;
                
        int index = data().getItems().indexOf(node.getUserObject());
        currentData = data().getItems().get(index);
                
        java.awt.EventQueue.invokeLater(new Runnable() {
           public void run() {
              //if (ndata.valuePropertyData().hasEnumValue()) {
          ModifierFrame vDialog = new ModifierFrame();
          vDialog.setSize(200, 410);
          vDialog.setLocation(300, 300);
          //vDialog
                //.setTitle("Choose value of "
                      //+ ndata.titleName());
          vDialog.setVisible(true);
                      
           }
        });*/
        final DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath()
                .getLastPathComponent();
        final ModifierData ndata = (ModifierData) node.getUserObject();
        final GroupPanel parent = this;

        int index = data().getItems().indexOf(node.getUserObject());
        currentData = data().getItems().get(index);

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                if (ndata.modifierValuePropertyData().hasEnumValue()) {
                    ModifierEnumValueConstraintFrame vDialog = new ModifierEnumValueConstraintFrame(parent);
                    vDialog.setSize(410, 330);
                    //ModifierStringValueConstraintFrame vDialog = new ModifierStringValueConstraintFrame(
                    //      parent);
                    //vDialog.setSize(380, 250);  ////410, 330);
                    vDialog.setLocation(300, 300);
                    vDialog.setTitle("Choose modifier value of " + ndata.titleName());
                    vDialog.setVisible(true);
                } else if (ndata.modifierValuePropertyData().hasStringValue()) {
                    ModifierStringValueConstraintFrame vDialog = new ModifierStringValueConstraintFrame(parent);
                    vDialog.setSize(380, 250);
                    vDialog.setLocation(300, 300);
                    vDialog.setTitle("Choose modifier value of " + ndata.titleName());
                    vDialog.setVisible(true);
                } else {
                    ModifierNumericValueConstraintFrame vDialog = new ModifierNumericValueConstraintFrame(
                            parent);
                    vDialog.setSize(410, 215);
                    vDialog.setLocation(300, 300);
                    vDialog.setTitle("Choose modifier value of " + ndata.titleName());
                    vDialog.setVisible(true);
                }
            }
        });
    }
}