Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JTree/8038113/bug8038113.java
38854 views
1
/*
2
* Copyright (c) 2014, 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
import java.awt.BasicStroke;
24
import java.awt.BorderLayout;
25
import java.awt.Graphics;
26
import java.awt.Graphics2D;
27
import javax.swing.Icon;
28
import javax.swing.JApplet;
29
import javax.swing.JPanel;
30
import javax.swing.JTree;
31
import javax.swing.SwingUtilities;
32
import javax.swing.plaf.basic.BasicTreeUI;
33
34
/* @test
35
* @bug 8038113
36
* @summary [macosx] JTree icon is not rendered in high resolution on Retina
37
* @run applet/manual=yesno bug8038113.html
38
*/
39
public class bug8038113 extends JApplet {
40
41
@Override
42
public void init() {
43
SwingUtilities.invokeLater(new Runnable() {
44
45
@Override
46
public void run() {
47
48
final JTree tree = new JTree();
49
final BasicTreeUI treeUI = (BasicTreeUI) tree.getUI();
50
51
final JPanel panel = new JPanel() {
52
53
@Override
54
public void paint(Graphics g) {
55
super.paint(g);
56
Graphics2D g2 = (Graphics2D) g;
57
g2.setStroke(new BasicStroke(0.5f));
58
g2.scale(2, 2);
59
60
int x = 10;
61
int y = 10;
62
Icon collapsedIcon = treeUI.getCollapsedIcon();
63
Icon expandeIcon = treeUI.getExpandedIcon();
64
int w = collapsedIcon.getIconWidth();
65
int h = collapsedIcon.getIconHeight();
66
collapsedIcon.paintIcon(this, g, x, y);
67
g.drawRect(x, y, w, h);
68
69
y += 10 + h;
70
w = expandeIcon.getIconWidth();
71
h = expandeIcon.getIconHeight();
72
expandeIcon.paintIcon(this, g, x, y);
73
g.drawRect(x, y, w, h);
74
75
}
76
};
77
getContentPane().setLayout(new BorderLayout());
78
getContentPane().add(panel, BorderLayout.CENTER);
79
}
80
});
81
}
82
}
83
84