Skip to content

Commit ae74a95

Browse files
author
duke
committed
Backport fe98f86b5792cbb17d47871452d27ab87d72b342
1 parent 1a06a61 commit ae74a95

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright (c) 2002, 2024, 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+
/*
25+
* @test
26+
* @bug 4587721
27+
* @summary Tests if JFileChooser details view chops off text
28+
* @library /java/awt/regtesthelpers
29+
* @build PassFailJFrame
30+
* @run main/manual bug4587721
31+
*/
32+
33+
import java.awt.Font;
34+
import java.util.Enumeration;
35+
36+
import javax.swing.JFileChooser;
37+
import javax.swing.UIDefaults;
38+
import javax.swing.UIManager;
39+
import javax.swing.plaf.FontUIResource;
40+
import javax.swing.plaf.metal.MetalLookAndFeel;
41+
42+
public class bug4587721 {
43+
44+
public static void main(String[] args) throws Exception {
45+
UIManager.setLookAndFeel(new MetalLookAndFeel());
46+
47+
String instructions = """
48+
Click on the Details button in JFileChooser Window.
49+
If the filename text is chopped off by height,
50+
then Press FAIL else Press PASS.
51+
""";
52+
53+
PassFailJFrame.builder()
54+
.title("bug4587721")
55+
.instructions(instructions)
56+
.columns(40)
57+
.testUI(bug4587721::createUI)
58+
.build()
59+
.awaitAndCheck();
60+
}
61+
62+
public static JFileChooser createUI() {
63+
setFonts();
64+
JFileChooser fc = new JFileChooser();
65+
return fc;
66+
}
67+
68+
public static void setFonts() {
69+
UIDefaults defaults = UIManager.getDefaults();
70+
Enumeration keys = defaults.keys();
71+
while (keys.hasMoreElements()) {
72+
Object key = keys.nextElement();
73+
if (defaults.get(key) instanceof Font)
74+
UIManager.put(key, new FontUIResource(new Font("Courier", Font.BOLD, 30)));
75+
}
76+
}
77+
}

0 commit comments

Comments
 (0)