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

The following examples show how to use java.awt.event.ActionEvent#getActionCommand() . 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
Source File: LogDetailsPanel.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
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
Source File: StyledEditorKit.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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
Source File: FileChooserDemo.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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 4
Source File: Test4759934.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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 5
Source File: StyledEditorKit.java    From Java8CN with 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 6
Source File: Test4759934.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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 7
Source File: CardTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@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 8
Source File: DefaultEditorKit.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 9
Source File: RocLinesPanel.java    From rtg-tools with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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 10
Source File: Diagrama.java    From brModelo with 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
Source File: StyledEditorKit.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 12
Source File: WebPanel.java    From ramus with 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 File: DefaultLogAxisEditor.java    From ccu-historian with GNU General Public License v3.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 14
Source File: XXE_Menu.java    From HackBar with 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 15
Source File: ToolBarDemo.java    From darklaf with 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 16
Source File: DefaultLogAxisEditor.java    From SIMVA-SoS with 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 File: CutEntryRepositoryAction.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/** 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 18
Source File: CharacterSheet.java    From gcs with 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 19
Source File: ListOutline.java    From gcs with 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 20
Source File: InputMethodPopupMenu.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public void actionPerformed(ActionEvent event) {
    String choice = event.getActionCommand();
    ((ExecutableInputMethodManager)InputMethodManager.getInstance()).changeInputMethod(choice);
}