我看到 Java 代码有两个问题,当代码作为小程序运行时,它希望用户按 TAB 键
首先,在Chrome中,似乎没有检测到压力机。
更糟糕的是,在IE9中按TAB会完全失去对小程序的关注。
我以前看过这些报告,但到目前为止我的搜索并没有提出一个简洁的解决方案,如果存在解决方案,甚至没有快速答案......是吗?
作为桌面或WebStart/JNLP应用程序TAB运行效果很好,只有在小程序中才会变得混乱。
我知道
现在回答这个问题已经很晚了,但如果其他人遇到同样的问题那么希望这会有所帮助。下面的链接解决了我的问题。http://dogfeathers.com/mark/java7issue.html
public void init()
{
Container topParent = null;
Container parent = this;
// The natural thing would be to call getParent() until it returns
// null, but then you would be looping for a long time, since
// PluginEmbeddedFrame's getParent() returns itself.
for (int k=0; k < 10; k++) {
topParent = parent;
parent = parent.getParent();
if (parent == null) break;
}
// If topParent isn't a KeyEventDispatcher then we must be in some
// Plugin version that doesn't need the workaround.
try {
KeyEventDispatcher ked = (KeyEventDispatcher)topParent;
KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
// You have to remove it twice, otherwise the problem isn't fixed
kfm.removeKeyEventDispatcher(ked);
kfm.removeKeyEventDispatcher(ked);
} catch (ClassCastException e) {}
}