< prev index next >

src/java.desktop/share/classes/sun/awt/SunToolkit.java

Print this page




 851                 return false;
 852             }
 853         }
 854         return false;
 855     }
 856 
 857     private static void checkPermissions(String filename) {
 858         SecurityManager security = System.getSecurityManager();
 859         if (security != null) {
 860             security.checkRead(filename);
 861         }
 862     }
 863 
 864     private static void checkPermissions(URL url) {
 865         SecurityManager sm = System.getSecurityManager();
 866         if (sm != null) {
 867             try {
 868                 java.security.Permission perm =
 869                     URLUtil.getConnectPermission(url);
 870                 if (perm != null) {
 871                     try {
 872                         sm.checkPermission(perm);
 873                     } catch (SecurityException se) {
 874                         // fallback to checkRead/checkConnect for pre 1.2
 875                         // security managers
 876                         if ((perm instanceof java.io.FilePermission) &&
 877                             perm.getActions().indexOf("read") != -1) {
 878                             sm.checkRead(perm.getName());
 879                         } else if ((perm instanceof
 880                             java.net.SocketPermission) &&
 881                             perm.getActions().indexOf("connect") != -1) {
 882                             sm.checkConnect(url.getHost(), url.getPort());
 883                         } else {
 884                             throw se;
 885                         }
 886                     }
 887                 }
 888             } catch (java.io.IOException ioe) {
 889                     sm.checkConnect(url.getHost(), url.getPort());
 890             }
 891         }
 892     }
 893 
 894     /**
 895      * Scans {@code imageList} for best-looking image of specified dimensions.
 896      * Image can be scaled and/or padded with transparency.
 897      */
 898     public static BufferedImage getScaledIconImage(java.util.List<Image> imageList, int width, int height) {
 899         if (width == 0 || height == 0) {
 900             return null;
 901         }
 902         java.util.List<Image> multiResAndnormalImages = new ArrayList<>(imageList.size());
 903         for (Image image : imageList) {
 904             if ((image instanceof MultiResolutionImage)) {
 905                 Image im = ((MultiResolutionImage) image).getResolutionVariant(width, height);
 906                 multiResAndnormalImages.add(im);




 851                 return false;
 852             }
 853         }
 854         return false;
 855     }
 856 
 857     private static void checkPermissions(String filename) {
 858         SecurityManager security = System.getSecurityManager();
 859         if (security != null) {
 860             security.checkRead(filename);
 861         }
 862     }
 863 
 864     private static void checkPermissions(URL url) {
 865         SecurityManager sm = System.getSecurityManager();
 866         if (sm != null) {
 867             try {
 868                 java.security.Permission perm =
 869                     URLUtil.getConnectPermission(url);
 870                 if (perm != null) {

 871                     sm.checkPermission(perm);














 872                 }
 873             } catch (java.io.IOException ioe) {
 874                 sm.checkConnect(url.getHost(), url.getPort());
 875             }
 876         }
 877     }
 878 
 879     /**
 880      * Scans {@code imageList} for best-looking image of specified dimensions.
 881      * Image can be scaled and/or padded with transparency.
 882      */
 883     public static BufferedImage getScaledIconImage(java.util.List<Image> imageList, int width, int height) {
 884         if (width == 0 || height == 0) {
 885             return null;
 886         }
 887         java.util.List<Image> multiResAndnormalImages = new ArrayList<>(imageList.size());
 888         for (Image image : imageList) {
 889             if ((image instanceof MultiResolutionImage)) {
 890                 Image im = ((MultiResolutionImage) image).getResolutionVariant(width, height);
 891                 multiResAndnormalImages.add(im);


< prev index next >