本文整理汇总了Java中javax.swing.AbstractAction类的典型用法代码示例。如果您正苦于以下问题:Java AbstractAction类的具体用法?Java AbstractAction怎么用?Java AbstractAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractAction类属于javax.swing包,在下文中一共展示了AbstractAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPreferredAction
import javax.swing.AbstractAction; //导入依赖的package包/类
/**
* On default select the represented agent and do the former original action
* @return
*/
@Override
public Action getPreferredAction() {
return new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
IPogamutEnvironments environments = Lookup.getDefault().lookup(IPogamutEnvironments.class);
if (environments == null)
return;
environments.getEnvironmentSelection(map).changeSelected(agent);
// Do the original action
Action original = UnrealAgentNode.super.getPreferredAction();
if (original != null)
original.actionPerformed(e);
}
};
}
示例2: initialize
import javax.swing.AbstractAction; //导入依赖的package包/类
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
setLayout(new BorderLayout());
this.setSize(581, 39);
this.add(getJPanel(), java.awt.BorderLayout.WEST);
setFocusable(true);
final AbstractAction aa = new AbstractAction() {
/**
*
*/
private static final long serialVersionUID = 1L;
public void actionPerformed(ActionEvent e) {
findNext(jTextField.getText(), jCheckBox.isSelected());
}
};
this.getInputMap().put(KeyStroke.getKeyStroke("F3"), "FindNext");
this.getActionMap().put("FindNext", aa);
getJTextField().getInputMap().put(KeyStroke.getKeyStroke("F3"),
"FindNext");
getJTextField().getActionMap().put("FindNext", aa);
}
示例3: ViewAsMenuItem
import javax.swing.AbstractAction; //导入依赖的package包/类
public ViewAsMenuItem(final String type) {
super(new AbstractAction(NbBundle.getMessage(NumericDisplayFilter.class, "CTL_View_"+type)) {
@Override
public void actionPerformed(ActionEvent e) {
onViewAs(type, true);
}
});
}
示例4: getPopupPresenter
import javax.swing.AbstractAction; //导入依赖的package包/类
public JMenuItem getPopupPresenter() {
JMenu displayAsPopup = new JMenu();
Mnemonics.setLocalizedText(displayAsPopup, NbBundle.getMessage(DebuggingActionsProvider.class, "CTL_Session_Popup_Language"));
String [] languages = session.getSupportedLanguages();
String currentLanguage = session.getCurrentLanguage();
for (int i = 0; i < languages.length; i++) {
final String language = languages[i];
JRadioButtonMenuItem langItem = new JRadioButtonMenuItem(new AbstractAction(language) {
public void actionPerformed(ActionEvent e) {
session.setCurrentLanguage(language);
}
});
if (currentLanguage.equals(language)) langItem.setSelected(true);
displayAsPopup.add(langItem);
}
return displayAsPopup;
}
示例5: getActions
import javax.swing.AbstractAction; //导入依赖的package包/类
@Override
public Action[] getActions(boolean context) {
Action[] res = new Action[2];
res[0] = new AbstractAction(NbBundle.getMessage(HiddenDataObject.class, "LBL_restore")) { //NOI18N
@Override
public void actionPerformed(ActionEvent e) {
try {
destroy();
} catch( IOException ex ) {
Exceptions.printStackTrace(ex);
}
}
};
res[0].setEnabled(canDestroy());
res[1] = SystemAction.get(OpenLayerFilesAction.class);
return res;
}
示例6: testGlobalChanges
import javax.swing.AbstractAction; //导入依赖的package包/类
public void testGlobalChanges() throws Exception {
class MyAction extends AbstractAction {
public int cntEnabled;
public int cntPerformed;
public boolean isEnabled() {
cntEnabled++;
return true;
}
public void actionPerformed(ActionEvent ev) {
cntPerformed++;
}
}
MyAction myAction = new MyAction();
ActionMap tc = new ActionMap();
tc.put(DefaultEditorKit.copyAction, myAction);
CopyAction a = (CopyAction)CopyAction.get(CopyAction.class);
ActionsInfraHid.setActionMap(tc);
try {
assertTrue("MyAction is enabled", a.isEnabled());
assertEquals("isEnabled called once", 1, myAction.cntEnabled);
a.setActionPerformer(null);
assertEquals("An enabled is currentlly called again", 2, myAction.cntEnabled);
} finally {
ActionsInfraHid.setActionMap(null);
}
}
示例7: getActions
import javax.swing.AbstractAction; //导入依赖的package包/类
@Override
public Action[] getActions() {
Action refresh = new AbstractAction() {
{
putValue(ACTION_COMMAND_KEY, "refresh_current_page");
putValue(SMALL_ICON, new ImageIcon(getClass().getResource(
"/com/ramussoft/gui/refresh.png")));
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_R,
KeyEvent.CTRL_MASK));
}
@Override
public void actionPerformed(ActionEvent e) {
pane.getDocument().putProperty(
Document.StreamDescriptionProperty, null);
openLocation();
}
};
return new Action[]{goBack, goForward, goHome, refresh, null,
exportToHTMLAction};
}
示例8: getPreferredAction
import javax.swing.AbstractAction; //导入依赖的package包/类
@Override
public Action getPreferredAction () {
if (options.contains(Option.ENABLE_POPUP)) {
if (currRepository != null && item != null) {
final File repo = currRepository;
final int index = item.getIndex();
return new AbstractAction(NbBundle.getMessage(ApplyStashAction.class, "LBL_ApplyStashAction_PopupName")) { //NOI18N
@Override
public void actionPerformed (ActionEvent e) {
SystemAction.get(ApplyStashAction.class).applyStash(repo, index, false);
}
};
}
}
return null;
}
示例9: getUserActions
import javax.swing.AbstractAction; //导入依赖的package包/类
@Override
public Action[] getUserActions () {
List<Action> actions = new ArrayList<Action>();
boolean hasParents = event.getLogInfoHeader().getLog().getParents().length > 0;
if (hasParents) {
actions.add(new AbstractAction(NbBundle.getMessage(SummaryView.class, "CTL_SummaryView_DiffToPrevious")) { // NOI18N
@Override
public void actionPerformed(ActionEvent e) {
diffPrevious(event, master);
}
});
}
actions.addAll(Arrays.asList(event.getActions(false)));
return actions.toArray(new Action[actions.size()]);
}
示例10: DetailsButton
import javax.swing.AbstractAction; //导入依赖的package包/类
public DetailsButton(String showText, String hideText,
Component expander, Component buddy) {
this.showText = showText;
this.hideText = hideText;
if (expander != null) setExpander(expander);
setAction(new AbstractAction(showText, collapsedIcon) {
private static final long serialVersionUID = 1L;
public void actionPerformed(ActionEvent e) {
setExpanded(!DetailsButton.this.expander.isVisible());
}
});
if (buddy != null) setBuddy(buddy);
setBorderPainted(false);
setContentAreaFilled(false);
}
示例11: createContextAwareInstance
import javax.swing.AbstractAction; //导入依赖的package包/类
@Messages("BTN_Open_Project=Open Project")
public @Override Action createContextAwareInstance(final Lookup context) {
return new AbstractAction(BTN_Open_Project()) {
public @Override void actionPerformed(ActionEvent e) {
Collection<? extends NbMavenProjectImpl> projects = context.lookupAll(NbMavenProjectImpl.class);
final NbMavenProjectImpl[] projectsArray = projects.toArray(new NbMavenProjectImpl[0]);
if(projectsArray.length > 0) {
RequestProcessor.getDefault().post(new Runnable() {
public @Override void run() {
OpenProjects.getDefault().open(projectsArray, false, true);
RequestProcessor.getDefault().post(new Runnable() {
public @Override void run() {
ProjectActionUtils.selectAndExpandProject(projectsArray[0]);
}
}, 500);
}
});
}
}
};
}
示例12: createContextAwareInstance
import javax.swing.AbstractAction; //导入依赖的package包/类
public @Override Action createContextAwareInstance(final Lookup context) {
return new AbstractAction(BTN_Open_Project()) {
public @Override void actionPerformed(ActionEvent e) {
Set<Project> projects = new HashSet<Project>();
for (Artifact art : context.lookupAll(Artifact.class)) {
File f = art.getFile();
if (f != null) {
Project p = FileOwnerQuery.getOwner(org.openide.util.Utilities.toURI(f));
if (p != null) {
projects.add(p);
}
}
}
OpenProjects.getDefault().open(projects.toArray(new NbMavenProjectImpl[projects.size()]), false, true);
}
};
}
示例13: inserirAtalhos
import javax.swing.AbstractAction; //导入依赖的package包/类
private void inserirAtalhos() {
InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
getRootPane().setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, inputMap);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancelar");
getRootPane().getActionMap().put("cancelar", new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent arg0) {
jPanelCards.removeAll();
dispose();
}
});
}
示例14: getActions
import javax.swing.AbstractAction; //导入依赖的package包/类
Action[] getActions () {
List<Action> actions = new ArrayList<Action>();
actions.add(new AbstractAction(NbBundle.getMessage(RepositoryRevision.class, "CTL_SummaryView_RollbackChange")) { //NOI18N
@Override
public void actionPerformed(ActionEvent e) {
SvnProgressSupport support = new SvnProgressSupport() {
@Override
public void perform() {
RevertModifications.RevisionInterval revisionInterval = new RevertModifications.RevisionInterval(getLog().getRevision());
final Context ctx = new Context(selectionRoots);
RevertModificationsAction.performRevert(revisionInterval, false, false, ctx, this);
}
};
support.start(Subversion.getInstance().getRequestProcessor(repositoryRootUrl),
repositoryRootUrl, NbBundle.getMessage(SummaryView.class, "MSG_Revert_Progress")); //NOI18N
}
});
return actions.toArray(new Action[actions.size()]);
}
示例15: createButton
import javax.swing.AbstractAction; //导入依赖的package包/类
/**
* Helper method used to create a button inside a JPanel
* @param action action associated to that button
* @return created component
*/
private JComponent createButton(AbstractAction action) {
JPanel panel = new JPanel(); // Use gridbag as centers by default
JButton button = new JButton(action);
button.setHorizontalTextPosition(SwingConstants.CENTER);
button.setVerticalTextPosition(SwingConstants.BOTTOM);
button.setPreferredSize(new Dimension((int) (BUTTONSIZE * 3.5), (BUTTONSIZE * 2)));
button.addMouseListener(rollover);
//if (action == buttonAction[4]) {
// button.setVisible(false);
//}
//if (action == buttonAction[0]) {
// button.setEnabled(false);
//}
//if (action == buttonAction[2]) button.setEnabled(false);
//if (action == buttonAction[4]) button.setEnabled(false);
panel.add(button);
return panel;
}