Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/swing/JButton/6604281/bug6604281.java
41153 views
1
/*
2
* Copyright (c) 2008, 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 6604281
26
@summary NimbusL&F :Regression in Focus traversal in JFileChooser in pit build
27
@author Pavel Porvatov
28
@run main bug6604281
29
*/
30
31
import javax.swing.*;
32
import javax.swing.plaf.IconUIResource;
33
import javax.swing.plaf.synth.SynthLookAndFeel;
34
import java.awt.*;
35
import java.awt.image.BufferedImage;
36
import java.lang.reflect.InvocationTargetException;
37
38
public class bug6604281 {
39
public static void main(String[] args) throws InvocationTargetException, InterruptedException {
40
SwingUtilities.invokeAndWait(new Runnable() {
41
public void run() {
42
SynthLookAndFeel laf = new SynthLookAndFeel();
43
try {
44
UIManager.setLookAndFeel(laf);
45
} catch (Exception e) {
46
fail(e.getMessage());
47
}
48
49
// Prepare image
50
BufferedImage image = new BufferedImage(32, 32, BufferedImage.TYPE_INT_RGB);
51
52
Graphics2D graphics = (Graphics2D) image.getGraphics();
53
54
graphics.setColor(Color.BLUE);
55
graphics.fillRect(0, 0, image.getWidth(), image.getHeight());
56
graphics.setColor(Color.RED);
57
graphics.drawLine(0, 0, image.getWidth(), image.getHeight());
58
59
// Use IconUIResource as an icon, because with ImageIcon bug is not reproduced
60
JButton button1 = new JButton(new IconUIResource(new ImageIcon(image)));
61
62
JButton button2 = new JButton(new IconUIResource(new ImageIcon(image)));
63
64
button2.setEnabled(false);
65
66
if (button1.getPreferredSize().getHeight() != button2.getPreferredSize().getHeight()) {
67
fail("Two similar buttons have different size");
68
}
69
}
70
});
71
}
72
73
private static void fail(String s) {
74
throw new RuntimeException("Test failed: " + s);
75
}
76
}
77
78