Java Swing - 如何動態(tài)構(gòu)建JTree...
我們想知道如何動態(tài)構(gòu)建JTree。...
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JTree;
import javax.swing.KeyStroke;
public class Main {
public static void main(String[] args) {
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);
}
}
}