Skip to content

Commit 470eedb

Browse files
author
Alexander Zvegintsev
committed
8370511: test/jdk/javax/swing/JSlider/bug4382876.java does not release previously pressed keys
Reviewed-by: psadhukhan, serb, honkar
1 parent f73e56e commit 470eedb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

test/jdk/javax/swing/JSlider/bug4382876.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public class bug4382876 {
4848
private static Robot r;
4949
private static JFrame f;
5050
private static JSlider slider;
51-
private static boolean upFail;
52-
private static boolean downFail;
51+
private static volatile boolean upFail;
52+
private static volatile boolean downFail;
5353

5454
public static void main(String[] args) throws Exception {
5555
try {
@@ -70,23 +70,30 @@ public static void main(String[] args) throws Exception {
7070
r.delay(1000);
7171

7272
r.keyPress(KeyEvent.VK_PAGE_UP);
73+
r.keyRelease(KeyEvent.VK_PAGE_UP);
74+
7375
SwingUtilities.invokeAndWait(() -> {
7476
if (slider.getValue() < -1000) {
7577
System.out.println("PAGE_UP VAL: " + slider.getValue());
7678
upFail = true;
7779
}
7880
});
81+
7982
if (upFail) {
8083
writeFailImage();
8184
throw new RuntimeException("Slider value did NOT change with PAGE_UP");
8285
}
86+
8387
r.keyPress(KeyEvent.VK_PAGE_DOWN);
88+
r.keyRelease(KeyEvent.VK_PAGE_DOWN);
89+
8490
SwingUtilities.invokeAndWait(() -> {
8591
if (slider.getValue() > -1000) {
8692
System.out.println("PAGE_DOWN VAL: " + slider.getValue());
8793
downFail = true;
8894
}
8995
});
96+
9097
if (downFail) {
9198
writeFailImage();
9299
throw new RuntimeException("Slider value did NOT change with PAGE_DOWN");

0 commit comments

Comments
 (0)