Skip to content

Commit 75e42e0

Browse files
author
duke
committed
Backport 0844745e7bd954a96441365f8010741ec1c29dbf
1 parent 4c6dec6 commit 75e42e0

File tree

7 files changed

+129
-126
lines changed

7 files changed

+129
-126
lines changed

test/jdk/ProblemList.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ java/awt/EventQueue/6980209/bug6980209.java 8198615 macosx-all
147147
java/awt/EventQueue/PushPopDeadlock/PushPopDeadlock.java 8024034 generic-all
148148
java/awt/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java 7080150 macosx-all
149149
java/awt/event/InputEvent/EventWhenTest/EventWhenTest.java 8168646 generic-all
150+
java/awt/List/KeyEventsTest/KeyEventsTest.java 8201307 linux-all
151+
java/awt/Paint/ListRepaint.java 8201307 linux-all
150152
java/awt/Mixing/AWT_Mixing/HierarchyBoundsListenerMixingTest.java 8049405 macosx-all
151153
java/awt/Mixing/AWT_Mixing/OpaqueOverlapping.java 8294264 windows-x64
152154
java/awt/Mixing/AWT_Mixing/OpaqueOverlappingChoice.java 8048171 generic-all

test/jdk/java/awt/Frame/MiscUndecorated/ActiveAWTWindowTest.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,15 +25,24 @@
2525
* @test
2626
* @key headful
2727
* @summary To check proper WINDOW_EVENTS are triggered when Frame gains or losses the focus
28-
* @author Jitender([email protected]) area=AWT
29-
* @author yan
3028
* @library /lib/client
3129
* @build ExtendedRobot
3230
* @run main ActiveAWTWindowTest
3331
*/
3432

35-
import java.awt.*;
36-
import java.awt.event.*;
33+
import java.awt.BorderLayout;
34+
import java.awt.Button;
35+
import java.awt.Color;
36+
import java.awt.EventQueue;
37+
import java.awt.FlowLayout;
38+
import java.awt.Frame;
39+
import java.awt.TextField;
40+
import java.awt.event.ActionEvent;
41+
import java.awt.event.ActionListener;
42+
import java.awt.event.InputEvent;
43+
import java.awt.event.WindowAdapter;
44+
import java.awt.event.WindowEvent;
45+
import java.awt.event.WindowFocusListener;
3746

3847
public class ActiveAWTWindowTest {
3948

@@ -47,12 +56,12 @@ public class ActiveAWTWindowTest {
4756
private boolean passed = true;
4857
private final int delay = 150;
4958

50-
public static void main(String[] args) {
59+
public static void main(String[] args) throws Exception {
5160
ActiveAWTWindowTest test = new ActiveAWTWindowTest();
5261
try {
5362
test.doTest();
5463
} finally {
55-
EventQueue.invokeLater(() -> {
64+
EventQueue.invokeAndWait(() -> {
5665
if (test.frame != null) {
5766
test.frame.dispose();
5867
}

test/jdk/java/awt/List/KeyEventsTest/KeyEventsTest.java

Lines changed: 49 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -22,9 +22,8 @@
2222
*/
2323

2424
import java.awt.BorderLayout;
25-
import java.awt.EventQueue;
26-
import java.awt.KeyboardFocusManager;
2725
import java.awt.Frame;
26+
import java.awt.KeyboardFocusManager;
2827
import java.awt.List;
2928
import java.awt.Panel;
3029
import java.awt.Point;
@@ -51,7 +50,7 @@
5150
* @run main KeyEventsTest
5251
*/
5352
public class KeyEventsTest {
54-
TestState currentState;
53+
private volatile TestState currentState;
5554
final Object LOCK = new Object();
5655
final int ACTION_TIMEOUT = 500;
5756

@@ -66,16 +65,14 @@ public static void main(final String[] args) throws Exception {
6665
r = new Robot();
6766
KeyEventsTest app = new KeyEventsTest();
6867
try {
69-
EventQueue.invokeAndWait(app::initAndShowGui);
68+
app.initAndShowGui();
7069
r.waitForIdle();
7170
r.delay(500);
7271
app.doTest();
7372
} finally {
74-
EventQueue.invokeAndWait(() -> {
75-
if (app.keyFrame != null) {
76-
app.keyFrame.dispose();
77-
}
78-
});
73+
if (app.keyFrame != null) {
74+
app.keyFrame.dispose();
75+
}
7976
}
8077
}
8178

@@ -184,52 +181,51 @@ private void test(TestState currentState) throws Exception {
184181
throw new RuntimeException("Test failed - list isn't focus owner.");
185182
}
186183

187-
EventQueue.invokeAndWait(() -> {
188-
list.deselect(0);
189-
list.deselect(1);
190-
list.deselect(2);
191-
list.deselect(3);
192-
list.deselect(4);
193-
list.deselect(5);
194-
list.deselect(6);
195-
list.deselect(7);
196-
list.deselect(8);
197-
198-
int selectIndex = 0;
199-
int visibleIndex = 0;
200-
201-
if (currentState.getScrollMoved()) {
202-
if (currentState.getKeyID() == KeyEvent.VK_PAGE_UP ||
203-
currentState.getKeyID() == KeyEvent.VK_HOME) {
204-
selectIndex = 8;
205-
visibleIndex = 8;
206-
} else if (currentState.getKeyID() == KeyEvent.VK_PAGE_DOWN ||
207-
currentState.getKeyID() == KeyEvent.VK_END) {
184+
list.deselect(0);
185+
list.deselect(1);
186+
list.deselect(2);
187+
list.deselect(3);
188+
list.deselect(4);
189+
list.deselect(5);
190+
list.deselect(6);
191+
list.deselect(7);
192+
list.deselect(8);
193+
194+
int selectIndex = 0;
195+
int visibleIndex = 0;
196+
197+
if (currentState.getScrollMoved()) {
198+
if (currentState.getKeyID() == KeyEvent.VK_PAGE_UP ||
199+
currentState.getKeyID() == KeyEvent.VK_HOME) {
200+
selectIndex = 8;
201+
visibleIndex = 8;
202+
} else if (currentState.getKeyID() == KeyEvent.VK_PAGE_DOWN ||
203+
currentState.getKeyID() == KeyEvent.VK_END) {
204+
selectIndex = 0;
205+
visibleIndex = 0;
206+
}
207+
} else {
208+
if (currentState.getKeyID() == KeyEvent.VK_PAGE_UP ||
209+
currentState.getKeyID() == KeyEvent.VK_HOME) {
210+
if (currentState.getSelectedMoved()) {
211+
selectIndex = 1;
212+
} else {
208213
selectIndex = 0;
209-
visibleIndex = 0;
210214
}
211-
} else {
212-
if (currentState.getKeyID() == KeyEvent.VK_PAGE_UP ||
213-
currentState.getKeyID() == KeyEvent.VK_HOME) {
214-
if (currentState.getSelectedMoved()) {
215-
selectIndex = 1;
216-
} else {
217-
selectIndex = 0;
218-
}
219-
visibleIndex = 0;
220-
} else if (currentState.getKeyID() == KeyEvent.VK_PAGE_DOWN ||
221-
currentState.getKeyID() == KeyEvent.VK_END) {
222-
if (currentState.getSelectedMoved()) {
223-
selectIndex = 7;
224-
} else {
225-
selectIndex = 8;
226-
}
227-
visibleIndex = 8;
215+
visibleIndex = 0;
216+
} else if (currentState.getKeyID() == KeyEvent.VK_PAGE_DOWN ||
217+
currentState.getKeyID() == KeyEvent.VK_END) {
218+
if (currentState.getSelectedMoved()) {
219+
selectIndex = 7;
220+
} else {
221+
selectIndex = 8;
228222
}
223+
visibleIndex = 8;
229224
}
230-
list.select(selectIndex);
231-
list.makeVisible(visibleIndex);
232-
});
225+
}
226+
list.select(selectIndex);
227+
list.makeVisible(visibleIndex);
228+
233229

234230
r.delay(10);
235231
r.waitForIdle();
@@ -309,7 +305,7 @@ class TestState {
309305
private final boolean scrollMoved;
310306
private final int keyID;
311307
private final boolean template;
312-
private boolean action;
308+
private volatile boolean action;
313309

314310
public TestState(boolean multiple, boolean selectedMoved, boolean scrollMoved, int keyID, boolean template){
315311
this.multiple = multiple;

test/jdk/java/awt/Paint/ButtonRepaint.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -21,28 +21,32 @@
2121
* questions.
2222
*/
2323

24-
25-
import java.awt.*;
24+
import java.awt.Button;
25+
import java.awt.EventQueue;
26+
import java.awt.Frame;
27+
import java.awt.Graphics;
2628

2729
/**
2830
* @test
2931
* @key headful
3032
* @bug 7090424
31-
* @author Sergey Bylokhov
3233
*/
3334
public final class ButtonRepaint extends Button {
3435

3536
public static void main(final String[] args) {
3637
for (int i = 0; i < 10; ++i) {
37-
final Frame frame = new Frame();
38-
frame.setSize(300, 300);
39-
frame.setLocationRelativeTo(null);
40-
ButtonRepaint button = new ButtonRepaint();
41-
frame.add(button);
42-
frame.setVisible(true);
43-
sleep();
44-
button.test();
45-
frame.dispose();
38+
Frame frame = new Frame();
39+
try {
40+
frame.setSize(300, 300);
41+
frame.setLocationRelativeTo(null);
42+
ButtonRepaint button = new ButtonRepaint();
43+
frame.add(button);
44+
frame.setVisible(true);
45+
sleep();
46+
button.test();
47+
} finally {
48+
frame.dispose();
49+
}
4650
}
4751
}
4852

test/jdk/java/awt/Paint/CheckboxRepaint.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -21,27 +21,32 @@
2121
* questions.
2222
*/
2323

24-
import java.awt.*;
24+
import java.awt.Checkbox;
25+
import java.awt.EventQueue;
26+
import java.awt.Frame;
27+
import java.awt.Graphics;
2528

2629
/**
2730
* @test
2831
* @key headful
2932
* @bug 7090424
30-
* @author Sergey Bylokhov
3133
*/
3234
public final class CheckboxRepaint extends Checkbox {
3335

3436
public static void main(final String[] args) {
3537
for (int i = 0; i < 10; ++i) {
36-
final Frame frame = new Frame();
37-
frame.setSize(300, 300);
38-
frame.setLocationRelativeTo(null);
39-
CheckboxRepaint checkbox = new CheckboxRepaint();
40-
frame.add(checkbox);
41-
frame.setVisible(true);
42-
sleep();
43-
checkbox.test();
44-
frame.dispose();
38+
Frame frame = new Frame();
39+
try {
40+
frame.setSize(300, 300);
41+
frame.setLocationRelativeTo(null);
42+
CheckboxRepaint checkbox = new CheckboxRepaint();
43+
frame.add(checkbox);
44+
frame.setVisible(true);
45+
sleep();
46+
checkbox.test();
47+
} finally {
48+
frame.dispose();
49+
}
4550
}
4651
}
4752

test/jdk/java/awt/Paint/LabelRepaint.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,21 +30,23 @@
3030
* @test
3131
* @key headful
3232
* @bug 7090424
33-
* @author Sergey Bylokhov
3433
*/
3534
public final class LabelRepaint extends Label {
3635

3736
public static void main(final String[] args) {
3837
for (int i = 0; i < 10; ++i) {
39-
final Frame frame = new Frame();
40-
frame.setSize(300, 300);
41-
frame.setLocationRelativeTo(null);
42-
LabelRepaint label = new LabelRepaint();
43-
frame.add(label);
44-
frame.setVisible(true);
45-
sleep();
46-
label.test();
47-
frame.dispose();
38+
Frame frame = new Frame();
39+
try {
40+
frame.setSize(300, 300);
41+
frame.setLocationRelativeTo(null);
42+
LabelRepaint label = new LabelRepaint();
43+
frame.add(label);
44+
frame.setVisible(true);
45+
sleep();
46+
label.test();
47+
} finally {
48+
frame.dispose();
49+
}
4850
}
4951
}
5052

0 commit comments

Comments
 (0)