Skip to content

Commit d6b7816

Browse files
committedJan 20, 2025
8341453: java/awt/a11y/AccessibleJTableTest.java fails in some cases where the test tables are not visible
Backport-of: f1f15370fa26e4c1121abadb8938c0126c6f4f24
1 parent 4a8fbb3 commit d6b7816

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed
 

‎test/jdk/java/awt/a11y/AccessibleJTableTest.java

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2021, JetBrains s.r.o.. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -26,22 +26,22 @@
2626
* @test
2727
* @bug 8267388
2828
* @summary Test implementation of NSAccessibilityTable protocol peer
29-
* @author Artem.Semenov@jetbrains.com
3029
* @run main/manual AccessibleJTableTest
3130
* @requires (os.family == "windows" | os.family == "mac")
3231
*/
3332

34-
import javax.swing.*;
35-
import javax.swing.event.TableModelEvent;
36-
import javax.swing.event.TableModelListener;
37-
import javax.swing.table.AbstractTableModel;
38-
import javax.swing.table.TableModel;
39-
40-
import java.awt.*;
33+
import java.awt.FlowLayout;
34+
import java.awt.GridLayout;
4135
import java.awt.event.ActionEvent;
4236
import java.awt.event.ActionListener;
4337
import java.util.concurrent.CountDownLatch;
4438
import java.util.concurrent.TimeUnit;
39+
import javax.swing.JButton;
40+
import javax.swing.JPanel;
41+
import javax.swing.JScrollPane;
42+
import javax.swing.JTable;
43+
import javax.swing.SwingUtilities;
44+
import javax.swing.table.AbstractTableModel;
4545

4646
public class AccessibleJTableTest extends AccessibleComponentTest {
4747
private static final String[] columnNames = {"One", "Two", "Three"};
@@ -67,6 +67,7 @@ public void createUI() {
6767
+ "If you can hear table cells ctrl+tab further and press PASS, otherwise press FAIL.\n";
6868

6969
JTable table = new JTable(data, columnNames);
70+
table.setPreferredScrollableViewportSize(table.getPreferredSize());
7071
JPanel panel = new JPanel();
7172
panel.setLayout(new FlowLayout());
7273
JScrollPane scrollPane = new JScrollPane(table);
@@ -82,12 +83,13 @@ public void createUIDraggable() {
8283
+ "Turn screen reader on, and Tab to the table.\n"
8384
+ "Using arrow keys navigate to the last cell in the first row in the table."
8485
+ "Screen reader should announce it as \"Column 3 row 1\"\n\n"
85-
+ "Using mouse drag the header of the last culumn so the last column becomes the first one."
86+
+ "Using mouse drag the header of the last column so the last column becomes the first one."
8687
+ "Wait for the screen reader to finish announcing new position in table.\n\n"
8788
+ "If new position in table corresponds to the new table layout ctrl+tab further "
8889
+ "and press PASS, otherwise press FAIL.\n";
8990

9091
JTable table = new JTable(data, columnNames);
92+
table.setPreferredScrollableViewportSize(table.getPreferredSize());
9193
JPanel panel = new JPanel();
9294
panel.setLayout(new FlowLayout());
9395
JScrollPane scrollPane = new JScrollPane(table);
@@ -105,7 +107,9 @@ public void createUINamed() {
105107
+ "If you can hear second table name: \"second table\" - ctrl+tab further and press PASS, otherwise press FAIL.\n";
106108

107109
JTable table = new JTable(data, columnNames);
110+
table.setPreferredScrollableViewportSize(table.getPreferredSize());
108111
JTable secondTable = new JTable(data, columnNames);
112+
secondTable.setPreferredScrollableViewportSize(secondTable.getPreferredSize());
109113
secondTable.getAccessibleContext().setAccessibleName("Second table");
110114
JPanel panel = new JPanel();
111115
panel.setLayout(new FlowLayout());
@@ -126,8 +130,8 @@ public void createUIWithChangingContent() {
126130
+ "If you hear changes in the table - ctrl+tab further and press PASS, otherwise press FAIL.\n";
127131

128132
JTable table = new JTable(new TestTableModel(3, 3));
129-
130-
JPanel panel = new JPanel();
133+
table.setPreferredScrollableViewportSize(table.getPreferredSize());
134+
JPanel panel = new JPanel();
131135
panel.setLayout(new FlowLayout());
132136
JScrollPane scrollPane = new JScrollPane(table);
133137
panel.add(scrollPane);

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Jan 20, 2025

@openjdk-notifier[bot]
Please sign in to comment.