1
1
/*
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.
3
3
* Copyright (c) 2021, JetBrains s.r.o.. All rights reserved.
4
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
5
*
26
26
* @test
27
27
* @bug 8267388
28
28
* @summary Test implementation of NSAccessibilityTable protocol peer
29
- * @author Artem.Semenov@jetbrains.com
30
29
* @run main/manual AccessibleJTableTest
31
30
* @requires (os.family == "windows" | os.family == "mac")
32
31
*/
33
32
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 ;
41
35
import java .awt .event .ActionEvent ;
42
36
import java .awt .event .ActionListener ;
43
37
import java .util .concurrent .CountDownLatch ;
44
38
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 ;
45
45
46
46
public class AccessibleJTableTest extends AccessibleComponentTest {
47
47
private static final String [] columnNames = {"One" , "Two" , "Three" };
@@ -67,6 +67,7 @@ public void createUI() {
67
67
+ "If you can hear table cells ctrl+tab further and press PASS, otherwise press FAIL.\n " ;
68
68
69
69
JTable table = new JTable (data , columnNames );
70
+ table .setPreferredScrollableViewportSize (table .getPreferredSize ());
70
71
JPanel panel = new JPanel ();
71
72
panel .setLayout (new FlowLayout ());
72
73
JScrollPane scrollPane = new JScrollPane (table );
@@ -82,12 +83,13 @@ public void createUIDraggable() {
82
83
+ "Turn screen reader on, and Tab to the table.\n "
83
84
+ "Using arrow keys navigate to the last cell in the first row in the table."
84
85
+ "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."
86
87
+ "Wait for the screen reader to finish announcing new position in table.\n \n "
87
88
+ "If new position in table corresponds to the new table layout ctrl+tab further "
88
89
+ "and press PASS, otherwise press FAIL.\n " ;
89
90
90
91
JTable table = new JTable (data , columnNames );
92
+ table .setPreferredScrollableViewportSize (table .getPreferredSize ());
91
93
JPanel panel = new JPanel ();
92
94
panel .setLayout (new FlowLayout ());
93
95
JScrollPane scrollPane = new JScrollPane (table );
@@ -105,7 +107,9 @@ public void createUINamed() {
105
107
+ "If you can hear second table name: \" second table\" - ctrl+tab further and press PASS, otherwise press FAIL.\n " ;
106
108
107
109
JTable table = new JTable (data , columnNames );
110
+ table .setPreferredScrollableViewportSize (table .getPreferredSize ());
108
111
JTable secondTable = new JTable (data , columnNames );
112
+ secondTable .setPreferredScrollableViewportSize (secondTable .getPreferredSize ());
109
113
secondTable .getAccessibleContext ().setAccessibleName ("Second table" );
110
114
JPanel panel = new JPanel ();
111
115
panel .setLayout (new FlowLayout ());
@@ -126,8 +130,8 @@ public void createUIWithChangingContent() {
126
130
+ "If you hear changes in the table - ctrl+tab further and press PASS, otherwise press FAIL.\n " ;
127
131
128
132
JTable table = new JTable (new TestTableModel (3 , 3 ));
129
-
130
- JPanel panel = new JPanel ();
133
+ table . setPreferredScrollableViewportSize ( table . getPreferredSize ());
134
+ JPanel panel = new JPanel ();
131
135
panel .setLayout (new FlowLayout ());
132
136
JScrollPane scrollPane = new JScrollPane (table );
133
137
panel .add (scrollPane );
1 commit comments
openjdk-notifier[bot] commentedon Jan 20, 2025
Review
Issues