List of usage examples for javax.swing JList getActionMap
public final ActionMap getActionMap()
ActionMap
used to determine what Action
to fire for particular KeyStroke
binding. From source file:ListCutPaste.java
/** * Add the cut/copy/paste actions to the action map. *//* ww w. j av a 2 s . c om*/ private void setMappings(JList list) { ActionMap map = list.getActionMap(); map.put(TransferHandler.getCutAction().getValue(Action.NAME), TransferHandler.getCutAction()); map.put(TransferHandler.getCopyAction().getValue(Action.NAME), TransferHandler.getCopyAction()); map.put(TransferHandler.getPasteAction().getValue(Action.NAME), TransferHandler.getPasteAction()); }
From source file:pl.otros.vfs.browser.VfsBrowser.java
License:asdf
private JPopupMenu addPopupMenu(JList list, String... actions) { JPopupMenu favoritesPopupMenu = new JPopupMenu(); for (String action : actions) { favoritesPopupMenu.add(list.getActionMap().get(action)); }//from w ww. java 2 s . c om list.addKeyListener(new PopupListener(favoritesPopupMenu)); list.addMouseListener(new PopupListener(favoritesPopupMenu)); return favoritesPopupMenu; }
From source file:pl.otros.vfs.browser.VfsBrowser.java
License:asdf
private void addOpenActionToList(final JList favoritesList) { favoritesList.getActionMap().put(ACTION_OPEN, new OpenSelectedFavorite(this, favoritesList)); favoritesList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { favoritesList.getActionMap().get(ACTION_OPEN).actionPerformed(null); }//from w ww .j ava 2 s . c o m } }); InputMap favoritesListInputMap = favoritesList.getInputMap(JComponent.WHEN_FOCUSED); favoritesListInputMap.put(KeyStroke.getKeyStroke("ENTER"), ACTION_OPEN); }
From source file:pl.otros.vfs.browser.VfsBrowser.java
License:asdf
private void addEditActionToList(final JList favoritesList, final MutableListModel<Favorite> listModel) { favoritesList.getActionMap().put(ACTION_EDIT, new EditFavorite(favoritesList, listModel)); InputMap favoritesListInputMap = favoritesList.getInputMap(JComponent.WHEN_FOCUSED); favoritesListInputMap.put(KeyStroke.getKeyStroke("F2"), ACTION_EDIT); }