Skip to content

Commit 365cb0b

Browse files
author
duke
committed
Backport 77b27893969d84de7c890a60c3cccb99e89d5d91
1 parent e78cfbe commit 365cb0b

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed

src/java.desktop/macosx/classes/com/apple/laf/AquaKeyBindings.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,8 @@ LateBoundInputMap getTableInputMap() {
383383
"ENTER", "selectNextRowCell",
384384
"shift ENTER", "selectPreviousRowCell",
385385
"alt TAB", "focusHeader",
386-
"alt shift TAB", "focusHeader"
386+
"alt shift TAB", "focusHeader",
387+
"F8", "focusHeader"
387388
}));
388389
}
389390

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
/*
24+
* @test
25+
* @bug 6394566
26+
* @key headful
27+
* @summary Tests that ESC moves the focus from the header to the table
28+
* @library ../../../../regtesthelpers
29+
* @build SwingTestHelper JRobot
30+
* @run main bug6394566
31+
*/
32+
33+
import java.awt.Component;
34+
import java.awt.event.KeyEvent;
35+
import java.awt.event.FocusEvent;
36+
import javax.swing.JScrollPane;
37+
import javax.swing.JTable;
38+
import javax.swing.table.JTableHeader;
39+
import javax.swing.table.DefaultTableModel;
40+
41+
public class bug6394566 extends SwingTestHelper {
42+
private JTable table;
43+
private JTableHeader header;
44+
45+
public static void main(String[] args) throws Throwable {
46+
new bug6394566().run(args);
47+
}
48+
49+
protected Component createContentPane() {
50+
table = new JTable(new DefaultTableModel(2, 2));
51+
header = table.getTableHeader();
52+
return new JScrollPane(table);
53+
}
54+
55+
public void onEDT10() {
56+
// Give the table the focus.
57+
requestAndWaitForFocus(table);
58+
}
59+
60+
//First, give the header focus using F8 on the JTable.
61+
//This will fail prior to mustang b72.
62+
public void onEDT20() {
63+
waitForEvent(header, FocusEvent.FOCUS_GAINED); //set up focus listener
64+
robot.hitKey(KeyEvent.VK_F8);
65+
}
66+
67+
//Next, give the table back the focus using ESC.
68+
//This will fail prior to the build with this bugfix.
69+
public void onEDT30() {
70+
waitForEvent(table, FocusEvent.FOCUS_GAINED); //set up focus listener
71+
robot.hitKey(KeyEvent.VK_ESCAPE);
72+
}
73+
}

0 commit comments

Comments
 (0)