src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java
changeset 52242 7bd9745e8e15
parent 47216 71c04702a3d5
equal deleted inserted replaced
52241:5fc701128281 52242:7bd9745e8e15
    35 
    35 
    36 import javax.swing.*;
    36 import javax.swing.*;
    37 import javax.swing.border.Border;
    37 import javax.swing.border.Border;
    38 import javax.swing.plaf.UIResource;
    38 import javax.swing.plaf.UIResource;
    39 
    39 
    40 import jdk.internal.loader.ClassLoaders;
       
    41 
       
    42 import sun.awt.AppContext;
    40 import sun.awt.AppContext;
    43 
    41 
    44 import sun.lwawt.macosx.CPlatformWindow;
    42 import sun.lwawt.macosx.CPlatformWindow;
    45 import sun.reflect.misc.ReflectUtil;
    43 import sun.reflect.misc.ReflectUtil;
    46 import sun.security.action.GetPropertyAction;
    44 import sun.security.action.GetPropertyAction;
   282 
   280 
   283         @Override
   281         @Override
   284         public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
   282         public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
   285             final BufferedImage img = new BufferedImage(width + blur * 2, height + blur * 2, BufferedImage.TYPE_INT_ARGB_PRE);
   283             final BufferedImage img = new BufferedImage(width + blur * 2, height + blur * 2, BufferedImage.TYPE_INT_ARGB_PRE);
   286             paintToImage(img, x, y, width, height);
   284             paintToImage(img, x, y, width, height);
   287 //            debugFrame("border", img);
       
   288             g.drawImage(img, -blur, -blur, null);
   285             g.drawImage(img, -blur, -blur, null);
   289         }
   286         }
   290 
   287 
   291         private void paintToImage(final BufferedImage img, final int x, final int y, final int width, final int height) {
   288         private void paintToImage(final BufferedImage img, final int x, final int y, final int width, final int height) {
   292             // clear the prior image
   289             // clear the prior image
   323         SlicedShadowBorder(final Painter prePainter, final Painter postPainter, final int offsetX, final int offsetY, final float distance, final float intensity, final int blur, final int templateWidth, final int templateHeight, final int leftCut, final int topCut, final int rightCut, final int bottomCut) {
   320         SlicedShadowBorder(final Painter prePainter, final Painter postPainter, final int offsetX, final int offsetY, final float distance, final float intensity, final int blur, final int templateWidth, final int templateHeight, final int leftCut, final int topCut, final int rightCut, final int bottomCut) {
   324             super(prePainter, postPainter, offsetX, offsetY, distance, intensity, blur);
   321             super(prePainter, postPainter, offsetX, offsetY, distance, intensity, blur);
   325 
   322 
   326             final BufferedImage i = new BufferedImage(templateWidth, templateHeight, BufferedImage.TYPE_INT_ARGB_PRE);
   323             final BufferedImage i = new BufferedImage(templateWidth, templateHeight, BufferedImage.TYPE_INT_ARGB_PRE);
   327             super.paintBorder(null, i.getGraphics(), 0, 0, templateWidth, templateHeight);
   324             super.paintBorder(null, i.getGraphics(), 0, 0, templateWidth, templateHeight);
   328 //            debugFrame("slices", i);
       
   329             slices = new SlicedImageControl(i, leftCut, topCut, rightCut, bottomCut, false);
   325             slices = new SlicedImageControl(i, leftCut, topCut, rightCut, bottomCut, false);
   330         }
   326         }
   331 
   327 
   332         @Override
   328         @Override
   333         public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
   329         public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
   334             slices.paint(g, x, y, width, height);
   330             slices.paint(g, x, y, width, height);
   335         }
   331         }
   336     }
       
   337 
       
   338 //    static void debugFrame(String name, Image image) {
       
   339 //        JFrame f = new JFrame(name);
       
   340 //        f.setContentPane(new JLabel(new ImageIcon(image)));
       
   341 //        f.pack();
       
   342 //        f.setVisible(true);
       
   343 //    }
       
   344 
       
   345     // special casing naughty applications, like InstallAnywhere
       
   346     // <rdar://problem/4851533> REGR: JButton: Myst IV: the buttons of 1.0.3 updater have redraw issue
       
   347     static boolean shouldUseOpaqueButtons() {
       
   348         // can we use ClassLoader.getSystemClassLoader here?
       
   349         final ClassLoader launcherClassLoader = ClassLoaders.appClassLoader();
       
   350         if (classExists(launcherClassLoader, "com.installshield.wizard.platform.macosx.MacOSXUtils")) return true;
       
   351         return false;
       
   352     }
       
   353 
       
   354     private static boolean classExists(final ClassLoader classLoader, final String clazzName) {
       
   355         try {
       
   356             return Class.forName(clazzName, false, classLoader) != null;
       
   357         } catch (final Throwable ignored) { }
       
   358         return false;
       
   359     }
   332     }
   360 
   333 
   361     private static final RecyclableSingleton<Method> getJComponentGetFlagMethod = new RecyclableSingleton<Method>() {
   334     private static final RecyclableSingleton<Method> getJComponentGetFlagMethod = new RecyclableSingleton<Method>() {
   362         @Override
   335         @Override
   363         protected Method getInstance() {
   336         protected Method getInstance() {