项目:Pogamut3
文件:UnrealAgentNode.java
/**
* 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);
}
};
}
项目:ramus
文件:FindPanel.java
/**
* 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);
}
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;
}
项目:incubator-netbeans
文件:HiddenDataObject.java
@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;
}
项目:ramus
文件:Navigator.java
@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};
}
@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;
}
项目:incubator-netbeans
文件:SummaryView.java
@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()]);
}
项目:VASSAL-src
文件:DetailsButton.java
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);
}
项目:incubator-netbeans
文件:ModulesNode.java
@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);
}
});
}
}
};
}
项目:incubator-netbeans
文件:DependencyNode.java
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()]),true);
}
};
}
项目:hearthstone
文件:EscolherCard.java
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();
}
});
}
项目:incubator-netbeans
文件:RepositoryRevision.java
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,ctx,this);
}
};
support.start(Subversion.getInstance().getRequestProcessor(repositoryRootUrl),repositoryRootUrl,NbBundle.getMessage(SummaryView.class,"MSG_Revert_Progress")); //NOI18N
}
});
return actions.toArray(new Action[actions.size()]);
}
项目:jmt
文件:JWatMainPanel.java
/**
* 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;
}
protected Action buildDeleteAction(final Configurable target) {
final DefaultMutableTreeNode targetNode = getTreeNode(target);
final Configurable parent = getParent(targetNode);
if (targetNode.getParent() != null) {
return new AbstractAction(deleteCmd) {
private static final long serialVersionUID = 1L;
public void actionPerformed(ActionEvent evt) {
int row = selectedRow;
remove(parent,target);
if (row < getRowCount()) {
setSelectionRow(row);
}
else {
setSelectionRow(row - 1);
}
}
};
}
else {
return null;
}
}
项目:jmt
文件:JWatStartScreen.java
private void initGUI() {
this.setIconImage(JMtimageLoader.loadImage(IMG_JWATICON).getimage());
this.setResizable(false);
this.setTitle("JWAT");
this.setSize(CommonConstants.MAX_GUI_WIDTH_JWAT_STARTSCREEN,CommonConstants.MAX_GUI_HEIGHT_JWAT_STARTSCREEN);
//Image image = new ImageIcon(imageURL).getimage();
//image = image.getScaledInstance(400,315,Image.SCALE_SMOOTH);
JPanel eastPanel = new JPanel(new BorderLayout());
eastPanel.add(Box.createVerticalStrut(5),BorderLayout.norTH);
JPanel buttonPanel = new JPanel(new GridLayout(buttonAction.length,1,2,2));
eastPanel.add(buttonPanel,BorderLayout.CENTER);
for (AbstractAction element : buttonAction) {
buttonPanel.add(createButton(element));
}
JLabel imageLabel = new JLabel();
imageLabel.setBorder(BorderFactory.createEmptyBorder(BUTTONSIZE - 5,0));
//imageLabel.setIcon(new ImageIcon(image));
imageLabel.setIcon(new ImageIcon(new ImageIcon(imageURL).getimage().getScaledInstance(400,Image.SCALE_SMOOTH)));
imageLabel.setHorizontalAlignment(SwingConstants.RIGHT);
imageLabel.setVerticalAlignment(SwingConstants.norTH);
this.getContentPane().add(imageLabel,BorderLayout.CENTER);
this.getContentPane().add(eastPanel,BorderLayout.EAST);
}
项目:rapidminer
文件:FileChooserUI.java
protected ActionMap createActions() {
final AbstractAction escAction = new AbstractAction() {
private static final long serialVersionUID = -3976059968191425942L;
@Override
public void actionPerformed(ActionEvent e) {
FileChooserUI.this.fileList.stopThumbnailGeneration();
getFileChooser().cancelSelection();
}
@Override
public boolean isEnabled() {
return getFileChooser().isEnabled();
}
};
final ActionMap map = new ActionMapUIResource();
map.put("approveSelection",getApproveSelectionAction());
map.put("cancelSelection",escAction);
return map;
}
项目:incubator-netbeans
文件:DocumentsDlg.java
private JPanel createListView () {
JPanel panel = new JPanel();
// Defined size in #36907 - surrounding controls will add to this size
// and result is desired 540x400. Note that we can't hardcode size of
// whole dialog to work correctly with different font size
panel.setPreferredSize(new Dimension(375,232));
panel.setLayout(new BorderLayout());
listView = new ListView();
// proper border for the view
listView.setBorder((Border)UIManager.get("Nb.ScrollPane.border")); // NOI18N
listView.setPopupAllowed(false);
listView.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(DocumentsDlg.class,"ACSD_ListView"));
//view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
listView.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put( Keystroke.getKeystroke(KeyEvent.VK_DELETE,"closeSelected") ;//NOI18N
listView.getActionMap().put( "closeSelected",new AbstractAction() {//NOI18N
@Override
public void actionPerformed( ActionEvent e ) {
closeDocuments(e );
}
});
panel.add(listView,BorderLayout.CENTER);
return panel;
}
public void addLayout(GraphLayout lo) {
try{
final String name = lo.toString();
final GraphLayout finalLo = lo;
menu.addMenuItem(
new AbstractAction(name) {
public void actionPerformed (ActionEvent evt) {
finalLo.setGraph(uiFacade.getGraph());
uiFacade.doGraphLayout(finalLo);
}
},"Layouts","",true
);
}
catch (Exception e) {
e.printstacktrace();
}
}
项目:incubator-netbeans
文件:SBOptionsPanel.java
@NbBundle.Messages({
"MSG_InvalidHome=Please,select a valid Scene Builder home...","LBL_browse=browse..."
})
SBOptionsPanel(SBOptionsPanelController controller) {
this.controller = controller;
initComponents();
sbHome.setNullSelectionMessage(Bundle.MSG_InvalidHome());
sbHome.setGrowAction(new AbstractAction(Bundle.LBL_browse()) {
@Override
public void actionPerformed(ActionEvent e) {
browseAddNewRuntime();
}
});
sbHomeInfo.setVisible(false);
}
项目:incubator-netbeans
文件:BookmarksView.java
BookmarksView() {
// getActionMap().put("rename",SystemAction.get(RenameAction.class));
nodeTree = new BookmarksNodeTree();
explorerManager = new ExplorerManager();
explorerManager.setRootContext(nodeTree.rootNode());
ActionMap actionMap = getActionMap();
actionMap.put("delete",ExplorerUtils.actionDelete(explorerManager,false)); //NOI18N
associateLookup(ExplorerUtils.createLookup(explorerManager,actionMap));
explorerManager.addPropertychangelistener(this);
// Ctrl+T will toggle the tree/table view
InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(Keystroke.getKeystroke(KeyEvent.VK_T,KeyEvent.CTRL_DOWN_MASK),"toggle-view"); //NOI18N
actionMap.put("toggle-view",new AbstractAction() { //NOI18N
@Override
public void actionPerformed(ActionEvent e) {
setTreeViewVisible(!treeViewShowing);
}
});
setIcon(ImageUtilities.loadImage("org/netbeans/modules/editor/bookmarks/resources/bookmark_16.png")); // NOI18N
}
项目:ramus
文件:RowFindPanel.java
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
setLayout(new BorderLayout());
this.setSize(581,jCheckBox.isSelected());
}
};
this.getInputMap().put(Keystroke.getKeystroke("F3"),"findNext");
this.getActionMap().put("findNext","findNext");
getJTextField().getActionMap().put("findNext",aa);
}
项目:incubator-netbeans
文件:ActionsTest.java
public void testCheckPrioritiesOfIconsWithStringSmallIcon() {
AbstractAction aa = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
};
Object icon = "org/openide/awt/TestIcon_big.png";
aa.putValue(Action.SMALL_ICON,icon);
aa.putValue("iconBase","org/openide/awt/data/testIcon.gif");
JButton b = new JButton();
Actions.connect(b,aa);
JMenuItem m = new JMenuItem();
Actions.connect(m,aa,false);
assertSame("Using the same icon (small" + icon,b.getIcon(),m.getIcon());
}
项目:incubator-netbeans
文件:TopComponentTest.java
public void testCanTCGarbageCollectWhenActionInMap() {
TopComponent tc = new TopComponent();
class CAA extends AbstractAction implements
ContextAwareAction {
public void actionPerformed(ActionEvent arg0) {
throw new UnsupportedOperationException("Not supported yet.");
}
public Action createContextAwareInstance(Lookup actionContext) {
return this;
}
}
ContextAwareAction del = new CAA();
ContextAwareAction context = Actions.context(Integer.class,true,del,"displayName",true);
Action a = context.createContextAwareInstance(tc.getLookup());
tc.getActionMap().put("key",a);
WeakReference<Object> ref = new WeakReference<Object>(tc);
tc = null;
a = null;
del = null;
context = null;
assertGC("Can the component GC?",ref);
}
项目:incubator-netbeans
文件:TopComponentTest.java
public void testCanTCGarbageCollectWhenActionInMapAndAssignLookup() {
TopComponent tc = new TopComponent();
class CAA extends AbstractAction implements
ContextAwareAction {
public void actionPerformed(ActionEvent arg0) {
throw new UnsupportedOperationException("Not supported yet.");
}
public Action createContextAwareInstance(Lookup actionContext) {
return this;
}
}
tc.associateLookup(Lookups.fixed(tc.getActionMap(),tc));
ContextAwareAction del = new CAA();
ContextAwareAction context = Actions.context(Integer.class,ref);
}
项目:incubator-netbeans
文件:ProfilerTableActions.java
private Action selectNextColumnAction() {
return new AbstractAction() {
public void actionPerformed(ActionEvent e) {
ProfilerColumnModel cModel = table._getColumnModel();
if (table.getRowCount() == 0 || cModel.getVisibleColumnCount() == 0) return;
int column = table.getSelectedColumn();
if (column == -1) {
table.selectColumn(cModel.getFirstVisibleColumn(),false);
table.selectRow(0,true);
} else {
int nextColumn = cModel.getNextVisibleColumn(column);
if (nextColumn > column) table.selectColumn(nextColumn,true);
}
}
};
}
项目:incubator-netbeans
文件:ProfilerTableActions.java
private Action createNextCellAction() {
return new AbstractAction() {
public void actionPerformed(ActionEvent e) {
ProfilerColumnModel cModel = table._getColumnModel();
if (table.getRowCount() == 0 || cModel.getVisibleColumnCount() == 0) return;
int column = table.getSelectedColumn();
if (column == -1) {
table.selectColumn(cModel.getFirstVisibleColumn(),true);
} else {
int nextColumn = cModel.getNextVisibleColumn(column);
boolean differentRow = nextColumn <= column && table.getRowCount() > 1;
if (nextColumn != column) table.selectColumn(nextColumn,!differentRow);
if (differentRow) {
int row = table.getSelectedRow();
int newRow = getNextRow(row);
if (row != newRow) table.selectRow(newRow,true);
}
}
}
};
}
/**
* Adds input action map for the tmodel<p>
* needed as <code>OnKeyPress Edit</code> in autosuggest overriding the
* basic <code>Delete</code> key press
*
* @param table the target tmodel
*/
private static void clearTableSelectionOnDelete(final JTable table) {
InputMap inputMap = table.getInputMap(WHEN_FOCUSED);
ActionMap actionMap = table.getActionMap();
inputMap.put(Keystroke.DELETE,"delete");
actionMap.put("delete",new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent evt) {
cancelEditing(table);
ClearSelection(table);
}
});
}
项目:incubator-netbeans
文件:KeyboardPopupSwitcher.java
/**
* Prevents showing a popup if a user releases the <code>releaseKey</code>
* in time specified by <code>invokerTimer</code> (which is 200ms by
* default).
*/
private static void processInterruption(KeyEvent kev) {
int keyCode = kev.getKeyCode();
if (keyCode == releaseKey && kev.getID() == KeyEvent.KEY_RELEASED) {
// if an user releases Ctrl-Tab before the time to show
// popup expires,don't show the popup at all and switch to
// the last used document immediately
cleanupInterrupter();
hits = 0;
AbstractAction rva = new ThreadsHistoryAction();
rva.actionPerformed(new ActionEvent(kev.getSource(),ActionEvent.ACTION_PERFORMED,"immediately",kev.getModifiers())); // NOI18N
kev.consume();
// #88931: Need to react to KEY_pressed,not KEY_RELEASED,to not miss the hit
} else if (keyCode == triggerKey
&& kev.getModifiers() == InputEvent.CTRL_MASK
&& kev.getID() == KeyEvent.KEY_pressed) {
// count number of trigger key hits before popup is shown
hits++;
kev.consume();
cleanupInterrupter();
instance = new KeyboardPopupSwitcher(hits + 1,true);
instance.showPopup();
}
}
项目:Cognizant-Intelligent-Test-Scripter
文件:TMSettingsControl.java
private static AbstractAction getEncryptAction(final JTable table) {
return new AbstractAction() {
@Override
public void actionPerformed(ActionEvent me) {
try {
int col = table.getSelectedColumn();
int row = table.getSelectedRow();
if (col > -1 && row > -1) {
String data = table.getValueAt(row,col).toString();
table.setValueAt(TMIntegration.encrypt(data),row,col);
}
} catch (HeadlessException ex) {
Logger.getLogger(TMSettingsControl.class.getName())
.log(Level.SEVERE,ex.getMessage(),ex);
}
}
};
}
项目:Cognizant-Intelligent-Test-Scripter
文件:SelectionManager.java
private void init() {
start = new Point(0,0);
end = new Point(0,0);
click = new Point(0,0);
selection = new Rectangle2D.Double();
escape = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
removeSelection();
}
};
com.getInputMap(WHEN_FOCUSED).put(Keystroke.getKeystroke(KeyEvent.VK_ESCAPE,"escape");
com.getActionMap().put("escape",escape);
com.setFocusable(true);
com.requestFocus();
}
项目:ramus
文件:AboutDialog.java
public AboutDialog(JFrame frame,List<Plugin> plugins,List<GUIPlugin> guiPlugins) {
super(frame,true);
this.setTitle(GlobalResourcesManager.getString("About"));
this.plugins = plugins.subList(0,plugins.size());
this.guiPlugins = guiPlugins;
this.setDefaultCloSEOperation(disPOSE_ON_CLOSE);
JTabbedPane pane = new JTabbedPane();
pane.addTab(GlobalResourcesManager.getString("About.MainTab"),createAboutComponent());
pane.addTab(GlobalResourcesManager.getString("About.PluginList"),createPluginListComponent());
pane.addTab(GlobalResourcesManager.getString("About.GUIPluginList"),createGUIPluginListComponent());
pane.addTab(GlobalResourcesManager.getString("About.ThirdParts"),createThirdPartsComponnt());
JPanel panel = new JPanel(new BorderLayout());
panel.add(pane,BorderLayout.CENTER);
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
bottomPanel.add(new JButton(new AbstractAction(GlobalResourcesManager
.getString("ok")) {
/**
*
*/
private static final long serialVersionUID = -8334150633007409370L;
@Override
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
}));
panel.add(bottomPanel,BorderLayout.soUTH);
this.setContentPane(panel);
setSize(600,350);
setResizable(false);
setLocationRelativeto(null);
}
RuntimeListModel() {
this.growAction = new AbstractAction(otherSelectionMessage) {
@Override
public void actionPerformed(ActionEvent e) {
}
};
}
项目:incubator-netbeans
文件:LocationChooser.java
public LocationChooser (LocationChooser.Panel firer) {
super ();
this.setBorder(BorderFactory.createEmptyBorder(0,0));
this.setName (NbBundle.getMessage(LocationChooser.class,"TXT_PlatformFolderTitle"));
this.setFileSelectionMode(DIRECTORIES_ONLY);
this.setMultiSelectionEnabled(false);
this.setControlButtonsAreShown(false);
// this.accessory = new PlatformAccessory ();
this.setFileFilter (new PlatformFileFilter());
// this.setAccessory (this.accessory);
this.firer = firer;
this.platformFileView = new PlatformFileView( this.getFileSystemView());
this.setFileView(this.platformFileView);
this.addPropertychangelistener (this);
this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(LocationChooser.class,"AD_LocationChooser"));
//XXX JFileChooser workaround
getActionMap().put("cancel",new AbstractAction() {
public void actionPerformed(ActionEvent e) {
Container parent = LocationChooser.this.getParent();
do {
parent = parent.getParent();
} while (parent != null && !(parent instanceof Window));
if (parent != null) {
((Window)parent).setVisible(false);
}
}});
getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put (Keystroke.getKeystroke(KeyEvent.VK_ESCAPE,"cancel");
this.setBorder(null);
}
项目:QN-ACTR-Release
文件:JWatWizard.java
public void setActionButton(String button,AbstractAction a) {
for (JButton element : btnList) {
try {
if (element.getText().equals(button)) {
a.putValue(Action.NAME,button);
element.setAction(a);
break;
}
} catch (ClassCastException e) {
System.err.println("DEBUG: Casting not allowed");
}
}
}
项目:jdk8u-jdk
文件:RadialGradientPrintingTest.java
public static void createUI() {
f = new JFrame("RadialGradient Printing Test");
f.setDefaultCloSEOperation(WindowConstants.EXIT_ON_CLOSE);
final RadialGradientPrintingTest gpt = new RadialGradientPrintingtest();
Container c = f.getContentPane();
c.add(BorderLayout.CENTER,gpt);
final JButton print = new JButton("Print");
print.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(gpt);
final boolean doPrint = job.printDialog();
if (doPrint) {
try {
job.print();
} catch (PrinterException ex) {
throw new RuntimeException(ex);
}
}
}
});
c.add(print,BorderLayout.soUTH);
f.pack();
f.setVisible(true);
}
项目:vexillo
文件:ExportDialog.java
private static void setCancelButton(final JRootPane rp,final JButton b) {
rp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(Keystroke.getKeystroke(KeyEvent.VK_ESCAPE,"cancel");
rp.getActionMap().put("cancel",new AbstractAction() {
private static final long serialVersionUID = 1L;
public void actionPerformed(ActionEvent ev) {
b.doClick();
}
});
}
项目:Logisim
文件:Caret.java
Caret(HexEditor hex) {
this.hex = hex;
this.listeners = new ArrayList<changelistener>();
this.cursor = -1;
Listener l = new Listener();
hex.addMouseListener(l);
hex.addMouseMotionListener(l);
hex.addKeyListener(l);
hex.addFocusListener(l);
InputMap imap = hex.getInputMap();
ActionMap amap = hex.getActionMap();
AbstractAction nullAction = new AbstractAction() {
/**
*
*/
private static final long serialVersionUID = 3859667024369145469L;
@Override
public void actionPerformed(ActionEvent e) {
}
};
String nullKey = "null";
amap.put(nullKey,nullAction);
imap.put(Keystroke.getKeystroke(KeyEvent.VK_DOWN,nullKey);
imap.put(Keystroke.getKeystroke(KeyEvent.VK_UP,nullKey);
imap.put(Keystroke.getKeystroke(KeyEvent.VK_LEFT,nullKey);
imap.put(Keystroke.getKeystroke(KeyEvent.VK_RIGHT,nullKey);
imap.put(Keystroke.getKeystroke(KeyEvent.VK_PAGE_DOWN,nullKey);
imap.put(Keystroke.getKeystroke(KeyEvent.VK_PAGE_UP,nullKey);
imap.put(Keystroke.getKeystroke(KeyEvent.VK_HOME,nullKey);
imap.put(Keystroke.getKeystroke(KeyEvent.VK_END,nullKey);
imap.put(Keystroke.getKeystroke(KeyEvent.VK_ENTER,nullKey);
}
项目:incubator-netbeans
文件:VariablesSwitchViewAction.java
public ViewAsMenuItem(final String type) {
super(new AbstractAction(NbBundle.getMessage(NumericdisplayFilter.class,"CTL_View_"+type)) {
@Override
public void actionPerformed(ActionEvent e) {
onViewAs(type,true);
}
});
}
private void extractLabelsFromProject(Project p,Map<String,String> labels) {
labels.clear();
if( null == p ) {
labels.put( Utils.KEY_STATUS_BAR_LABEL,NbBundle.getMessage(MainProjectScanningScope.class,"LBL_noprojectStatusBar") ); //NOI18N
} else {
Projectinformation pi = ProjectUtils.getinformation(p);
labels.put(AbstractAction.SHORT_DESCRIPTION,"HINT_CurrentProjectScope",pi.getdisplayName()) ); //NOI18N
labels.put(AbstractAction.NAME,pi.getdisplayName());
labels.put( Utils.KEY_STATUS_BAR_LABEL,"LBL_CurrentProjectStatusBar",pi.getdisplayName()) ); //NOI18N
}
}
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",myAction.cntEnabled);
a.setActionPerformer(null);
assertEquals("An enabled is currentlly called again",myAction.cntEnabled);
} finally {
ActionsInfraHid.setActionMap(null);
}
}