getSelectedSprite().setSprite(da.getByteArrImage()); getSelectedSprite().writeInfo();
int curr = getCurrentSprite(); battleSprites[curr].setSprite(da.getByteArrImage()); battleSprites[curr].writeInfo();
    public void actionPerformed(ActionEvent ae)    {        if (ae.getActionCommand().equals(spriteSelector.getActionCommand()))        {            doSpriteSelectAction();        }        else if (ae.getActionCommand().equals(palSelector.getActionCommand()))        {            if (palSelector.getSelectedIndex() == -1)            {                try                {                    palSelector.setSelectedIndex(Integer.parseInt(palSelector                        .getSelectedItem().toString().trim().replaceAll(                            "[^\\d]", "")));                }                catch (NumberFormatException nfe)                {                    //we shouldn't get number format exceptions                    //the regular expression should remove all                    //non-digit characters                    System.err                        .println("This error cannot occur (BattleSpriteEditor"                            + ".actionPerformed(palSelector) "                            + "NumberFormatException).");                    nfe.printStackTrace();                    //set it back to a legal value                    palSelector.setSelectedIndex(currPal);                    return;                }                catch (IllegalArgumentException iae)                {                    //number out of range                    //would mean number too high, negitive is prevented                    //by the regular expression                    //change the palette selector back to what it was                    palSelector.setSelectedIndex(currPal);                    //previous line should have caused a call to this method,                    //no need to do it again                    return;                }            }            updatePalette();            da.repaint();        }        else if (ae.getActionCommand().equals(sizeSelector.getActionCommand()))        {            if ((sizeSelector.getSelectedIndex() + 1) != getSelectedSprite()                .getSize())            {                if (JOptionPane.showConfirmDialog(mainWindow,                    "Are you sure you wish to change the size of this "                        + "sprite to "                        + (sizeSelector.getSelectedItem().toString().split(                            "\\]")[1].trim()) + "? "                        + "Sprite data outside that area "                        + "will be permanently lost.", "Are you sure?",                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.CANCEL_OPTION)                {                    sizeSelector                        .setSelectedIndex(getSelectedSprite().getSize() - 1);                    return;                }                getSelectedSprite()                    .setSize(sizeSelector.getSelectedIndex() + 1);                da.setImage(getSelectedSprite().getSprite());                jsp.updateUI();            }        }        else if (ae.getActionCommand().equals("apply"))        {            getSelectedSprite().setSprite(da.getByteArrImage());            getSelectedSprite().writeInfo();            writePalettes(rom);            battleSpriteNames[spriteSelector.getSelectedIndex()] = name                .getText();            writeArray("insideSprites.txt", false, battleSpriteNames);        }        else if (ae.getActionCommand().equals("close"))        {            hide();        }        else if (ae.getActionCommand().equals("hFlip"))        {            da.doHFlip();        }        else if (ae.getActionCommand().equals("vFlip"))        {            da.doVFlip();        }        else if (ae.getActionCommand().equals("undo"))        {            da.undo();            da.repaint();        }        else if (ae.getActionCommand().equals("cut"))        {            da.cut();            da.repaint();        }        else if (ae.getActionCommand().equals("copy"))        {            da.copy();            da.repaint();        }        else if (ae.getActionCommand().equals("paste"))        {            da.paste();            da.repaint();        }        else if (ae.getActionCommand().equals("delete"))        {            da.delete();            da.repaint();        }        else if (ae.getActionCommand().equals(gridLines.getActionCommand()))        {            da.setDrawGridlines(gridLines.isSelected());            da.repaint();        }        else if (ae.getActionCommand().equals("paletteEditor"))        {            if (getCurrentPalNum() < 32)            {                getCurrentPal()[pal.getSelectedColorIndex()] = pal                    .getNewColor();                updatePalette();                da.repaint();            }            else            {                JOptionPane.showMessageDialog(mainWindow,                    "ERROR: You may not edit this palette!\n"                        + "This palette is past #31, and therefore\n"                        + "it is not a real palette, it is some part\n"                        + "of the battle swirl data. Editing it would\n"                        + "corrupt that data.",                    "Error, Unable to Edit Palette", JOptionPane.ERROR_MESSAGE);            }        }        else if (ae.getActionCommand().equals("importImg"))        {            importImg();        }        else if (ae.getActionCommand().equals("exportImg"))        {            exportImg();        }        else if (ae.getActionCommand().equals("importBmpImg"))        {            importBmpImg();        }    }