-
Bug
-
Resolution: Fixed
-
P4
-
1.1.5
-
1.1.6
-
x86, sparc
-
solaris_2.6, windows_nt
-
Verified
ingrid.yao@Eng 1997-11-25
This appears to be a regression introduced in the fix for bug#4089468.
another suggested fix from Oracle by adding "else { focus = c; }" at the
bottom of java.awt.Container$LightweightDispatcher.setFocusRequest().
This proposed one-liner just gets rid of the symptoms and may not be
the right solution.
---------------- Bug report-------------------------------
Platform: Windows NT
Command Line: java b590689
Directions and Expected Results:
- Run this program.
- Click on the button to initially set focus on it.
- Start pressing [Tab] & [Shift+Tab] and
observe the behavior and output.
- When using [Tab] to go forward, it takes 3 jumps to
cycle through the two components.
- When using [Shift+Tab] to go backward, it takes the correct 2 jumps,
but the lightweight component never receives a focusGained event.
Notes:
In the simple test case, the Tab key does not correctly move focus back and
forth between a lightweight component and a java.awt.Button, both of which
are children of a java.awt.Panel inside a java.awt.Frame.
/*
Oracle Bug: 590689
Directions and Expected Results:
- Run this program.
- Click on the button to initially set focus on it.
- Start pressing [Tab] & [Shift+Tab] and
observe the behavior and output.
- When using [Tab] to go forward, it takes 3 jumps to
cycle through the two components.
- When using [Shift+Tab] to go backward, it takes the correct 2 jumps,
but the lightweight component never receives a focusGained event.
*/
public class b590689
{
public static void main( String[] args )
{
java.awt.Container panel = new java.awt.Panel();
panel.setLayout( new java.awt.BorderLayout());
panel.add( "West", new LightweightButton());
panel.add( "East", new java.awt.Button( "Focusable button" ));
java.awt.Window frame = new java.awt.Frame( "Fix me!" );
frame.add( "Center", panel );
frame.pack();
frame.setVisible( true );
}
static class LightweightButton extends java.awt.Component
implements java.awt.event.FocusListener
{
LightweightButton() { addFocusListener( this ); }
public void focusGained( java.awt.event.FocusEvent e )
{
System.out.println( "FocusComponent.focusGained( " + e );
}
public java.awt.Dimension getPreferredSize()
{
return new java.awt.Dimension( 100, 100 );
}
public void focusLost( java.awt.event.FocusEvent e ) {}
public boolean isFocusTraversable() { return true; }
}
}