/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
@test
@bug 4053856
@summary Choice components don't honour key focus
@library ../../regtesthelpers
@build Util
@author Andrei Dmitriev : area=awt.choice
@run main ChoiceFocus
*/
/*
Here is the old description for the test.
This bug occurs in jdk <= 1.1.6, 1.2b3. The problem is that key press
and release events will not be delivered to a choice component with
the focus if the mouse is over another component (of any type);
This bug occurs in Motif and was fixed in the native code.
1. Set the focus on choice component 1 by selecting an item.
2. Move the mouse over choice component 2, BUT do not set the focus on it.
3. Type some characters e.g. 'a', 'b' etc.
4. Verify by the console output that all the key events are delivered to
choice component 1, not 2. If all the key events are delivered to
choice 1, the test passes.
*/
public class ChoiceFocus {
volatile static boolean keyPressed = false;
volatile static boolean keyReleased = false;
volatile static boolean keyTyped = false;
f.setLayout(new GridLayout());
public void keyPressed(KeyEvent e){
keyPressed = true;
}
public void keyReleased(KeyEvent e){
keyReleased = true;
}
keyTyped = true;
}
});
f.pack();
f.setVisible(true);
robot.setAutoWaitForIdle(true);
//transfer focus to Choice
//close choice
//position a mouse over a different component
throw new RuntimeException("Failed. Some of event wasn't come "+keyPressed + " : "+keyReleased+" : "+keyTyped);
} else {
}
}
}////~