Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JTree/8038113/bug8038113.java
38854 views
/*1* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/22import java.awt.BasicStroke;23import java.awt.BorderLayout;24import java.awt.Graphics;25import java.awt.Graphics2D;26import javax.swing.Icon;27import javax.swing.JApplet;28import javax.swing.JPanel;29import javax.swing.JTree;30import javax.swing.SwingUtilities;31import javax.swing.plaf.basic.BasicTreeUI;3233/* @test34* @bug 803811335* @summary [macosx] JTree icon is not rendered in high resolution on Retina36* @run applet/manual=yesno bug8038113.html37*/38public class bug8038113 extends JApplet {3940@Override41public void init() {42SwingUtilities.invokeLater(new Runnable() {4344@Override45public void run() {4647final JTree tree = new JTree();48final BasicTreeUI treeUI = (BasicTreeUI) tree.getUI();4950final JPanel panel = new JPanel() {5152@Override53public void paint(Graphics g) {54super.paint(g);55Graphics2D g2 = (Graphics2D) g;56g2.setStroke(new BasicStroke(0.5f));57g2.scale(2, 2);5859int x = 10;60int y = 10;61Icon collapsedIcon = treeUI.getCollapsedIcon();62Icon expandeIcon = treeUI.getExpandedIcon();63int w = collapsedIcon.getIconWidth();64int h = collapsedIcon.getIconHeight();65collapsedIcon.paintIcon(this, g, x, y);66g.drawRect(x, y, w, h);6768y += 10 + h;69w = expandeIcon.getIconWidth();70h = expandeIcon.getIconHeight();71expandeIcon.paintIcon(this, g, x, y);72g.drawRect(x, y, w, h);7374}75};76getContentPane().setLayout(new BorderLayout());77getContentPane().add(panel, BorderLayout.CENTER);78}79});80}81}828384