K
kwatson
We are using an embedded applet for data entry purposes.
Occasionally, a user will hit the tab key, and bad things happen.
A string of spaces are entered into the applet, focus goes back to the
browser, and then the user starts hitting backspaces, etc trying to
remove the spaces they just stuck in, and suddenly find themselves
booted out of the web application and having to start over.
I have been tasked with preventing this behavior by keeping the tab
key from giving focus back to the browser. While this seems to have
been no major problem to deal with in Firefox, IE6 & IE7 are both
proving to be my undoing, and the IE browser is the one this HAS to be
fixed in.
We are using the Sun JRE 1.6.0_03 in IE for applets.
Here are some of the things I have tried thus far without success.
// Try 1:
SwingTerminal.class.getMethod("setFocusable", params).invoke(this, new
Object[]{new Boolean(true)});
SwingTerminal.class.getMethod("setFocusTraversalKeysEnabled",
params).invoke(this, new Object[]{new Boolean(false)});
// Try 2:
Set<AWTKeyStroke> forwardKeys =
this.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
Set<AWTKeyStroke> newForwardKeys = new HashSet<AWTKeyStroke>(1);
newForwardKeys.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, 0));
this.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
newForwardKeys);
// Try 3
SwingTerminal.class.getMethod("setFocusTraversalKeysEnabled",
params).invoke(this, new Object[]{new Boolean(false)});
// common to all attempts
// inside my key event processor
if ( evt.getKeyCode() == KeyEvent.VK_TAB )
{
if ( evt.isAltDown() != evt.isControlDown() )
{
evt.consume();
}
}
Debugging statements tell me that my key processor is running, however
evt.getKeyCode() is not equal to KeyCode.VK_TAB.
Can anyone provide me with some insight on how to keep the tab key
inside the applet within IE?
Occasionally, a user will hit the tab key, and bad things happen.
A string of spaces are entered into the applet, focus goes back to the
browser, and then the user starts hitting backspaces, etc trying to
remove the spaces they just stuck in, and suddenly find themselves
booted out of the web application and having to start over.
I have been tasked with preventing this behavior by keeping the tab
key from giving focus back to the browser. While this seems to have
been no major problem to deal with in Firefox, IE6 & IE7 are both
proving to be my undoing, and the IE browser is the one this HAS to be
fixed in.
We are using the Sun JRE 1.6.0_03 in IE for applets.
Here are some of the things I have tried thus far without success.
// Try 1:
SwingTerminal.class.getMethod("setFocusable", params).invoke(this, new
Object[]{new Boolean(true)});
SwingTerminal.class.getMethod("setFocusTraversalKeysEnabled",
params).invoke(this, new Object[]{new Boolean(false)});
// Try 2:
Set<AWTKeyStroke> forwardKeys =
this.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
Set<AWTKeyStroke> newForwardKeys = new HashSet<AWTKeyStroke>(1);
newForwardKeys.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, 0));
this.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
newForwardKeys);
// Try 3
SwingTerminal.class.getMethod("setFocusTraversalKeysEnabled",
params).invoke(this, new Object[]{new Boolean(false)});
// common to all attempts
// inside my key event processor
if ( evt.getKeyCode() == KeyEvent.VK_TAB )
{
if ( evt.isAltDown() != evt.isControlDown() )
{
evt.consume();
}
}
Debugging statements tell me that my key processor is running, however
evt.getKeyCode() is not equal to KeyCode.VK_TAB.
Can anyone provide me with some insight on how to keep the tab key
inside the applet within IE?