private static BufferedImage scaleIcon(Icon icon,double scaleFactor){
  if (icon == null) {
    return null;
  }
  int w=icon.getIconWidth();
  int h=icon.getIconHeight();
  GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
  GraphicsDevice gd=ge.getDefaultScreenDevice();
  GraphicsConfiguration gc=gd.getDefaultConfiguration();
  BufferedImage iconImage=gc.createCompatibleImage(w,h,Transparency.TRANSLUCENT);
  Graphics2D g=iconImage.createGraphics();
  icon.paintIcon(null,g,0,0);
  g.dispose();
  int scaledW=(int)(w * scaleFactor);
  int scaledH=(int)(h * scaleFactor);
  BufferedImage scaledImage=gc.createCompatibleImage(scaledW,scaledH,Transparency.TRANSLUCENT);
  g=scaledImage.createGraphics();
  g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BILINEAR);
  g.drawImage(iconImage,0,0,scaledW,scaledH,null);
  g.dispose();
  return scaledImage;
}

private static BufferedImage scaleIcon ( Icon icon , double scaleFactor ) { if ( icon == null ) { return null ; } int w = icon . getIconWidth ( ) ; int h = icon . getIconHeight ( ) ; GraphicsEnvironment ge = GraphicsEnvironment . getLocalGraphicsEnvironment ( ) ; GraphicsDevice gd = ge . getDefaultScreenDevice ( ) ; GraphicsConfiguration gc = gd . getDefaultConfiguration ( ) ; BufferedImage iconImage = gc . createCompatibleImage ( w , h , Transparency . TRANSLUCENT ) ; Graphics2D g = iconImage . createGraphics ( ) ; icon . paintIcon ( null , g , 0 , 0 ) ; g . dispose ( ) ; int scaledW = ( int ) ( w * scaleFactor ) ; int scaledH = ( int ) ( h * scaleFactor ) ; BufferedImage scaledImage = gc . createCompatibleImage ( scaledW , scaledH , Transparency . TRANSLUCENT ) ; g = scaledImage . createGraphics ( ) ; g . setRenderingHint ( RenderingHints . KEY_INTERPOLATION , RenderingHints . VALUE_INTERPOLATION_BILINEAR ) ; g . drawImage ( iconImage , 0 , 0 , scaledW , scaledH , null ) ; g . dispose ( ) ; return scaledImage ; }
scales an icon using specified scale factor
