下面列出了java.awt.event.ActionEvent#getActionCommand() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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();
}
/**
* 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);
}
}
}
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
}
}
/**
* 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);
}
}
}
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
}
}
@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);
}
}
/**
* 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);
}
}
}
}
}
@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;
}
}
}
/**
* 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);
}
}
}
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);
}
}
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();
}
}
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);
}
}
@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);
}
}
@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();
}
}
/** 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));
}
}
/**
* 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);
}
}
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);
}
@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);
}
/**
* 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);
}
}
public void actionPerformed(ActionEvent event) {
String choice = event.getActionCommand();
((ExecutableInputMethodManager)InputMethodManager.getInstance()).changeInputMethod(choice);
}