protected static BufferedImage createBufferedImage(int width,int height,boolean hasAlpha){
  BufferedImage bimage=null;
  GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
  try {
    int transparency=Transparency.OPAQUE;
    if (hasAlpha) {
      transparency=Transparency.TRANSLUCENT;
    }
    GraphicsDevice gs=ge.getDefaultScreenDevice();
    GraphicsConfiguration gc=gs.getDefaultConfiguration();
    bimage=gc.createCompatibleImage(width,height,transparency);
  }
 catch (  HeadlessException e) {
  }
  if (bimage == null) {
    int type=BufferedImage.TYPE_INT_RGB;
    if (hasAlpha) {
      type=BufferedImage.TYPE_INT_ARGB;
    }
    bimage=new BufferedImage(width,height,type);
  }
  return bimage;
}

protected static BufferedImage createBufferedImage ( int width , int height , boolean hasAlpha ) { BufferedImage bimage = null ; GraphicsEnvironment ge = GraphicsEnvironment . getLocalGraphicsEnvironment ( ) ; try { int transparency = Transparency . OPAQUE ; if ( hasAlpha ) { transparency = Transparency . TRANSLUCENT ; } GraphicsDevice gs = ge . getDefaultScreenDevice ( ) ; GraphicsConfiguration gc = gs . getDefaultConfiguration ( ) ; bimage = gc . createCompatibleImage ( width , height , transparency ) ; } catch ( HeadlessException e ) { } if ( bimage == null ) { int type = BufferedImage . TYPE_INT_RGB ; if ( hasAlpha ) { type = BufferedImage . TYPE_INT_ARGB ; } bimage = new BufferedImage ( width , height , type ) ; } return bimage ; }
create a buffered image of the given width and height , compatible with the alpha requirement .
