List of usage examples for java.awt.event ActionEvent getActionCommand
public String getActionCommand()
From source file:com.floreantpos.config.ui.DatabaseConfigurationDialog.java
public void actionPerformed(ActionEvent e) { try {//w w w . j av a 2 s .co m String command = e.getActionCommand(); Database selectedDb = (Database) databaseCombo.getSelectedItem(); final String providerName = selectedDb.getProviderName(); final String databaseURL = tfServerAddress.getText(); final String databasePort = tfServerPort.getText(); final String databaseName = tfDatabaseName.getText(); final String user = tfUserName.getText(); final String pass = new String(tfPassword.getPassword()); final String connectionString = selectedDb.getConnectString(databaseURL, databasePort, databaseName); final String hibernateDialect = selectedDb.getHibernateDialect(); final String driverClass = selectedDb.getHibernateConnectionDriverClass(); if (CANCEL.equalsIgnoreCase(command)) { dispose(); return; } setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); Application.getInstance().setSystemInitialized(false); saveConfig(selectedDb, providerName, databaseURL, databasePort, databaseName, user, pass, connectionString, hibernateDialect); if (TEST.equalsIgnoreCase(command)) { try { DatabaseUtil.checkConnection(connectionString, hibernateDialect, driverClass, user, pass); } catch (DatabaseConnectionException e1) { JOptionPane.showMessageDialog(this, Messages.getString("DatabaseConfigurationDialog.32")); //$NON-NLS-1$ return; } connectionSuccess = true; JOptionPane.showMessageDialog(this, Messages.getString("DatabaseConfigurationDialog.31")); //$NON-NLS-1$ } else if (UPDATE_DATABASE.equals(command)) { int i = JOptionPane.showConfirmDialog(this, Messages.getString("DatabaseConfigurationDialog.0"), //$NON-NLS-1$ Messages.getString("DatabaseConfigurationDialog.1"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$ if (i != JOptionPane.YES_OPTION) { return; } //isAuthorizedToPerformDbChange(); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); boolean databaseUpdated = DatabaseUtil.updateDatabase(connectionString, hibernateDialect, driverClass, user, pass); if (databaseUpdated) { connectionSuccess = true; JOptionPane.showMessageDialog(DatabaseConfigurationDialog.this, Messages.getString("DatabaseConfigurationDialog.2")); //$NON-NLS-1$ } else { JOptionPane.showMessageDialog(DatabaseConfigurationDialog.this, Messages.getString("DatabaseConfigurationDialog.3")); //$NON-NLS-1$ } } else if (CREATE_DATABASE.equals(command)) { int i = JOptionPane.showConfirmDialog(this, Messages.getString("DatabaseConfigurationDialog.33"), //$NON-NLS-1$ Messages.getString("DatabaseConfigurationDialog.34"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$ if (i != JOptionPane.YES_OPTION) { return; } i = JOptionPane.showConfirmDialog(this, Messages.getString("DatabaseConfigurationDialog.4"), //$NON-NLS-1$ Messages.getString("DatabaseConfigurationDialog.5"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$ boolean generateSampleData = false; if (i == JOptionPane.YES_OPTION) generateSampleData = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); String createDbConnectString = selectedDb.getCreateDbConnectString(databaseURL, databasePort, databaseName); boolean databaseCreated = DatabaseUtil.createDatabase(createDbConnectString, hibernateDialect, driverClass, user, pass, generateSampleData); if (databaseCreated) { JOptionPane.showMessageDialog(DatabaseConfigurationDialog.this, Messages.getString("DatabaseConfigurationDialog.6") + //$NON-NLS-1$ Messages.getString("DatabaseConfigurationDialog.7")); //$NON-NLS-1$ Main.restart(); connectionSuccess = true; } else { JOptionPane.showMessageDialog(DatabaseConfigurationDialog.this, Messages.getString("DatabaseConfigurationDialog.36")); //$NON-NLS-1$ } } else if (SAVE.equalsIgnoreCase(command)) { if (connectionSuccess) { Application.getInstance().initializeSystem(); } dispose(); } } catch (Exception e2) { PosLog.error(getClass(), e2); POSMessageDialog.showMessage(this, e2.getMessage()); } finally { setCursor(Cursor.getDefaultCursor()); } }
From source file:com.raphfrk.craftproxyclient.gui.CraftProxyGUI.java
public void actionPerformed(ActionEvent action) { if (action.getSource().equals(connect)) { if (action.getActionCommand().equals("Start")) { startProxyServer();//from ww w. j a v a2 s. c o m } else if (action.getActionCommand().equals("Stop")) { connectionListener.interrupt(); connect.setText("Stopping"); setStatus("Halting proxy server"); } else if (action.getActionCommand().equals("Stopping")) { JOptionPane.showMessageDialog(CraftProxyGUI.this, "Server halt is in progress", "Error", JOptionPane.ERROR_MESSAGE); } } }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.xhtml.PainelXHTML.java
public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd == "Salvar") { salvaAlteracoes.salvar();// ww w . ja v a 2s.c o m textAreaSourceCode.coloreSource(); reavalia(textAreaSourceCode.getText()); } else if (cmd == "AbrirURL") { String url; url = JOptionPane.showInputDialog(this, GERAL.DIGITE_ENDERECO, "http://"); avaliaUrl(url); // JOptionPane.showMessageDialog(null, "Seu nome " + nome); } else if (cmd == "Abrir") { String a[] = { ".html", ".htm" }; G_File temp = new G_File(caminhoRecente.read(), a); if (temp.getFile() != null) { avaliaArq(temp); } } else if (cmd == "SaveAs") { // salvarComo(); //salvaAlteracoes.setUltimoPath(caminhoRecente.read()); salvaAlteracoes.salvarComo(); // avalia(); } else if (cmd == "Creditos") { new Creditos(); } else if (cmd == "Sair") { System.exit(0); } else if (cmd == "SelecionarTudo") { textAreaSourceCode.getTextPane().selectAll(); if (ferrXHTMLPanelNaoEditavel != null) { ferrXHTMLPanelNaoEditavel.textAreaSourceCode.getTextPane().selectAll(); } } else if (cmd == "Desfazer") { textAreaSourceCode.undo(); // boxCode.coloreSource(); // reavalia(boxCode.getText()); } else if (cmd == "AumentaFonte") { textAreaSourceCode.aumentaFontSize(); } else if (cmd == "DiminuiFonte") { textAreaSourceCode.diminuiFontSize(); } else if (cmd == "Contraste") { textAreaSourceCode.autoContraste(); reavalia(textAreaSourceCode.getText()); } else if (cmd == "Cancelar") { salvaAlteracoes.cancelar(); } }
From source file:com.funambol.admin.settings.panels.EditConsoleAppender.java
/** * Create the panel/*from w w w . j a v a 2 s .c o m*/ * @throws Exception if error occures during creation of the panel. */ private void init() throws Exception { final int h = 18; final int x1 = 15; final int x2 = 150; final int w1 = 100; final int w2 = 310; int y = 40; int dy = 25; setLayout(null); setName(Bundle.getMessage(Bundle.EDIT_CONSOLE_APPENDER_PANEL_NAME)); panelNameLabel.setText(Bundle.getMessage(Bundle.EDIT_CONSOLE_APPENDER_PANEL_NAME)); panelNameLabel.setBounds(new Rectangle(14, 5, 245, 28)); panelNameLabel.setAlignmentX(SwingConstants.CENTER); panelNameLabel.setBorder(new TitledBorder("")); nameLabel.setText(Bundle.getMessage(Bundle.LABEL_APPENDER_NAME) + " :"); nameLabel.setBounds(new Rectangle(x1, y, w1, h)); nameLabel2.setBounds(new Rectangle(x2, y, w2, h)); y += dy; conversionPatternLabel.setText(Bundle.getMessage(Bundle.LABEL_PATTERN_LAYOUT) + " :"); conversionPatternLabel.setBounds(new Rectangle(x1, y, w1, h)); conversionPattern.setBounds(new Rectangle(x2, y, w2, h)); y += dy; y += dy; confirmButton.setText(Bundle.getMessage(Bundle.LABEL_BUTTON_SAVE)); confirmButton.setBounds(new Rectangle(401, y, 60, 25)); confirmButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { validateValues(); getValues(); EditConsoleAppender.this.actionPerformed(new ActionEvent(EditConsoleAppender.this, ACTION_EVENT_UPDATE, event.getActionCommand())); } catch (Exception e) { notifyError(new AdminException(e.getMessage())); } } }); add(panelNameLabel, null); add(nameLabel, null); add(nameLabel2, null); add(conversionPatternLabel, null); add(conversionPattern, null); add(confirmButton, null); GuiFactory.setDefaultFont(this); panelNameLabel.setFont(GuiFactory.titlePanelFont); }
From source file:com.funambol.json.admin.JsonConnectorConfigPanel.java
/** * Create the panel/* ww w .j a v a 2s . c o m*/ */ private void init() { JLabel title, serverLabel; JPanel seccPanel; JPanel behaviourOnErrorsPanel; title = new JLabel(); seccPanel = new JPanel(); behaviourOnErrorsPanel = new JPanel(); serverLabel = new JLabel(); serverValue = new JTextField(); setLayout(null); title.setFont(titlePanelFont); title.setText("Funambol Json Connector"); title.setBounds(new Rectangle(14, 5, 316, 28)); title.setAlignmentX(SwingConstants.CENTER); title.setBorder(new TitledBorder("")); seccPanel.setLayout(null); seccPanel.setBorder(new TitledBorder("HTTP Server Configuration")); serverLabel.setText("Server:"); seccPanel.add(serverLabel); serverLabel.setBounds(10, 20, 116, 15); seccPanel.add(serverValue); serverValue.setBounds(150, 20, 220, 19); serverValue.setFont(defaultFont); add(seccPanel); seccPanel.setBounds(10, 50, 380, 70); //the ssl option panel behaviourOnErrorsPanel.setBorder(new TitledBorder("Behaviour on errors")); behaviourOnErrorsPanel.setLayout(null); stopSyncOnFatalError.setText("Stop sync on fatal errors"); stopSyncOnFatalError.setBounds(10, 25, 200, 15); behaviourOnErrorsPanel.add(stopSyncOnFatalError); add(behaviourOnErrorsPanel); behaviourOnErrorsPanel.setBounds(10, 130, 380, 60); confirmButton.setFont(defaultFont); confirmButton.setText("Save"); add(confirmButton); confirmButton.setBounds(160, 200, 70, 25); confirmButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { validateValues(); getValues(); JsonConnectorConfigPanel.this.actionPerformed(new ActionEvent(JsonConnectorConfigPanel.this, ACTION_EVENT_UPDATE, event.getActionCommand())); } catch (Exception e) { notifyError(new AdminException(e.getMessage())); } } }); // // Setting font... // Component[] components = getComponents(); for (int i = 0; (components != null) && (i < components.length); ++i) { components[i].setFont(defaultFont); } // // We add it as the last one so that the font won't be changed // add(title); }
From source file:com.game.ui.views.MapPanel.java
@Override public void actionPerformed(ActionEvent e) { // we consider we just viewing the map information if (playerAvailable == false) { //here is to set the InformationPanel; int[] actionPositon = getTileLocation(Integer.parseInt(e.getActionCommand())); int actionRow = actionPositon[0]; int actionColumn = actionPositon[1]; if (informationPanel == null) { informationPanel = new InformationPanel(); }/*w ww. java 2 s . co m*/ if (turnPanel == null) { turnPanel = new TurnPanel(); turnPanel.player1.addActionListener(new TurnControl()); turnPanel.player2.addActionListener(new TurnControl()); //turnPanel.player3.addActionListener(new TurnControl()); turnPanel.player4.addActionListener(new TurnControl()); turnPanel.inventory.addActionListener(new InventoryControl()); } wrapperPanel2.add(informationPanel.tilePanel, BorderLayout.NORTH); wrapperPanel2.add(turnPanel, BorderLayout.SOUTH); wrapperPanel.add(wrapperPanel2, BorderLayout.EAST); informationPanel.commandCounter.setText("Postion : " + e.getActionCommand()); informationPanel.actionRow.setText("Row: " + actionRow); informationPanel.actionColumn.setText("actionColum: " + actionColumn); TileInformation info = pathMap.get(Integer.parseInt(e.getActionCommand())); if (info != null) { if (info.getPlayer() != null) informationPanel.playerStyle.setText("playerStyle: " + info.getPlayer().getType()); else informationPanel.playerStyle.setText("playerStyle: "); informationPanel.endTile.setText("endTile " + info.isEndTile()); informationPanel.startTile.setText("startTile " + info.isStartTile()); } this.revalidate(); } // here is to move the players else { if (pathMap.get(Integer.parseInt(e.getActionCommand())) != null) { playerAvailable = false; boolean moveAble = false; int[] a = new int[2]; int[] b = new int[2]; b = getTileLocation(userLocation.get(0)); a = getTileLocation(Integer.parseInt(e.getActionCommand())); if (Math.abs(a[0] - b[0]) + Math.abs(b[1] - a[1]) == 1) { moveAble = true; } // if(moveDistance <= pathMap.get(userLocation.get(0)).getPlayer().getMovement()) if (moveAble == true) { if (pathMap.get(Integer.parseInt(e.getActionCommand())).isEndTile()) { this.dispose(); } else { tile[userLocation.get(0) - 1].setIcon(null); tile[Integer.parseInt(e.getActionCommand()) - 1].setIcon(icon); pathMap.get(userLocation.get(0)).setStartTile(false); Player p = pathMap.get(userLocation.get(0)).getPlayer(); pathMap.get(userLocation.get(0)).setPlayer(null); pathMap.get(Integer.parseInt(e.getActionCommand())).setPlayer(p); pathMap.get(Integer.parseInt(e.getActionCommand())).setStartTile(true); userLocation.put(0, Integer.parseInt(e.getActionCommand())); } } else { } } else { } } }
From source file:de.huberlin.cuneiform.compiler.debug.DebugDispatcher.java
@Override public void actionPerformed(ActionEvent e) { List<Integer> signatureList; Set<Invocation> readyInvocationSet; Set<JsonReportEntry> report; if (e.getSource() == exitItem) { frame.dispose();//from w ww.j a v a 2 s .c o m return; } if (e.getActionCommand().equals(PreInvocView.LABEL_STEP)) { signatureList = invocOverview.getSelectedPreInvocSignatureList(); readyInvocationSet = getReadyInvocationSet(); if (signatureList == null) throw new NullPointerException("Signature list must not be null."); if (signatureList.isEmpty()) throw new RuntimeException("Signature list must not be empty."); invocOverview.setContentOld(); try { for (Integer i : signatureList) { if (i == null) throw new NullPointerException("Signature must not be null."); for (Invocation invoc : readyInvocationSet) if (invoc.getSignature() == i) { report = dispatch(invoc); if (!invoc.isComputed()) throw new RuntimeException("Expected the invocation to be computed."); evalReport(report); readyInvocationSet.remove(invoc); invocOverview.removePreInvocation(invoc); invocOverview.insertPostInvocation(invoc); break; } updateView(); } } catch (NotDerivableException e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(frame, e1.getMessage(), "NotDerivableException", JOptionPane.ERROR_MESSAGE); } catch (IOException e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(frame, e1.getMessage(), "IOException", JOptionPane.ERROR_MESSAGE); } catch (InterruptedException e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(frame, e1.getMessage(), "InterruptedException", JOptionPane.ERROR_MESSAGE); } catch (JSONException e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(frame, e1.getMessage(), "JSONException", JOptionPane.ERROR_MESSAGE); } return; } }
From source file:edu.wisc.ssec.mcidasv.control.McIDASVHistogramWrapper.java
/** * @return {@link ActionListener} that listens for * {@link ChartPanel#PROPERTIES_COMMAND} events and shows the histogram * properties./* w w w . j ava 2s. c o m*/ */ private ActionListener buildHistoPropsListener() { return new ActionListener() { @Override public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if (ChartPanel.PROPERTIES_COMMAND.equals(command)) { McIDASVHistogramWrapper.this.showProperties(); return; } } }; }
From source file:org.jfree.chart.demo.JFreeChartDemo.java
/** * Handles menu selections by passing control to an appropriate method. * * @param event the event.//from w ww. j a va2s .com */ public void actionPerformed(final ActionEvent event) { final String command = event.getActionCommand(); if (command.equals(EXIT_COMMAND)) { attemptExit(); } else if (command.equals(ABOUT_COMMAND)) { about(); } else { /// Loop through available commands to find index to current command. int chartnum = -1; int i = CHART_COMMANDS.length; while (i > 0) { --i; if (command.equals(CHART_COMMANDS[i][0])) { chartnum = i; i = 0; } } /// check our index is valid if ((chartnum >= 0) && (chartnum < this.frame.length)) { /// Check we have not already created chart. if (this.frame[chartnum] == null) { // setup the chart. DEMO.getChart(chartnum); // present it in a frame... String str = this.resources.getString(CHART_COMMANDS[chartnum][2] + ".title"); this.frame[chartnum] = new ChartFrame(str, DEMO.getChart(chartnum)); this.frame[chartnum].getChartPanel().setPreferredSize(new java.awt.Dimension(500, 270)); this.frame[chartnum].pack(); RefineryUtilities.positionFrameRandomly(this.frame[chartnum]); /// Set panel to zoomable if required try { str = this.resources.getString(CHART_COMMANDS[chartnum][2] + ".zoom"); if ((str != null) && (str.toLowerCase().equals("true"))) { final ChartPanel panel = this.frame[chartnum].getChartPanel(); panel.setMouseZoomable(true); panel.setHorizontalAxisTrace(true); panel.setVerticalAxisTrace(true); } } catch (Exception ex) { /// Filter out messages which for charts which do not have zoom /// specified. if (ex.getMessage().indexOf("MissingResourceException") == 0) { ex.printStackTrace(); } } this.frame[chartnum].setVisible(true); } else { this.frame[chartnum].setVisible(true); this.frame[chartnum].requestFocus(); } } } }
From source file:com.digitalgeneralists.assurance.ui.MainWindow.java
public void actionPerformed(ActionEvent e) { if (AssuranceActions.viewScanAction.equals(e.getActionCommand())) { this.topArea.setSelectedIndex(0); this.setMenuState(this.resultsMenuIndex, false); }/*from www .j ava 2s. c o m*/ if (AssuranceActions.viewHistoryAction.equals(e.getActionCommand())) { this.topArea.setSelectedIndex(1); this.setMenuState(this.scanMenuIndex, false); } if (AssuranceActions.quitApplicationAction.equals(e.getActionCommand())) { this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING)); } if (AssuranceActions.aboutApplicationAction.equals(e.getActionCommand())) { this.displayAboutDialog(); } if (AssuranceActions.displaySettingsAction.equals(e.getActionCommand())) { this.displayPreferencesDialog(); } }