我使用键盘在布局之间跳转,但该功能在其他布局中是钢的,我需要此功能仅在 1 个布局中工作。
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.addKeyEventDispatcher(new KeyEventDispatcher() {
@Override
public boolean dispatchKeyEvent(java.awt.event.KeyEvent e) {
System.out.println(e.paramString());
String sa = e.paramString();
char ch = sa.charAt(4);
if(e.getKeyCode()==112 && ch=='R'){
dispose ();
Home d = new Home ();
d.setTitle("Home");
d.setVisible (true);
}
return false;
}