{
// Disassembles image into editor data
try
{
// If image was actually a nine-patch image
this.ninePatchIcon = new NinePatchIcon ( ninePatchImage );
this.ninePatchImage = ninePatchImage;
}
catch ( final IllegalArgumentException e )
{
// If image is not a nine-patch image we will fix it to be one
final BufferedImage fixedImage = ImageUtils
.createCompatibleImage ( ninePatchImage.getWidth () + 2, ninePatchImage.getHeight () + 2, Transparency.TRANSLUCENT );
final Graphics2D g2d = fixedImage.createGraphics ();
g2d.drawImage ( ninePatchImage, 1, 1, null );
g2d.setPaint ( Color.BLACK );
g2d.drawLine ( 1, 0, fixedImage.getWidth () - 2, 0 );
g2d.drawLine ( 0, 1, 0, fixedImage.getHeight () - 2 );
g2d.dispose ();
this.ninePatchIcon = new NinePatchIcon ( fixedImage );
this.ninePatchImage = fixedImage;
}
}