[英]TAB key in Java Applets
我看到Java代碼有兩個問題,當代碼作為小程序運行時,期望用戶按TAB鍵
首先,在Chrome中,似乎沒有檢測到壓力。
在IE9中,更令人討厭的是,按TAB鍵將注意力完全放在小程序上。
我以前看過這些報告,但是到目前為止,我的搜索並沒有提出一個整潔的解決方案,甚至在解決方案存在時也沒有給出快速的答案……是嗎?
作為桌面或WebStart / JNLP應用程序運行,TAB可以很好地工作,只有在applet中它才會變得混亂。
我知道現在回答這個問題已經很晚了,但是如果其他人也遇到同樣的問題,那么希望這會有所幫助。 下面的鏈接解決了我的問題。 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) {}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.