sp.setImage(ImageIO.read(f));  this.spriteDrawingArea.setImage(sp.getSprite()); this.spriteDrawingArea.repaint();
try { sp.setImage(ImageIO.read(f));  this.spriteDrawingArea.setImage(sp.getSprite()); this.spriteDrawingArea.repaint(); } catch (ArrayIndexOutOfBoundsException e) { JOptionPane.showMessageDialog(mainWindow, "Image import failed due to an image of invalid size.\n" + "Try checking the size of the image " + "and changing the size\n" + "of the target sprite using the " + "SPT editor if necessary.\n" + "Also note that this feature is only to be used\n" + "with sprite images exported by JHack and having\n" + "identical palettes.", "Error: Import Failed", JOptionPane.ERROR_MESSAGE); }
    public void importImg(File f)    {        if (f == null)            return;        try        {            if (!f.exists())                throw new FileNotFoundException();            Sprite sp = new Sprite(getSpriteInfo(HackModule.getNumberOfString(                selector.getSelectedItem().toString(), false)), this);            sp.setImage(ImageIO.read(f));            //this.spriteDrawingArea.setImage(sp.getImage());            this.spriteDrawingArea.setImage(sp.getSprite());            this.spriteDrawingArea.repaint();        }        catch (IOException e)        {            System.out.println("Unable to read image: " + f.toString());            e.printStackTrace();        }    }