Java Code Examples for java.awt.event.ActionEvent#getActionCommand()

The following examples show how to use java.awt.event.ActionEvent#getActionCommand() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public void actionPerformed(ActionEvent e)
{
    String cmd = e.getActionCommand();
    if (cmd.equals("save"))
    {
        _logFile.setComments(_commentEditor.getText());
    }
    Thread update = new Thread
    ( 
            new Runnable()
            {

                public void run()
                {
                    RemoteLogRepositoryBackend.getInstance().updateLogDetails(_logFile);
                }

            }
    );
    update.setName("LogFile Details Updater Thread");
    update.start();
    LogRepository.getInstance().runSaveDatabase();
}
 
Example 2
/**
 * Sets the foreground color.
 *
 * @param e the action event
 */
public void actionPerformed(ActionEvent e) {
    JEditorPane editor = getEditor(e);
    if (editor != null) {
        Color fg = this.fg;
        if ((e != null) && (e.getSource() == editor)) {
            String s = e.getActionCommand();
            try {
                fg = Color.decode(s);
            } catch (NumberFormatException nfe) {
            }
        }
        if (fg != null) {
            MutableAttributeSet attr = new SimpleAttributeSet();
            StyleConstants.setForeground(attr, fg);
            setCharacterAttributes(editor, attr, false);
        } else {
            UIManager.getLookAndFeel().provideErrorFeedback(editor);
        }
    }
}
 
Example 3
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (CMD_DIALOG.equals(command)) {
        JDialog dialog = new JDialog(this.frame, "Dialog"); // NON-NLS: dialog title
        dialog.setLocation(200, 0);
        show(dialog, CMD_CHOOSER);
    }
    else if (CMD_CHOOSER.equals(command)) {
        Object source = event.getSource();
        Component component = (source instanceof Component)
                ? (Component) source
                : null;

        JColorChooser.showDialog(component, "ColorChooser", Color.BLUE); // NON-NLS: title
    }
}
 
Example 4
Source Project: Java8CN   File: StyledEditorKit.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Sets the font size.
 *
 * @param e the action event
 */
public void actionPerformed(ActionEvent e) {
    JEditorPane editor = getEditor(e);
    if (editor != null) {
        int size = this.size;
        if ((e != null) && (e.getSource() == editor)) {
            String s = e.getActionCommand();
            try {
                size = Integer.parseInt(s, 10);
            } catch (NumberFormatException nfe) {
            }
        }
        if (size != 0) {
            MutableAttributeSet attr = new SimpleAttributeSet();
            StyleConstants.setFontSize(attr, size);
            setCharacterAttributes(editor, attr, false);
        } else {
            UIManager.getLookAndFeel().provideErrorFeedback(editor);
        }
    }
}
 
Example 5
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (CMD_DIALOG.equals(command)) {
        JDialog dialog = new JDialog(this.frame, "Dialog"); // NON-NLS: dialog title
        dialog.setLocation(200, 0);
        show(dialog, CMD_CHOOSER);
    }
    else if (CMD_CHOOSER.equals(command)) {
        Object source = event.getSource();
        Component component = (source instanceof Component)
                ? (Component) source
                : null;

        JColorChooser.showDialog(component, "ColorChooser", Color.BLUE); // NON-NLS: title
    }
}
 
Example 6
@Override
public void actionPerformed(ActionEvent e) {
    String arg = e.getActionCommand();

    if ("first".equals(arg)) {
        ((CardLayout) cards.getLayout()).first(cards);
    } else if ("next".equals(arg)) {
        ((CardLayout) cards.getLayout()).next(cards);
    } else if ("previous".equals(arg)) {
        ((CardLayout) cards.getLayout()).previous(cards);
    } else if ("last".equals(arg)) {
        ((CardLayout) cards.getLayout()).last(cards);
    } else {
        ((CardLayout) cards.getLayout()).show(cards, arg);
    }
}
 
Example 7
/**
 * The operation to perform when this action is triggered.
 *
 * @param e the action event
 */
public void actionPerformed(ActionEvent e) {
    JTextComponent target = getTextComponent(e);
    if ((target != null) && (e != null)) {
        if ((! target.isEditable()) || (! target.isEnabled())) {
            return;
        }
        String content = e.getActionCommand();
        int mod = e.getModifiers();
        if ((content != null) && (content.length() > 0)) {
            boolean isPrintableMask = true;
            Toolkit tk = Toolkit.getDefaultToolkit();
            if (tk instanceof SunToolkit) {
                isPrintableMask = ((SunToolkit)tk).isPrintableCharacterModifiersMask(mod);
            }

            if (isPrintableMask) {
                char c = content.charAt(0);
                if ((c >= 0x20) && (c != 0x7F)) {
                    target.replaceSelection(content);
                }
            }
        }
    }
}
 
Example 8
@Override
public void actionPerformed(ActionEvent e) {
  final Component[] components = getComponents();
  for (final Component component : components) {
    final RocLinePanel cp = (RocLinePanel) component;
    if (cp == mPanel) {
      switch (e.getActionCommand()) {
        case "remove":
          remove(mPanel);
          mRocPlot.mData.remove(mPanel.getPath());
          break;
        default:
          System.err.println("Unhandled event!");
      }
      updateCurves();
      break;
    }
  }
}
 
Example 9
/**
 * Sets the font family.
 *
 * @param e the event
 */
public void actionPerformed(ActionEvent e) {
    JEditorPane editor = getEditor(e);
    if (editor != null) {
        String family = this.family;
        if ((e != null) && (e.getSource() == editor)) {
            String s = e.getActionCommand();
            if (s != null) {
                family = s;
            }
        }
        if (family != null) {
            MutableAttributeSet attr = new SimpleAttributeSet();
            StyleConstants.setFontFamily(attr, family);
            setCharacterAttributes(editor, attr, false);
        } else {
            UIManager.getLookAndFeel().provideErrorFeedback(editor);
        }
    }
}
 
Example 10
Source Project: brModelo   File: Diagrama.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void DoAction(ActionEvent ev) {
    if (ev.getActionCommand() == null || ev.getActionCommand().isEmpty()) {
        setComando(null);
        return;
    }
    try {
        Controler.Comandos cmd = Controler.Comandos.valueOf(ev.getActionCommand());
        if (comando != cmd) {
            cliq1 = null;
            cliq2 = null;
        }
        setComando(cmd);
    } catch (Exception e) {
        setComando(null);
    }
}
 
Example 11
public void actionPerformed(ActionEvent evt) {
    Object src = evt.getSource();
    String cmd = evt.getActionCommand();

    if (src == backButton) {
        back();
    } else if (src == nextButton) {
        FileChooserUI ui = chooser.getUI();
        if (ui instanceof BasicFileChooserUI) {
            // Workaround for bug 4528663. This is necessary to
            // pick up the contents of the file chooser text field.
            // This will trigger an APPROVE_SELECTION action.
            ((BasicFileChooserUI) ui).getApproveSelectionAction().
                    actionPerformed(null);
        } else {
            next();
        }
    } else if (src == closeButton) {
        close();
    } else if (APPROVE_SELECTION.equals(cmd)) {
        next();
    } else if (CANCEL_SELECTION.equals(cmd)) {
        close();
    }
}
 
Example 12
Source Project: ramus   File: WebPanel.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected void actionPerformed(final ActionEvent e) {
    final String s = e.getActionCommand();
    if (GO_TO_URL.equals(s))
        goToURL(false);
    else if (GO_BACK.equals(s)) {
        jTextField.setText(history.back());
        goToURL(true);
    } else if (GO_NEXT.equals(s)) {
        jTextField.setText(history.next());
        goToURL(true);
    }
}
 
Example 13
Source Project: gcs   File: ListOutline.java    License: Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent event) {
    Object source  = event.getSource();
    String command = event.getActionCommand();

    if (source instanceof OutlineProxy) {
        source = ((OutlineProxy) source).getRealOutline();
    }
    if (source == this && Outline.CMD_OPEN_SELECTION.equals(command)) {
        openDetailEditor(false);
    }
}
 
Example 14
Source Project: gcs   File: CharacterSheet.java    License: Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (Outline.CMD_POTENTIAL_CONTENT_SIZE_CHANGE.equals(command)) {
        mRootsToSync.add(((Outline) event.getSource()).getRealOutline());
        markForRebuild();
    }
}
 
Example 15
/** Fires action event */
@Override
public void loggedActionPerformed(ActionEvent e) {
	String actionCommand = e.getActionCommand();
	Action action = tree.getActionMap().get(actionCommand);
	if (action != null) {
		action.actionPerformed(new ActionEvent(tree, ActionEvent.ACTION_PERFORMED, actionCommand));
	}
}
 
Example 16
Source Project: SIMVA-SoS   File: DefaultLogAxisEditor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Handles actions from within the property panel.
 * 
 * @param event an event.
 */
@Override
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (command.equals("TickUnitValue")) {
        validateTickUnit();
    }
    else {
        // pass to the super-class for handling
        super.actionPerformed(event);
    }
}
 
Example 17
Source Project: darklaf   File: ToolBarDemo.java    License: MIT License 5 votes vote down vote up
public void actionPerformed(final ActionEvent e) {
    String cmd = e.getActionCommand();
    String description = null;

    // 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>.";
    }

    displayResult("If this were a real app, it would have " + description);
}
 
Example 18
Source Project: HackBar   File: XXE_Menu.java    License: MIT License 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    int[] selectedIndex = myburp.context.getSelectionBounds();
    IHttpRequestResponse req = myburp.context.getSelectedMessages()[0];
    byte[] request = req.getRequest();
    byte[] param = new byte[selectedIndex[1]-selectedIndex[0]];
    System.arraycopy(request, selectedIndex[0], param, 0, selectedIndex[1]-selectedIndex[0]);
    String selectString = new String(param);
    String action = e.getActionCommand();
    byte[] newRequest = do_XXE(request, selectString, action, selectedIndex);
    req.setRequest(newRequest);
}
 
Example 19
/**
 * Handles actions from within the property panel.
 * 
 * @param event an event.
 */
@Override
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (command.equals("TickUnitValue")) {
        validateTickUnit();
    }
    else {
        // pass to the super-class for handling
        super.actionPerformed(event);
    }
}
 
Example 20
Source Project: Bytecoder   File: InputMethodPopupMenu.java    License: Apache License 2.0 4 votes vote down vote up
public void actionPerformed(ActionEvent event) {
    String choice = event.getActionCommand();
    ((ExecutableInputMethodManager)InputMethodManager.getInstance()).changeInputMethod(choice);
}