これらのキーの押下に反応する上に存在するキー バインディングがあります。JTree
次のコード スニペットは、入力マップの 1 つで使用可能なバインディングを出力します。
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JTree;
import javax.swing.KeyStroke;
import java.awt.EventQueue;
public class TreeActionMap {
public static void main( String[] args ) {
EventQueue.invokeLater( new Runnable() {
@Override
public void run() {
JTree tree = new JTree( );
InputMap inputMap = tree.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
KeyStroke[] keyStrokes = inputMap.allKeys();
for ( KeyStroke keyStroke : keyStrokes ) {
Object actionCommand = inputMap.get( keyStroke );
System.out.println( "keyStroke = " + keyStroke );
System.out.println( "actionCommand = " + actionCommand );
}
}
} );
}
}
したがって、すべてのインスタンスをループしてそれらすべてInputMap
を呼び出した場合、はそれらのキーを押しても反応しなくなります。clear
JTree