img.getGraphics().drawImage(trans, 0, 0, null);  newTileset.importTileBitmap(img, getCutter(width, height, spacing), true);  newTileset.setTransparentColor( colorButton.getColor());  newTileset.setTilesetImageFilename(file); } catch (IOException e) { JOptionPane.showMessageDialog(this, e.getLocalizedMessage(), IMPORT_ERROR_MSG, JOptionPane.WARNING_MESSAGE); continue; } }  } catch (Exception e) { JOptionPane.showMessageDialog(this, e.getLocalizedMessage(), IMPORT_ERROR_MSG, JOptionPane.ERROR_MESSAGE); newTileset = null; return; } }  break; }
newTileset.importTileBitmap(file, getCutter(width, height, spacing)); } catch (IOException e) { JOptionPane.showMessageDialog(this, e.getLocalizedMessage(), IMPORT_ERROR_MSG, JOptionPane.WARNING_MESSAGE); } }
    private void createSetAndDispose() {    	newTileset = new TileSet();        newTileset.setName(tilesetName.getText());        newTileset.setDefaultProperties(defaultSetProperties);        // In the off chance that something goes wrong,        // keep working.    	while(true) {	        if (tilebmpCheck.isSelected()) {	            String file = tilebmpFile.getText();	            int spacing = tileSpacing.intValue();	            int width = tileWidth.intValue();	            int height = tileHeight.intValue();	            try {	                if (!transCheck.isSelected()) {	                    newTileset.importTileBitmap(file,	                            getCutter(width, height, spacing),	                            true);	                } else {	                    try {	                        Toolkit tk = Toolkit.getDefaultToolkit();	                        Image orig = ImageIO.read(new File(file));	                        Image trans = tk.createImage(	                                new FilteredImageSource(orig.getSource(),	                                        new TransparentImageFilter(	                                                colorButton.getColor().getRGB())));	                        BufferedImage img = new BufferedImage(	                                trans.getWidth(null),	                                trans.getHeight(null),	                                BufferedImage.TYPE_INT_ARGB);	                        img.getGraphics().drawImage(trans, 0, 0, null);	                        newTileset.importTileBitmap(img,	                                getCutter(width, height, spacing),	                                true);	                        newTileset.setTransparentColor(	                                colorButton.getColor());	                        newTileset.setTilesetImageFilename(file);	                    } catch (IOException e) {	                    	JOptionPane.showMessageDialog(this, e.getLocalizedMessage(),	                                IMPORT_ERROR_MSG, JOptionPane.WARNING_MESSAGE);	                    	continue;	                    }	                }	            } catch (Exception e) {	                JOptionPane.showMessageDialog(this, e.getLocalizedMessage(),	                        IMPORT_ERROR_MSG, JOptionPane.ERROR_MESSAGE);	                newTileset = null;	                return;	            }	        }	        break;    	}        dispose();    }