本文整理了Java中javax.swing.JTree.getInputMap()
方法的一些代码示例,展示了JTree.getInputMap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTree.getInputMap()
方法的具体详情如下:
包路径:javax.swing.JTree
类名称:JTree
方法名:getInputMap
暂无
代码示例来源:origin: realXuJiang/bigtable-sql
private void initRenderer()
{
DefaultTreeCellRenderer treeCellRenderer = new DefaultTreeCellRenderer()
{
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)
{
return modifyRenderer(super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus), value);
}
};
_tree.setCellRenderer(treeCellRenderer);
AbstractAction cancelCutAction = new AbstractAction()
{
public void actionPerformed(ActionEvent actionEvent)
{
if (null != _pathsToPaste && PasteMode.CUT.equals(_pasteMode))
{
_pathsToPaste = null;
_tree.repaint();
}
}
};
KeyStroke escapeStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
_tree.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(escapeStroke, "cancelCutAction");
_tree.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escapeStroke, "cancelCutAction");
_tree.getInputMap(JComponent.WHEN_FOCUSED).put(escapeStroke, "cancelCutAction");
_tree.getActionMap().put("cancelCutAction", cancelCutAction);
}
代码示例来源:origin: net.sf.squirrel-sql/squirrel-sql
private void initRenderer()
{
DefaultTreeCellRenderer treeCellRenderer = new DefaultTreeCellRenderer()
{
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)
{
return modifyRenderer(super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus), value);
}
};
_tree.setCellRenderer(treeCellRenderer);
AbstractAction cancelCutAction = new AbstractAction()
{
public void actionPerformed(ActionEvent actionEvent)
{
if (null != _pathsToPaste && PasteMode.CUT.equals(_pasteMode))
{
_pathsToPaste = null;
_tree.repaint();
}
}
};
KeyStroke escapeStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
_tree.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(escapeStroke, "cancelCutAction");
_tree.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escapeStroke, "cancelCutAction");
_tree.getInputMap(JComponent.WHEN_FOCUSED).put(escapeStroke, "cancelCutAction");
_tree.getActionMap().put("cancelCutAction", cancelCutAction);
}
代码示例来源:origin: stackoverflow.com
JTree tree = new JTree(new String[]{"a", "b", "c"});
tree.setEditable(true);
InputMap m = tree.getInputMap(JComponent.WHEN_FOCUSED);
KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0);
m.put(ks, "actionMapKey");
tree.getActionMap().put("actionMapKey", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
// do your stuff
}
});
代码示例来源:origin: org.apache.jmeter/ApacheJMeter_core
InputMap inputMap = treevar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
KeyStroke[] keyStrokes = new KeyStroke[]{KeyStrokes.CTRL_0,
KeyStrokes.CTRL_1, KeyStrokes.CTRL_2, KeyStrokes.CTRL_3,
代码示例来源:origin: stackoverflow.com
final JTree tree = new JTree();
tree.setEditable(true);
MouseListener ml = new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
int row = tree.getRowForLocation(e.getX(), e.getY());
TreePath path = tree.getPathForLocation(e.getX(), e.getY());
if (row != -1) {
if (e.getClickCount() == 1) {
tree.startEditingAtPath(path);
}
}
}
};
tree.addMouseListener(ml);
tree.getInputMap().put(
KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "startEditing");
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-modelutil
/** Creates a new instance of CheckTreeView */
public CheckTreeView() {
setFocusable(false);
CheckListener l = new CheckListener();
tree.addMouseListener(l);
tree.addKeyListener(l);
CheckRenderer check = new CheckRenderer();
tree.setCellRenderer(check);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.setShowsRootHandles(false);
InputMap input = tree.getInputMap(JTree.WHEN_FOCUSED);
if (null != input) {
input.remove(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
}
setBorder(UIManager.getBorder("ScrollPane.border")); // NOI18N
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-java-hints-analyzer
/** Creates a new instance of CheckTreeView */
public CheckTreeView() {
setFocusable( false );
CheckListener l = new CheckListener();
tree.addMouseListener( l );
tree.addKeyListener( l );
CheckRenderer check = new CheckRenderer();
tree.setCellRenderer( check );
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.setShowsRootHandles(false);
InputMap input = tree.getInputMap( JTree.WHEN_FOCUSED );
if( null != input )
input.remove( KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0) );
setBorder( UIManager.getBorder("ScrollPane.border") );
}
代码示例来源:origin: xSAVIKx/AndroidScreencast
/**
* If the node is cancelable an escape Action is registered in the tree's InputMap and ActionMap that will cancel the execution
*
* @param tree the tree
* @param worker the worker to cancel
*/
protected void registerSwingWorkerForCancel(JTree tree, com.github.xsavikx.androidscreencast.ui.worker.SwingWorker<MutableTreeNode[], ?> worker) {
if (!cancelable) {
return;
}
tree.getInputMap().put(ESCAPE_KEY, ESCAPE_ACTION_NAME);
Action action = tree.getActionMap().get(ESCAPE_ACTION_NAME);
if (action == null) {
CancelWorkersAction cancelWorkerAction = new CancelWorkersAction();
cancelWorkerAction.addSwingWorker(worker);
tree.getActionMap().put(ESCAPE_ACTION_NAME, cancelWorkerAction);
} else {
if (action instanceof CancelWorkersAction) {
CancelWorkersAction cancelAction = (CancelWorkersAction) action;
cancelAction.addSwingWorker(worker);
}
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
tree.addMouseListener(ml);
tree.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enter_action");
tree.getActionMap().put("enter_action", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
代码示例来源:origin: Waikato/weka-trunk
tree.addMouseListener(ml);
tree.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enter_action");
tree.getActionMap().put("enter_action", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
代码示例来源:origin: org.zaproxy/zap
treeContext.getInputMap().put(
(KeyStroke) delContextAction.getValue(DeleteContextAction.ACCELERATOR_KEY),
DeleteContextAction.ACTION_NAME);
代码示例来源:origin: org.bitbucket.goalhub.simpleide/jedit
resultTree.getInputMap().remove(keyStroke);
代码示例来源:origin: org.zaproxy/zap
treeAlert.getInputMap().put(view.getDefaultDeleteKeyStroke(), deleteAlertKey);
treeAlert.getActionMap().put(deleteAlertKey, new AbstractAction() {
代码示例来源:origin: de.sciss/jtreetable
protected JTree createAndConfigureTree() {
JTree tree = createTree(treeTable.getTreeTableModel());
if (treeTable.getSelectionModel() == null) {
treeTable.setSelectionModel(tree.getSelectionModel());
} else {
tree.setSelectionModel(treeTable.getSelectionModel());
}
tree.setOpaque(false);
tree.setRowHeight(20);
tree.putClientProperty("JTree.lineStyle", "None");
InputMap inputs = tree.getInputMap();
remap(inputs, KeyEvent.VK_LEFT);
remap(inputs, KeyEvent.VK_RIGHT);
updateTreeClientProperties(tree);
return tree;
}
内容来源于网络,如有侵权,请联系作者删除!