tileset.setTilesetImageFilename(null);
    public void actionPerformed(ActionEvent event) {        Object source = event.getSource();        if (source == bOk) {            tileset.setName(tilesetNameEntry.getText());            this.dispose();        } else if (source == bDelete) {            int answer = JOptionPane.showConfirmDialog(                    this, "Delete tile?", "Are you sure?",                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);            if (answer == JOptionPane.YES_OPTION) {                Tile tile = (Tile)tileList.getSelectedValue();                if (tile != null) {                    tileset.removeTile(tile.getId());                }                queryTiles();            }        } else if (source == bChangeI) {            changeImage();        } else if (source == bNew) {            newTile();        } else if (source == bDuplicate) {            Tile n = new Tile(currentTile);            tileset.addNewTile(n);            queryTiles();            // Select the last (cloned) tile            tileList.setSelectedIndex(tileset.getTotalTiles() - 1);            tileList.ensureIndexIsVisible(tileset.getTotalTiles() - 1);        } else if (source == externalBitmapCheck) {            if (!externalBitmapCheck.isSelected()) {                int answer = JOptionPane.showConfirmDialog(                        this,                        "Warning: this operation cannot be reversed.  Disable "                        + "the use of an external bitmap?",                       "Are you sure?",                        JOptionPane.YES_NO_OPTION,                        JOptionPane.QUESTION_MESSAGE);                if (answer == JOptionPane.YES_OPTION) {                    //tileset.setTilebmpFile(null);                    updateEnabledState();                } else {                    externalBitmapCheck.setSelected(true);                }            }        } /* else if (source == sharedImagesCheck) {            if (sharedImagesCheck.isSelected()) {                tileset.enableSharedImages();                updateEnabledState();            } else {                int answer = JOptionPane.YES_OPTION;                if (!tileset.safeToDisableSharedImages()) {                    answer = JOptionPane.showConfirmDialog(                        this, "This tileset uses features that require the "                        + "use of shared images.  Disable the use of shared "                        + "images?",                        "Are you sure?",                        JOptionPane.YES_NO_OPTION,                        JOptionPane.QUESTION_MESSAGE);                }                if (answer == JOptionPane.YES_OPTION) {                    tileset.disableSharedImages();                    updateEnabledState();                } else {                    sharedImagesCheck.setSelected(true);                }            }        }*/ else if (source == bAddImage) {            Image img = loadImage();            if (img != null) {                tileset.addImage(img);            }            queryImages();        } else if (source == bDeleteImage) {            int answer = JOptionPane.showConfirmDialog(                this, "Delete this image?",                "Are you sure?",                JOptionPane.YES_NO_OPTION,                JOptionPane.QUESTION_MESSAGE);            if (answer == JOptionPane.YES_OPTION) {                tileset.removeImage(Integer.toString(currentImageIndex));                queryImages();            }        } else if (source == bDeleteAllUnusedImages) {            int answer = JOptionPane.showConfirmDialog(                this, "Delete all unused images?",                "Are you sure?",                JOptionPane.YES_NO_OPTION,                JOptionPane.QUESTION_MESSAGE);            if (answer == JOptionPane.YES_OPTION) {                for (int index = tileset.getTotalImages() - 1;                    index >= 0; --index) {                    	                    boolean image_used = false;                    for (int i = 0; i < tileset.getTotalTiles(); ++i) {                        if (tileset.getTile(i) != null                            && tileset.getTile(i).getImageId() == index) {                            image_used = true;                        }                    }                    if (!image_used) {                        tileset.removeImage(Integer.toString(index));                    }                }                queryImages();            }        }        repaint();    }