本文整理汇总了Java中javax.swing.ActionMap类的典型用法代码示例。如果您正苦于以下问题:Java ActionMap类的具体用法?Java ActionMap怎么用?Java ActionMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ActionMap类属于javax.swing包,在下文中一共展示了ActionMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import javax.swing.ActionMap; //导入依赖的package包/类
private void init() {
// Close the dialog when Esc is pressed
String cancelName = "cancel";
InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), cancelName);
ActionMap actionMap = getRootPane().getActionMap();
actionMap.put(cancelName, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
doClose(RET_CANCEL);
}
});
DefaultComboBoxModel<String> comboBoxModel = (DefaultComboBoxModel<String>) encodingComboBox.getModel();
for (Map.Entry<String, Charset> entry : Charset.availableCharsets().entrySet()) {
if (!"UTF-8".equals(entry.getKey())) {
comboBoxModel.addElement(entry.getValue().name());
}
}
}
示例2: toString
import javax.swing.ActionMap; //导入依赖的package包/类
/** Converts an action map to a string representation. */
static public String toString(ActionMap am) {
StringBuilder result = new StringBuilder();
LinkedHashMap<Object,Object> map = new LinkedHashMap<>();
for (Object key : am.allKeys()) {
map.put(key, am.get(key));
}
result.append(map);
result.append('\n');
ActionMap parent = am.getParent();
if (parent != null) {
result.append("Parent: ");
result.append(toString(parent));
}
return result.toString();
}
示例3: exchangeCommands
import javax.swing.ActionMap; //导入依赖的package包/类
private static void exchangeCommands(String[][] commandsToExchange,
final JComponent target, final JComponent source) {
InputMap targetBindings = target.getInputMap();
KeyStroke[] targetBindingKeys = targetBindings.allKeys();
ActionMap targetActions = target.getActionMap();
InputMap sourceBindings = source.getInputMap();
ActionMap sourceActions = source.getActionMap();
for (int i = 0; i < commandsToExchange.length; i++) {
String commandFrom = commandsToExchange[i][0];
String commandTo = commandsToExchange[i][1];
final Action orig = targetActions.get(commandTo);
if (orig == null) {
continue;
}
sourceActions.put(commandTo, new AbstractAction() {
public void actionPerformed(ActionEvent e) {
orig.actionPerformed(new ActionEvent(target, e.getID(), e.getActionCommand(), e.getWhen(), e.getModifiers()));
}
});
for (int j = 0; j < targetBindingKeys.length; j++) {
if (targetBindings.get(targetBindingKeys[j]).equals(commandFrom)) {
sourceBindings.put(targetBindingKeys[j], commandTo);
}
}
}
}
示例4: MVMapElement
import javax.swing.ActionMap; //导入依赖的package包/类
MVMapElement(TLDataObject dataObject) {
// Hack
if (Beans.isDesignTime()) {
Beans.setDesignTime(false);
}
this.dataObject = dataObject;
glPanel = new TLMapGLPanel(dataObject.getDatabase().getMap(), dataObject.getDatabase());
slider = new TLSlider(dataObject.getDatabase());
elementPanel = new JPanel(new BorderLayout());
elementPanel.add(glPanel, BorderLayout.CENTER);
elementPanel.add(slider, BorderLayout.PAGE_END);
ActionMap map = new ActionMap();
map.put("save", SystemAction.get(SaveAction.class));
elementPanel.setActionMap(map);
lookupContent = new InstanceContent();
lookup = new ProxyLookup(dataObject.getLookup(), new AbstractLookup(lookupContent));
}
示例5: testPropertyChangeListenersDetachedAtFinalizeIssue58100
import javax.swing.ActionMap; //导入依赖的package包/类
@RandomlyFails // NB-Core-Build #7816: expected:<0> but was:<1>
public void testPropertyChangeListenersDetachedAtFinalizeIssue58100() throws Exception {
class MyAction extends AbstractAction
implements ActionPerformer {
public void actionPerformed(ActionEvent ev) {
}
public void performAction(SystemAction a) {
}
}
MyAction action = new MyAction();
ActionMap map = new ActionMap();
CallbackSystemAction systemaction = (CallbackSystemAction)SystemAction.get(SimpleCallbackAction.class);
map.put(systemaction.getActionMapKey(), action);
Lookup context = Lookups.singleton(map);
Action delegateaction = systemaction.createContextAwareInstance(context);
assertTrue("Action is expected to have a PropertyChangeListener attached", action.getPropertyChangeListeners().length > 0);
Reference actionref = new WeakReference(systemaction);
systemaction = null;
delegateaction = null;
assertGC("CallbackSystemAction is supposed to be GCed", actionref);
assertEquals("Action is expected to have no PropertyChangeListener attached", 0, action.getPropertyChangeListeners().length);
}
示例6: sendAction
import javax.swing.ActionMap; //导入依赖的package包/类
private void sendAction(final Object key) throws Exception {
class Process implements Runnable {
@Override
public void run() {
final ActionMap map = treeView.tree.getActionMap();
Action a = map.get(key);
String all = Arrays.toString(map.allKeys()).replace(',', '\n');
assertNotNull("Action for key " + key + " found: " + all, a);
a.actionPerformed(new ActionEvent(treeView.tree, 0, null));
}
}
Process processEvent = new Process();
LOG.log(Level.INFO, "Sending action {0}", key);
SwingUtilities.invokeAndWait(processEvent);
LOG.log(Level.INFO, "Action {0} send", key);
}
示例7: initActionMapInEDT
import javax.swing.ActionMap; //导入依赖的package包/类
private boolean initActionMapInEDT() {
// Init action map: cut,copy,delete,paste actions.
javax.swing.ActionMap am = editor.getActionMap();
//#43157 - editor actions need to be accessible from outside using the TopComponent.getLookup(ActionMap.class) call.
// used in main menu enabling/disabling logic.
javax.swing.ActionMap paneMap = pane.getActionMap();
// o.o.windows.DelegateActionMap.setParent() leads to CloneableEditor.getEditorPane()
provideUnfinishedPane = true;
try {
am.setParent(paneMap);
} finally {
provideUnfinishedPane = false;
}
//#41223 set the defaults befor the custom editor + kit get initialized, giving them opportunity to
// override defaults..
paneMap.put(DefaultEditorKit.cutAction, getAction(DefaultEditorKit.cutAction));
paneMap.put(DefaultEditorKit.copyAction, getAction(DefaultEditorKit.copyAction));
paneMap.put("delete", getAction(DefaultEditorKit.deleteNextCharAction)); // NOI18N
paneMap.put(DefaultEditorKit.pasteAction, getAction(DefaultEditorKit.pasteAction));
return true;
}
示例8: init
import javax.swing.ActionMap; //导入依赖的package包/类
private void init() {
initialized = true;
setDefaultRenderer(Object.class, new DefaultOutlineCellRenderer());
ActionMap am = getActionMap();
//make rows expandable with left/rigt arrow keys
Action a = am.get("selectNextColumn"); //NOI18N
am.put("selectNextColumn", new ExpandAction(true, a)); //NOI18N
a = am.get("selectPreviousColumn"); //NOI18N
am.put("selectPreviousColumn", new ExpandAction(false, a)); //NOI18N
getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (getSelectedRowCount() == 1) {
selectedRow = getSelectedRow();
} else {
selectedRow = -1;
}
}
});
}
示例9: TemplatesPanel
import javax.swing.ActionMap; //导入依赖的package包/类
/** Creates new form TemplatesPanel */
public TemplatesPanel (String pathToSelect) {
ActionMap map = getActionMap ();
map.put (DefaultEditorKit.copyAction, ExplorerUtils.actionCopy (getExplorerManager ()));
map.put (DefaultEditorKit.cutAction, ExplorerUtils.actionCut (getExplorerManager ()));
map.put (DefaultEditorKit.pasteAction, ExplorerUtils.actionPaste (getExplorerManager ()));
map.put ("delete", ExplorerUtils.actionDelete (getExplorerManager (), true)); // NOI18N
initComponents ();
createTemplateView ();
treePanel.add (view, BorderLayout.CENTER);
associateLookup (ExplorerUtils.createLookup (getExplorerManager (), map));
initialize (pathToSelect);
}
示例10: ResultPanelTree
import javax.swing.ActionMap; //导入依赖的package包/类
ResultPanelTree(ResultDisplayHandler displayHandler, StatisticsPanel statPanel) {
super(new BorderLayout());
treeView = new ResultTreeView();
treeView.getAccessibleContext().setAccessibleName(Bundle.ACSN_TestResults());
treeView.getAccessibleContext().setAccessibleDescription(Bundle.ACSD_TestResults());
treeView.setBorder(BorderFactory.createEtchedBorder());
// resultBar.setPassedPercentage(0.0f);
JToolBar toolBar = new JToolBar();
toolBar.setFloatable(false);
toolBar.add(resultBar);
toolBar.setBorder(BorderFactory.createEtchedBorder());
add(toolBar, BorderLayout.NORTH);
add(treeView, BorderLayout.CENTER);
explorerManager = new ExplorerManager();
explorerManager.setRootContext(rootNode = new RootNode(displayHandler.getSession(), filterMask));
explorerManager.addPropertyChangeListener(this);
initAccessibility();
this.displayHandler = displayHandler;
this.statPanel = statPanel;
displayHandler.setLookup(ExplorerUtils.createLookup(explorerManager, new ActionMap()));
}
示例11: componentOpened
import javax.swing.ActionMap; //导入依赖的package包/类
/** Opened for the first time */
@Override
protected void componentOpened() {
Log.getLogger().entering("QueryBuilder", "componentOpened");
activateActions();
ActionMap map = getActionMap();
InputMap keys = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
installActions(map, keys);
// QueryBuilder does not need to listen to VSE, because it will notify us
// directly if something changes. The SqlCommandCustomizer needs to listen
// to VSE, because that's the only way it is notified of changes to the command
// sqlStatement.addPropertyChangeListener(sqlStatementListener) ;
// vse.addPropertyChangeListener(sqlStatementListener) ;
// do NOT force a parse here. It's done in componentShowing().
// populate( sqlStatement.getCommand()) ;
}
示例12: getComponent
import javax.swing.ActionMap; //导入依赖的package包/类
public JComponent getComponent() {
if (panel == null) {
final BeanTreeView view = new BeanTreeView();
view.setRootVisible(false);
view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
class Panel extends JPanel implements ExplorerManager.Provider, Lookup.Provider {
// Make sure action context works correctly:
private final Lookup lookup = ExplorerUtils.createLookup(manager, new ActionMap());
{
setLayout(new BorderLayout());
add(view, BorderLayout.CENTER);
}
public ExplorerManager getExplorerManager() {
return manager;
}
public Lookup getLookup() {
return lookup;
}
}
panel = new Panel();
}
return panel;
}
示例13: getComponent
import javax.swing.ActionMap; //导入依赖的package包/类
public JComponent getComponent() {
if (panel == null) {
final BeanTreeView view = new BeanTreeView();
view.setRootVisible(true);
view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
class Panel extends JPanel implements ExplorerManager.Provider, Lookup.Provider {
// Make sure action context works correctly:
private final Lookup lookup = ExplorerUtils.createLookup(manager, new ActionMap());
{
setLayout(new BorderLayout());
add(view, BorderLayout.CENTER);
}
public ExplorerManager getExplorerManager() {
return manager;
}
public Lookup getLookup() {
return lookup;
}
}
panel = new Panel();
}
return panel;
}
示例14: testNPEinAllKeys
import javax.swing.ActionMap; //导入依赖的package包/类
/**
* Test of allKeys method, of class DelegateActionMap.
*/
@Test
public void testNPEinAllKeys() {
System.out.println( "allKeys" );
TopComponent tc = new TopComponent();
ActionMap delegate = new ActionMap();
delegate.put( "test", new AbstractAction() {
@Override
public void actionPerformed( ActionEvent e ) {
throw new UnsupportedOperationException( "Not supported yet." ); //To change body of generated methods, choose Tools | Templates.
}
});
assertNotNull( delegate.allKeys() );
DelegateActionMap instance = new DelegateActionMap( tc, delegate );
Object[] result = instance.allKeys();
assertNotNull( result );
instance.clear();
result = instance.allKeys();
assertNotNull( result );
}
示例15: LicensePanel
import javax.swing.ActionMap; //导入依赖的package包/类
/** Creates new form LicensePanel */
public LicensePanel(URL url) {
this.url = url;
initComponents();
initAccessibility();
try {
jEditorPane1.setPage(url);
} catch (IOException exc) {
//Problem with locating file
System.err.println("Exception: " + exc.getMessage()); //NOI18N
exc.printStackTrace();
}
ActionMap actionMap = jEditorPane1.getActionMap();
actionMap.put(DefaultEditorKit.upAction, new ScrollAction(-1));
actionMap.put(DefaultEditorKit.downAction, new ScrollAction(1));
}