Skip to content

Commit be18e7e

Browse files
author
Damon Nguyen
committed
8064922: [macos] Test javax/swing/JTabbedPane/4624207/bug4624207.java fails
Reviewed-by: tr, honkar, psadhukhan
1 parent 0744db8 commit be18e7e

File tree

2 files changed

+28
-40
lines changed

2 files changed

+28
-40
lines changed

test/jdk/ProblemList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,6 @@ javax/swing/AbstractButton/6711682/bug6711682.java 8060765 windows-all,macosx-al
676676
javax/swing/JFileChooser/6396844/TwentyThousandTest.java 8198003 generic-all
677677
javax/swing/JFileChooser/8194044/FileSystemRootTest.java 8327236 windows-all
678678
javax/swing/JPopupMenu/6800513/bug6800513.java 7184956 macosx-all
679-
javax/swing/JTabbedPane/4624207/bug4624207.java 8064922 macosx-all
680679
javax/swing/SwingUtilities/TestBadBreak/TestBadBreak.java 8160720 generic-all
681680
javax/swing/JFileChooser/bug6798062.java 8146446 windows-all
682681
javax/swing/JPopupMenu/4870644/bug4870644.java 8194130 macosx-all,linux-all

test/jdk/javax/swing/JTabbedPane/4624207/bug4624207.java

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 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,25 +25,26 @@
2525
* @test
2626
* @key headful
2727
* @bug 4624207
28+
* @requires (os.family != "mac")
2829
* @summary JTabbedPane mnemonics don't work from outside the tabbed pane
29-
* @author Oleg Mokhovikov
30-
* @library /test/lib
31-
* @library ../../regtesthelpers
32-
* @build Util jdk.test.lib.Platform
3330
* @run main bug4624207
3431
*/
35-
import javax.swing.*;
36-
import javax.swing.event.ChangeEvent;
37-
import javax.swing.event.ChangeListener;
38-
import java.awt.*;
32+
33+
import java.awt.BorderLayout;
34+
import java.awt.Robot;
3935
import java.awt.event.FocusEvent;
4036
import java.awt.event.FocusListener;
4137
import java.awt.event.KeyEvent;
4238

43-
import jdk.test.lib.Platform;
39+
import javax.swing.JButton;
40+
import javax.swing.JFrame;
41+
import javax.swing.JTabbedPane;
42+
import javax.swing.JTextField;
43+
import javax.swing.SwingUtilities;
44+
import javax.swing.event.ChangeEvent;
45+
import javax.swing.event.ChangeListener;
4446

4547
public class bug4624207 implements ChangeListener, FocusListener {
46-
4748
private static volatile boolean stateChanged = false;
4849
private static volatile boolean focusGained = false;
4950
private static JTextField txtField;
@@ -71,51 +72,39 @@ public static void main(String[] args) throws Exception {
7172
Robot robot = new Robot();
7273
robot.setAutoDelay(50);
7374

74-
SwingUtilities.invokeAndWait(new Runnable() {
75-
76-
public void run() {
77-
createAndShowGUI();
78-
}
79-
});
80-
75+
SwingUtilities.invokeAndWait(() -> createAndShowGUI());
8176
robot.waitForIdle();
82-
83-
SwingUtilities.invokeAndWait(new Runnable() {
84-
85-
public void run() {
86-
txtField.requestFocus();
87-
}
88-
});
89-
77+
SwingUtilities.invokeAndWait(() -> txtField.requestFocus());
9078
robot.waitForIdle();
9179

9280
if (!focusGained) {
9381
throw new RuntimeException("Couldn't gain focus for text field");
9482
}
9583

96-
SwingUtilities.invokeAndWait(new Runnable() {
97-
98-
public void run() {
99-
tab.addChangeListener((ChangeListener) listener);
100-
txtField.removeFocusListener((FocusListener) listener);
101-
}
84+
SwingUtilities.invokeAndWait(() -> {
85+
tab.addChangeListener((ChangeListener) listener);
86+
txtField.removeFocusListener((FocusListener) listener);
10287
});
10388

10489
robot.waitForIdle();
10590

106-
if (Platform.isOSX()) {
107-
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_B);
108-
} else {
109-
Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_B);
110-
}
91+
robot.keyPress(KeyEvent.VK_ALT);
92+
robot.keyPress(KeyEvent.VK_B);
93+
robot.keyRelease(KeyEvent.VK_B);
94+
robot.keyRelease(KeyEvent.VK_ALT);
11195

11296
robot.waitForIdle();
11397

11498
if (!stateChanged || tab.getSelectedIndex() != 1) {
115-
throw new RuntimeException("JTabbedPane mnemonics don't work from outside the tabbed pane");
99+
throw new RuntimeException("JTabbedPane mnemonics don't " +
100+
"work from outside the tabbed pane");
116101
}
117102
} finally {
118-
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
103+
SwingUtilities.invokeAndWait(() -> {
104+
if (frame != null) {
105+
frame.dispose();
106+
}
107+
});
119108
}
120109
}
121110

0 commit comments

Comments
 (0)