cbdia.show();
cbdia.setVisible(true);
    public void actionPerformed(ActionEvent ae)    {        // respond to each component        if (ae.getActionCommand().equals("tilesetSelector"))        {            doTilesetSelectAction();        }        else if (ae.getActionCommand().equals("paletteSelector"))        {            updateTileSelector();            updateArrangementSelector();            updateArrangementEditor();            updatePaletteDisplay();            updateTileGraphicsEditor();        }        else if (ae.getActionCommand().equals("subPaletteSelector"))        {            updateTileSelector();            updatePaletteDisplay();            updateTileGraphicsEditor();        }        else if (ae.getActionCommand().equals("tileSelector"))        {            updateTileGraphicsEditor();            if (!(this.getCurrentComponent() instanceof IntArrDrawingArea))                setFocus(tileDrawingArea);        }        else if (ae.getActionCommand().equals("arrangementSelector"))        {            resetArrangementUndo();            arrangementEditor.clearSelection();            updateCollisionEditor();            updateArrangementEditor();            if (this.getCurrentComponent() instanceof IntArrDrawingArea)                setFocus(arrangementEditor);        }        else if (ae.getActionCommand().equals("arrangementEditor"))        {            setFocus((Component) ae.getSource());            // updateArrangementSelector();            arrangementSelector.repaintCurrentArrangement();        }        else if (ae.getActionCommand().equals("tileDrawingArea"))        {            setFocus((Component) ae.getSource());            getSelectedTileset().setTile(getCurrentTile(),                tileDrawingArea.getByteArrImage());            tileSelector.repaintCurrent();            arrangementSelector.repaintCurrentTile();            arrangementEditor.repaintCurrentTile();        }        else if (ae.getActionCommand().equals("paletteEditor"))        {            getSelectedTileset().setPaletteColor(                tileDrawingPalette.getSelectedColorIndex(),                getCurrentPalette(), getCurrentSubPalette(),                tileDrawingPalette.getNewColor());            updatePaletteDisplay();            updateTileGraphicsEditor();            updateTileSelector();            updateArrangementSelector();            updateArrangementEditor();        }        else if (ae.getActionCommand().equalsIgnoreCase(            "tileForegroundDrawingArea"))        {            setFocus((Component) ae.getSource());            getSelectedTileset().setTile(getCurrentTile() + 512,                tileForegroundDrawingArea.getByteArrImage());        }        // default window stuff        else if (ae.getActionCommand().equals("apply"))        {            // writeInfo(true);            writeInfo(rom);        }        else if (ae.getActionCommand().equals("close"))        {            hide();        }        // flipping        else if (ae.getActionCommand().equals("hFlip"))        {            if (getCurrentComponent() instanceof ImageDrawingArea)                ((ImageDrawingArea) getCurrentComponent()).doHFlip();        }        else if (ae.getActionCommand().equals("vFlip"))        {            if (getCurrentComponent() instanceof ImageDrawingArea)                ((ImageDrawingArea) getCurrentComponent()).doVFlip();        }        // undo        else if (ae.getActionCommand().equals("undo"))        {            getCurrentUndoable().undo();            getCurrentComponent().repaint();        }        // copy&paste stuff        else if (ae.getActionCommand().equals("cut"))        {            getCurrentCopyAndPaster().cut();            getCurrentComponent().repaint();        }        else if (ae.getActionCommand().equals("copy"))        {            getCurrentCopyAndPaster().copy();            getCurrentComponent().repaint();        }        else if (ae.getActionCommand().equals("paste"))        {            getCurrentCopyAndPaster().paste();            getCurrentComponent().repaint();        }        else if (ae.getActionCommand().equals("delete"))        {            getCurrentCopyAndPaster().delete();            getCurrentComponent().repaint();        }        // copy&paste both stuff        else if (ae.getActionCommand().equals("cutBoth"))        {            this.cutBoth();        }        else if (ae.getActionCommand().equals("copyBoth"))        {            this.copyBoth();        }        else if (ae.getActionCommand().equals("pasteBoth"))        {            this.pasteBoth();        }        else if (ae.getActionCommand().equals("deleteBoth"))        {            this.deleteBoth();        }        // copy&paste cb stuff        else if (ae.getActionCommand().equals("cb_show"))        {            if (cbdia == null)                initCbDia();            cbdia.show();        }        else if (ae.getActionCommand().equals("cb_copy"))        {            int i = cbsel.getCurrentTile();            byte[][] fg = tileForegroundDrawingArea.getByteArrImage(), bg = tileDrawingArea                .getByteArrImage();            for (int x = 0; x < 8; x++)            {                System.arraycopy(bg[x], 0, cb[i][0][x], 0, 8);                System.arraycopy(fg[x], 0, cb[i][1][x], 0, 8);            }            cbsel.repaintCurrent();        }        else if (ae.getActionCommand().equals("cb_paste"))        {            int i = cbsel.getCurrentTile();            byte[][] fg = new byte[8][8], bg = new byte[8][8];            for (int x = 0; x < 8; x++)            {                System.arraycopy(cb[i][0][x], 0, bg[x], 0, 8);                System.arraycopy(cb[i][1][x], 0, fg[x], 0, 8);            }            tileDrawingArea.paste(bg, true);            tileDrawingArea.repaint();            tileForegroundDrawingArea.paste(fg, true);            tileForegroundDrawingArea.repaint();        }        // backgroud <--> foreground copies        else if (ae.getActionCommand().equals("bfCopy"))        {            this.tileForegroundDrawingArea.setImage(this.tileDrawingArea                .getIntArrImage());            this.tileForegroundDrawingArea.repaint();            this.setFocus(tileForegroundDrawingArea);        }        else if (ae.getActionCommand().equals("fbCopy"))        {            this.tileDrawingArea.setImage(this.tileForegroundDrawingArea                .getIntArrImage());            this.tileDrawingArea.repaint();            this.setFocus(tileDrawingArea);        }        // gridline toggle        else if (ae.getActionCommand().equals("tileSelGridLines"))        {            mainWindow.getContentPane().invalidate();            tileSelector.invalidate();            tileSelector.resetPreferredSize();            tileSelector.validate();            tileSelector.repaint();            mainWindow.getContentPane().validate();            if (cbdia != null)            {                cbdia.invalidate();                cbsel.invalidate();                cbsel.resetPreferredSize();                cbsel.validate();                cbsel.repaint();                cbdia.validate();                cbdia.pack();            }        }        else if (ae.getActionCommand().equals("arrEdGridLines"))        {            mainWindow.getContentPane().invalidate();            arrangementEditor.invalidate();            arrangementEditor.resetPreferredSize();            arrangementEditor.validate();            arrangementEditor.repaint();            mainWindow.getContentPane().validate();        }        // import/export        else if (ae.getActionCommand().equals("importTile"))        {            importTile(getCurrentTileset(), getCurrentTile());            updateTileGraphicsEditor();            updateTileSelector();        }        else if (ae.getActionCommand().equals("exportTile"))        {            exportTile(getCurrentTileset(), getCurrentTile());        }        else if (ae.getActionCommand().equals("importPal"))        {            importPalette(getCurrentTileset(), getCurrentPalette());            updateTileSelector();            updateArrangementSelector();            updateArrangementEditor();            updatePaletteDisplay();            updateTileGraphicsEditor();        }        else if (ae.getActionCommand().equals("exportPal"))        {            exportPalette(getCurrentTileset(), getCurrentPalette());        }        else if (ae.getActionCommand().equals("importTileset"))        {            importTileset(getCurrentTileset());            updateTileGraphicsEditor();            updateTileSelector();        }        else if (ae.getActionCommand().equals("exportTileset"))        {            exportTileset(getCurrentTileset());        }        else if (ae.getActionCommand().equals("importCollision"))        {            importCollision(getCurrentTileset());            updateCollisionEditor();        }        else if (ae.getActionCommand().equals("exportCollision"))        {            exportCollision(getCurrentTileset());        }        else if (ae.getActionCommand().equals("importAllTileset"))        {            importAllTileset(getCurrentTileset());            updatePaletteDisplay();            updateTileGraphicsEditor();            updateTileSelector();            resetArrangementUndo();            updateCollisionEditor();            updateArrangementSelector();            updateArrangementEditor();        }        else if (ae.getActionCommand().equals("exportAllTileset"))        {            exportAllTileset(getCurrentTileset());        }        else if (ae.getActionCommand().equals("importAll"))        {            importAll();            updatePaletteDisplay();            updateTileGraphicsEditor();            updateTileSelector();            resetArrangementUndo();            updateCollisionEditor();            updateArrangementSelector();            updateArrangementEditor();        }        else if (ae.getActionCommand().equals("exportAll"))        {            exportAll();        }        // focus stuff        else if (ae.getActionCommand().equals("bgeFocus"))        {            setFocus(this.tileDrawingArea);        }        else if (ae.getActionCommand().equals("fgeFocus"))        {            setFocus(this.tileForegroundDrawingArea);        }        else if (ae.getActionCommand().equals("colFocus"))        {            setFocus(this.collisionEditor);        }        else if (ae.getActionCommand().equals("arrFocus"))        {            setFocus(this.arrangementEditor);        }        else if (ae.getActionCommand().equals("cycFocus"))        {            cycleFocus();        }        else        {            System.err.println("Uncaught action command in eb.TileEditor: "                + ae.getActionCommand());        }    }