[tiled] r582 - in trunk: . src/tiled/core src/tiled/io src/tiled/io/xml src/tiled/mapeditor src/tiled/mapeditor/animation src/tiled/mapeditor/brush src/tiled/mapeditor/dialogs src/tiled/mapeditor/plugin src/tiled/mapeditor/resources src/tiled/mapeditor/selection src/tiled/mapeditor/undo src/tiled/mapeditor/util src/tiled/mapeditor/widget src/tiled/util src/tiled/view

svn@biggeruniverse.com svn at biggeruniverse.com
Fri Feb 17 13:33:24 PST 2006


Author: bjorn
Date: 2006-02-17 15:33:23 -0600 (Fri, 17 Feb 2006)
New Revision: 582

Added:
   trunk/src/tiled/core/LayerLockedException.java
   trunk/src/tiled/mapeditor/Resources.java
   trunk/src/tiled/mapeditor/resources/gui.properties
   trunk/src/tiled/mapeditor/resources/gui_nl.properties
Modified:
   trunk/CHANGES
   trunk/build.xml
   trunk/src/tiled/core/AnimatedTile.java
   trunk/src/tiled/core/Map.java
   trunk/src/tiled/core/ObjectGroup.java
   trunk/src/tiled/core/TileLayer.java
   trunk/src/tiled/io/MapHelper.java
   trunk/src/tiled/io/xml/XMLMapTransformer.java
   trunk/src/tiled/io/xml/XMLMapWriter.java
   trunk/src/tiled/io/xml/XMLWriter.java
   trunk/src/tiled/mapeditor/MapEditor.java
   trunk/src/tiled/mapeditor/animation/AnimationDialog.java
   trunk/src/tiled/mapeditor/brush/CustomBrush.java
   trunk/src/tiled/mapeditor/brush/RandomBrush.java
   trunk/src/tiled/mapeditor/brush/ShapeBrush.java
   trunk/src/tiled/mapeditor/dialogs/AboutDialog.java
   trunk/src/tiled/mapeditor/dialogs/BrushDialog.java
   trunk/src/tiled/mapeditor/dialogs/ConfigurationDialog.java
   trunk/src/tiled/mapeditor/dialogs/ImageColorDialog.java
   trunk/src/tiled/mapeditor/dialogs/NewMapDialog.java
   trunk/src/tiled/mapeditor/dialogs/NewTilesetDialog.java
   trunk/src/tiled/mapeditor/dialogs/ObjectDialog.java
   trunk/src/tiled/mapeditor/dialogs/PluginDialog.java
   trunk/src/tiled/mapeditor/dialogs/PropertiesDialog.java
   trunk/src/tiled/mapeditor/dialogs/ResizeDialog.java
   trunk/src/tiled/mapeditor/dialogs/TileDialog.java
   trunk/src/tiled/mapeditor/dialogs/TilesetManager.java
   trunk/src/tiled/mapeditor/plugin/PluginClassLoader.java
   trunk/src/tiled/mapeditor/selection/SelectionLayer.java
   trunk/src/tiled/mapeditor/undo/MapLayerStateEdit.java
   trunk/src/tiled/mapeditor/undo/UndoStack.java
   trunk/src/tiled/mapeditor/util/LayerTableModel.java
   trunk/src/tiled/mapeditor/util/MultisetListRenderer.java
   trunk/src/tiled/mapeditor/util/TiledFileFilter.java
   trunk/src/tiled/mapeditor/widget/BrushBrowser.java
   trunk/src/tiled/mapeditor/widget/ImageViewPanel.java
   trunk/src/tiled/mapeditor/widget/IntegerSpinner.java
   trunk/src/tiled/mapeditor/widget/TileButton.java
   trunk/src/tiled/util/TiledConfiguration.java
   trunk/src/tiled/view/MapView.java
Log:
Merged internationalization and reimplementation of preferences to trunk.


Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/CHANGES	2006-02-17 21:33:23 UTC (rev 582)
@@ -1,6 +1,9 @@
 0.6.0 - TBD (+ means planned change)
 
-+ Added support for localization/internationalization
+* Made a start with internationalization/localization
+* Rewrote configuration based on the Preferences class, no more tiled.conf
+* Fixed tileset dialog so that it is now possible to change the tile height to
+  something else than the tile height used by the map.
 + Added a navigation minimap
 + Added full support for animated tiles
 + Rewrote main mapeditor code

Modified: trunk/build.xml
===================================================================
--- trunk/build.xml	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/build.xml	2006-02-17 21:33:23 UTC (rev 582)
@@ -49,6 +49,7 @@
     <copy todir="${build}/tiled/mapeditor/resources">
       <fileset dir="./src/tiled/mapeditor/resources">
         <include name="*.png" />
+        <include name="*.properties" />
         <include name="map.dtd" />
       </fileset>
     </copy>

Modified: trunk/src/tiled/core/AnimatedTile.java
===================================================================
--- trunk/src/tiled/core/AnimatedTile.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/core/AnimatedTile.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -19,84 +19,81 @@
 import tiled.util.TiledConfiguration;
 
 /**
- * Animated tiles take advantage of the Sprite class
- * internally to handle animation using an array of
- * Tiles.
+ * Animated tiles take advantage of the Sprite class internally to handle
+ * animation using an array of tiles.
  *
  * @see tiled.core.Sprite
  */
 public class AnimatedTile extends Tile {
 
-	private Sprite sprite;
-	
-	public AnimatedTile() {
-		super();
-	}
-	
-	public AnimatedTile(TileSet set) {
-		super(set);
-	}
-	
-	public AnimatedTile(Tile [] frames) {
-		this();
-		if(TiledConfiguration.getInstance().keyHasValue("tiled.animation.safe", "1")) {
-			//TODO:clone all the frames, just to be safe
-		} else {
-			sprite = new Sprite(frames);
-		}
-	}
-	
-	public AnimatedTile(Sprite s) {
-		this();
-		setSprite(s);
-	}
-	
-	public void setSprite(Sprite s) {
-		sprite = s;
-	}
-	
-	public int countAnimationFrames() {
-		return sprite.getTotalFrames();
-	}
-	
-	public int countKeys() {
-		return sprite.getTotalKeys();
-	}
-	
-	public Sprite getSprite() {
-		return sprite;
-	}
-	
-	/**
-	 * In an AnimatedTile we must take the extra step of
-	 * zooming all frames of the animation. This function
-	 * can be somewhat slower than calling getScaledImage()
-	 * on a Tile, but it depends on several factors.
-	 * 
-	 * @see tiled.core.Tile#getScaledImage(double)
-	 */
-	public Image getScaledImage(double zoom) {
-		try {
-			Iterator itr = sprite.getKeys();
-			
-			while(itr.hasNext()) {
-				Sprite.KeyFrame key = (Sprite.KeyFrame)itr.next();
-				for(int i=0;i < key.getTotalFrames();i++) {
-					key.getFrame(i).getScaledImage(zoom);
-				}
-			}
-		} catch (Exception e) {}
-		return sprite.getCurrentFrame().getScaledImage(zoom);
-	}
-	
-	/**
-	 * Handles drawing the correct frame, and iterating by the
-	 * frame rate
-	 * 
-	 * @see tiled.core.Tile#draw(Graphics, int, int, double)
-	 */
-	public void draw(Graphics g, int x, int y, double zoom) {
-		sprite.getCurrentFrame().draw(g, x, y, zoom);
-		sprite.iterateFrame();
-	}
+    private Sprite sprite;
+
+    public AnimatedTile() {
+    }
+
+    public AnimatedTile(TileSet set) {
+        super(set);
+    }
+
+    public AnimatedTile(Tile[] frames) {
+        this();
+        if (TiledConfiguration.node("animation").getBoolean("safe", false)) {
+            //TODO:clone all the frames, just to be safe
+        } else {
+            sprite = new Sprite(frames);
+        }
+    }
+
+    public AnimatedTile(Sprite s) {
+        this();
+        setSprite(s);
+    }
+
+    public void setSprite(Sprite s) {
+        sprite = s;
+    }
+
+    public int countAnimationFrames() {
+        return sprite.getTotalFrames();
+    }
+
+    public int countKeys() {
+        return sprite.getTotalKeys();
+    }
+
+    public Sprite getSprite() {
+        return sprite;
+    }
+
+    /**
+     * In an AnimatedTile we must take the extra step of zooming all frames of
+     * the animation. This function can be somewhat slower than calling
+     * getScaledImage() on a Tile, but it depends on several factors.
+     *
+     * @see tiled.core.Tile#getScaledImage(double)
+     */
+    public Image getScaledImage(double zoom) {
+        try {
+            Iterator itr = sprite.getKeys();
+
+            while (itr.hasNext()) {
+                Sprite.KeyFrame key = (Sprite.KeyFrame) itr.next();
+                for (int i = 0;i < key.getTotalFrames(); i++) {
+                    key.getFrame(i).getScaledImage(zoom);
+                }
+            }
+        } catch (Exception e) {}
+        return sprite.getCurrentFrame().getScaledImage(zoom);
+    }
+
+    /**
+     * Handles drawing the correct frame, and iterating by the
+     * frame rate
+     *
+     * @see tiled.core.Tile#draw(Graphics, int, int, double)
+     */
+    public void draw(Graphics g, int x, int y, double zoom) {
+        sprite.getCurrentFrame().draw(g, x, y, zoom);
+        sprite.iterateFrame();
+    }
 }

Copied: trunk/src/tiled/core/LayerLockedException.java (from rev 581, branches/bjorn/src/tiled/core/LayerLockedException.java)

Modified: trunk/src/tiled/core/Map.java
===================================================================
--- trunk/src/tiled/core/Map.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/core/Map.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -176,9 +176,9 @@
      * processing is complete.
      *
      * @param s TileSet to remove
-     * @throws Exception
+     * @throws LayerLockedException
      */
-    public void removeTileset(TileSet s) throws Exception{
+    public void removeTileset(TileSet s) throws LayerLockedException {
         // Sanity check
         if (tilesets.indexOf(s) == -1)
             return;

Modified: trunk/src/tiled/core/ObjectGroup.java
===================================================================
--- trunk/src/tiled/core/ObjectGroup.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/core/ObjectGroup.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -16,14 +16,15 @@
 import java.awt.geom.Area;
 import java.util.*;
 
-
+/**
+ * @version $Id$
+ */
 public class ObjectGroup extends MapLayer
 {
     
     private LinkedList boundObjects;
     
     public ObjectGroup() {
-    	super();
     	boundObjects = new LinkedList();
     }
     /**

Modified: trunk/src/tiled/core/TileLayer.java
===================================================================
--- trunk/src/tiled/core/TileLayer.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/core/TileLayer.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -19,16 +19,17 @@
 /**
  * A TileLayer is a specialized MapLayer, used for tracking two dimensional
  * tile data.
+ *
+ * @version $Id$
  */
 public class TileLayer extends MapLayer
 {
-    protected Tile map[][];
+    protected Tile[][] map;
 
     /**
      * Default contructor
      */
     public TileLayer() {
-        super();
     }
 
     /**
@@ -148,9 +149,9 @@
         for (int y = 0; y < bounds.height; y++) {
             for (int x = 0; x < bounds.width; x++) {
                 if (dir == MIRROR_VERTICAL) {
-                    mirror[y][x] = map[(bounds.height - 1) - y][x];
+                    mirror[y][x] = map[bounds.height - 1 - y][x];
                 } else {
-                    mirror[y][x] = map[y][(bounds.width - 1) - x];
+                    mirror[y][x] = map[y][bounds.width - 1 - x];
                 }
             }
         }
@@ -232,11 +233,11 @@
      * is locked, an exception is thrown.
      *
      * @param tile the Tile to be removed
-     * @throws Exception
+     * @throws LayerLockedException
      */
-    public void removeTile(Tile tile) throws Exception {
+    public void removeTile(Tile tile) throws LayerLockedException {
         if (getLocked()) {
-            throw new Exception(
+            throw new LayerLockedException(
                     "Attempted to remove tile when this layer is locked.");
         }
 
@@ -410,7 +411,7 @@
      * @exception CloneNotSupportedException
      */
     public Object clone() throws CloneNotSupportedException {
-        TileLayer clone = null;
+        TileLayer clone;
         clone = (TileLayer)super.clone();
 
         // Clone the layer data

Modified: trunk/src/tiled/io/MapHelper.java
===================================================================
--- trunk/src/tiled/io/MapHelper.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/io/MapHelper.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -15,6 +15,7 @@
 import java.io.IOException;
 import java.util.Iterator;
 import java.util.Stack;
+import java.util.prefs.Preferences;
 
 import javax.swing.JOptionPane;
 
@@ -27,6 +28,8 @@
 
 /**
  * A handler for saving and loading maps.
+ *
+ * @version $Id$
  */
 public class MapHelper {
     private static PluginClassLoader pluginLoader;
@@ -214,11 +217,11 @@
      *          had for the user
      */
     private static void reportPluginMessages(Stack s) {
-        // TODO: maybe have a nice dialog with a scrollbar, in case there are a
-        // lot of messages...
-        TiledConfiguration config = TiledConfiguration.getInstance();
+        // TODO: maybe have a nice dialog with a scrollbar, in case there are
+        // a lot of messages...
+        Preferences prefs = TiledConfiguration.node("io");
 
-        if (config.keyHasValue("tiled.report.io", 1)) {
+        if (prefs.getBoolean("reportWarnings", false)) {
             if (!s.isEmpty()) {
                 Iterator itr = s.iterator();
                 StringBuffer warnings = new StringBuffer();

Modified: trunk/src/tiled/io/xml/XMLMapTransformer.java
===================================================================
--- trunk/src/tiled/io/xml/XMLMapTransformer.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/io/xml/XMLMapTransformer.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -291,7 +291,8 @@
 
             try {
                 //just a little check for tricky people...
-                if(!source.substring(source.lastIndexOf('.')+1).toLowerCase().equals("tsx")) {
+                String extention = source.substring(source.lastIndexOf('.') + 1);
+                if (!extention.toLowerCase().equals("tsx")) {
                     warnings.push("WARN: tileset files should end in .tsx! ("+source+")");
                 }
 

Modified: trunk/src/tiled/io/xml/XMLMapWriter.java
===================================================================
--- trunk/src/tiled/io/xml/XMLMapWriter.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/io/xml/XMLMapWriter.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -21,6 +21,7 @@
 import java.util.Properties;
 import java.util.Stack;
 import java.util.Vector;
+import java.util.prefs.Preferences;
 import java.util.zip.GZIPOutputStream;
 
 import tiled.core.*;
@@ -33,6 +34,8 @@
  */
 public class XMLMapWriter implements MapWriter
 {
+    private static final int LAST_BYTE = 0x000000FF;
+
     /**
      * Saves a map to an XML file.
      *
@@ -99,7 +102,7 @@
         writer.flush();
     }
 
-    private void writeMap(Map map, XMLWriter w, String wp) throws IOException {
+    private static void writeMap(Map map, XMLWriter w, String wp) throws IOException {
         try {
             w.startElement("map");
 
@@ -118,10 +121,10 @@
                     w.writeAttribute("orientation", "shifted"); break;
             }
 
-            w.writeAttribute("width", "" + map.getWidth());
-            w.writeAttribute("height", "" + map.getHeight());
-            w.writeAttribute("tilewidth", "" + map.getTileWidth());
-            w.writeAttribute("tileheight", "" + map.getTileHeight());
+            w.writeAttribute("width", map.getWidth());
+            w.writeAttribute("height", map.getHeight());
+            w.writeAttribute("tilewidth", map.getTileWidth());
+            w.writeAttribute("tileheight", map.getTileHeight());
 
             Properties props = map.getProperties();
             for (Enumeration keys = props.keys(); keys.hasMoreElements();) {
@@ -158,7 +161,7 @@
      * degenerate case where the tileset is not stored in an external file,
      * writes the contents of the tileset instead.
      */
-    private void writeTilesetReference(TileSet set, XMLWriter w, String wp)
+    private static void writeTilesetReference(TileSet set, XMLWriter w, String wp)
         throws IOException {
 
         try {
@@ -169,7 +172,7 @@
             } else {
                 w.startElement("tileset");
                 try {
-                    w.writeAttribute("firstgid", "" + set.getFirstGid());
+                    w.writeAttribute("firstgid", set.getFirstGid());
                     w.writeAttribute("source", source.substring(
                                 source.lastIndexOf(File.separatorChar) + 1));
                     if (set.getBaseDir() != null) {
@@ -184,7 +187,7 @@
         } 
     }
 
-    private void writeTileset(TileSet set, XMLWriter w, String wp)
+    private static void writeTileset(TileSet set, XMLWriter w, String wp)
         throws IOException {
 
         try {
@@ -197,11 +200,11 @@
                 w.writeAttribute("name", name);
             }
 
-            w.writeAttribute("firstgid", "" + set.getFirstGid());
+            w.writeAttribute("firstgid", set.getFirstGid());
 
             if (tilebmpFile != null) {
-                w.writeAttribute("tilewidth", "" + set.getTileWidth());
-                w.writeAttribute("tileheight", "" + set.getTileHeight());
+                w.writeAttribute("tilewidth", set.getTileWidth());
+                w.writeAttribute("tileheight", set.getTileHeight());
                 //w.writeAttribute("spacing", "0");
             }
 
@@ -221,9 +224,12 @@
                 w.endElement();
             } else {
                 // Embedded tileset
+                Preferences prefs = TiledConfiguration.node("saving");
 
-                TiledConfiguration conf = TiledConfiguration.getInstance();
-                if (conf.keyHasValue("tmx.save.tileSetImages", "1")) {
+                boolean embedImages = prefs.getBoolean("embedImages", true);
+                boolean tileSetImages = prefs.getBoolean("tileSetImages", false);
+
+                if (tileSetImages) {
                     Enumeration ids = set.getImageIds();
                     while (ids.hasMoreElements()) {
                         String id = (String)ids.nextElement();
@@ -238,16 +244,15 @@
                         w.endElement();
                         w.endElement();
                     }
-                } else if (conf.keyHasValue("tmx.save.embedImages", "0")) {
-                    String imgSource = conf.getValue(
-                            "tmx.save.tileImagePrefix") + "set.png";
+                } else if (!embedImages) {
+                    String imgSource =
+                            prefs.get("tileImagePrefix", "tile") + "set.png";
 
                     w.startElement("image");
                     w.writeAttribute("source", imgSource);
 
-                    String tilesetFilename = (wp.substring(0,
-                            wp.lastIndexOf(File.separatorChar) + 1)
-                            + imgSource);
+                    String tilesetFilename = wp.substring(0,
+                            wp.lastIndexOf(File.separatorChar) + 1) + imgSource;
                     FileOutputStream fw = new FileOutputStream(new File(
                                 tilesetFilename));
                     //byte[] data = ImageHelper.imageToPNG(setImage);
@@ -261,7 +266,7 @@
                 Iterator tileIterator = set.iterator();
                 boolean needWrite = !set.isOneForOne();
 
-                if (conf.keyHasValue("tmx.save.embedImages", "1")) {
+                if (embedImages) {
                     needWrite = true;
                 } else {
                     while (tileIterator.hasNext()) {
@@ -290,7 +295,7 @@
         }
     }
 
-    private void writeObjectGroup(ObjectGroup o, XMLWriter w)
+    private static void writeObjectGroup(ObjectGroup o, XMLWriter w)
         throws IOException
     {
         Iterator itr = o.getObjects();
@@ -304,15 +309,15 @@
      * first global ids for the tilesets are determined, in order for the right
      * gids to be written to the layer data.
      */
-    private void writeMapLayer(MapLayer l, XMLWriter w) throws IOException {
+    private static void writeMapLayer(MapLayer l, XMLWriter w) throws IOException {
         try {
-            TiledConfiguration conf = TiledConfiguration.getInstance();
-            boolean encodeLayerData = conf.keyHasValue(
-                    "tmx.save.encodeLayerData", "1");
-            boolean compressLayerData = conf.keyHasValue(
-                    "tmx.save.layerCompression", "1") && encodeLayerData;
+            Preferences prefs = TiledConfiguration.node("saving");
+            boolean encodeLayerData =
+                    prefs.getBoolean("encodeLayerData", true);
+            boolean compressLayerData =
+                    prefs.getBoolean("layerCompression", true) &&
+                            encodeLayerData;
 
-
             Rectangle bounds = l.getBounds();
 
             if (l.getClass() == SelectionLayer.class) {
@@ -324,20 +329,20 @@
             }
 
             w.writeAttribute("name", l.getName());
-            w.writeAttribute("width", "" + bounds.width);
-            w.writeAttribute("height", "" + bounds.height);
+            w.writeAttribute("width", bounds.width);
+            w.writeAttribute("height", bounds.height);
             if (bounds.x != 0) {
-                w.writeAttribute("xoffset", "" + bounds.x);
+                w.writeAttribute("xoffset", bounds.x);
             }
             if (bounds.y != 0) {
-                w.writeAttribute("yoffset", "" + bounds.y);
+                w.writeAttribute("yoffset", bounds.y);
             }
 
             if (!l.isVisible()) {
                 w.writeAttribute("visible", "0");
             }
             if (l.getOpacity() < 1.0f) {
-                w.writeAttribute("opacity", "" + l.getOpacity());
+                w.writeAttribute("opacity", l.getOpacity());
             }
 
             Properties props = l.getProperties();
@@ -375,10 +380,10 @@
                                 gid = tile.getGid();
                             }
 
-                            out.write((gid      ) & 0x000000FF);
-                            out.write((gid >>  8) & 0x000000FF);
-                            out.write((gid >> 16) & 0x000000FF);
-                            out.write((gid >> 24) & 0x000000FF);
+                            out.write(gid       & LAST_BYTE);
+                            out.write(gid >> 8  & LAST_BYTE);
+                            out.write(gid >> 16 & LAST_BYTE);
+                            out.write(gid >> 24 & LAST_BYTE);
                         }
                     }
 
@@ -398,7 +403,7 @@
                             }
 
                             w.startElement("tile");
-                            w.writeAttribute("gid", ""+gid);
+                            w.writeAttribute("gid", gid);
                             w.endElement();
                         }
                     }
@@ -411,14 +416,14 @@
         }
     }
     
-    private void writeTile(Tile tile, XMLWriter w) throws IOException {
+    private static void writeTile(Tile tile, XMLWriter w) throws IOException {
     	
         try {
             w.startElement("tile");
 
             int tileId = tile.getId();
 
-            w.writeAttribute("id", "" + tileId);
+            w.writeAttribute("id", tileId);
 
             //if (groundHeight != getHeight()) {
             //    w.writeAttribute("groundheight", "" + groundHeight);
@@ -435,12 +440,14 @@
 
             Image tileImage = tile.getImage();
 
-            TiledConfiguration conf = TiledConfiguration.getInstance();
+            Preferences prefs = TiledConfiguration.node("saving");
 
+            boolean embedImages = prefs.getBoolean("embedImages", true);
+            boolean tileSetImages = prefs.getBoolean("tileSetImages", false);
+
             // Write encoded data
-            if (tileImage != null) {
-                if (conf.keyHasValue("tmx.save.embedImages", "1")
-                        && conf.keyHasValue("tmx.save.tileSetImages", "0")) {
+            if (tileImage != null && !tileSetImages) {
+                if (embedImages && !tileSetImages) {
                     w.startElement("image");
                     w.writeAttribute("format", "png");
                     w.startElement("data");
@@ -449,25 +456,24 @@
                                     ImageHelper.imageToPNG(tileImage))));
                     w.endElement();
                     w.endElement();
-                } else if(conf.keyHasValue("tmx.save.tileSetImages", "1")) {
+                } else if (tileSetImages) {
                     w.startElement("image");
-                    w.writeAttribute("id", "" + tile.getImageId());
+                    w.writeAttribute("id", tile.getImageId());
                     int orientation = tile.getImageOrientation();
                     int rotation;
                     boolean flipped =
-                        (orientation & 1) == ((orientation & 2) >> 1);
+                            (orientation & 1) == (orientation & 2) >> 1;
                     if ((orientation & 4) == 4) {
-                        rotation = ((orientation & 1) == 1) ? 270 : 90;
+                        rotation = (orientation & 1) == 1 ? 270 : 90;
                     } else {
-                        rotation = ((orientation & 2) == 2) ? 180 : 0;
+                        rotation = (orientation & 2) == 2 ? 180 : 0;
                     }
-                    if (rotation != 0) w.writeAttribute("rotation",
-                            "" + rotation);
+                    if (rotation != 0) w.writeAttribute("rotation", rotation);
                     if (flipped) w.writeAttribute("flipped", "true");
                     w.endElement();
                 } else {
-                    String prefix = conf.getValue("tmx.save.tileImagePrefix");
-                    String filename = conf.getValue("tmx.save.maplocation") +
+                    String prefix = prefs.get("tileImagePrefix", "tile");
+                    String filename = prefs.get("maplocation", "") +
                         prefix + tileId + ".png";
                     w.startElement("image");
                     w.writeAttribute("source", prefix + tileId + ".png");
@@ -490,35 +496,35 @@
         }
     }
 
-    private void writeAnimation(Sprite s, XMLWriter w) throws IOException {
-    	try {
-	    	w.startElement("animation");
-	    	for(int k = 0; k < s.getTotalKeys(); k++) {
-	    		Sprite.KeyFrame key = s.getKey(k);
-	    		w.startElement("keyframe");
-	    		w.writeAttribute("name", key.getName());
-	    		for(int it = 0; it < key.getTotalFrames(); it++) {
-	    			Tile stile = key.getFrame(it);
-	    			w.startElement("tile");
-	                w.writeAttribute("gid", ""+stile.getGid());
-	                w.endElement();
-	    		}
-	    		w.endElement();
-	    	}
-	    	w.endElement();
-    	} catch (XMLWriterException e) {
+    private static void writeAnimation(Sprite s, XMLWriter w) throws IOException {
+        try {
+            w.startElement("animation");
+            for (int k = 0; k < s.getTotalKeys(); k++) {
+                Sprite.KeyFrame key = s.getKey(k);
+                w.startElement("keyframe");
+                w.writeAttribute("name", key.getName());
+                for (int it = 0; it < key.getTotalFrames(); it++) {
+                    Tile stile = key.getFrame(it);
+                    w.startElement("tile");
+                    w.writeAttribute("gid", stile.getGid());
+                    w.endElement();
+                }
+                w.endElement();
+            }
+            w.endElement();
+        } catch (XMLWriterException e) {
             e.printStackTrace();
         }
     }
-    
-    private void writeObject(MapObject m, ObjectGroup o, XMLWriter w)
+
+    private static void writeObject(MapObject m, ObjectGroup o, XMLWriter w)
         throws IOException
     {
         try {
             Rectangle b = o.getBounds();
             w.startElement("object");
-            w.writeAttribute("x", "" + (m.getX() + b.x));
-            w.writeAttribute("y", "" + (m.getY() + b.y));
+            w.writeAttribute("x", m.getX() + b.x);
+            w.writeAttribute("y", m.getY() + b.y);
             w.writeAttribute("type", m.getType());
             if (m.getSource() != null) {
                 w.writeAttribute("source", m.getSource());
@@ -604,7 +610,7 @@
                 // Assumes: \ does not occur in filenames
                 relPath = relPath.replace('\\', '/');
             }
-        } catch (Exception e) {
+        } catch (IOException e) {
         }
 
         return relPath;

Modified: trunk/src/tiled/io/xml/XMLWriter.java
===================================================================
--- trunk/src/tiled/io/xml/XMLWriter.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/io/xml/XMLWriter.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -5,7 +5,7 @@
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
- * 
+ *
  *  Adam Turk <aturk at biggeruniverse.com>
  *  Bjorn Lindeijer <b.lindeijer at xs4all.nl>
  */
@@ -17,7 +17,6 @@
 import java.io.IOException;
 import java.util.Stack;
 
-
 /**
  * A simple helper class to write an XML file, based on
  * http://www.xmlsoft.org/html/libxml-xmlwriter.html
@@ -30,10 +29,10 @@
     private String indentString = " ";
     private String newLine = "\n";
     private final Writer w;
-    
+
     private final Stack openElements;
-    private boolean bStartTagOpen = false;
-    private boolean bDocumentOpen = false;
+    private boolean bStartTagOpen;
+    private boolean bDocumentOpen;
 
 
     public XMLWriter(Writer writer) {
@@ -44,18 +43,18 @@
 
     public void setIndent(boolean bIndent) {
         this.bIndent = bIndent;
-        newLine = ((bIndent) ? "\n" : "");
+        newLine = bIndent ? "\n" : "";
     }
 
     public void setIndentString(String indentString) {
         this.indentString = indentString;
     }
-    
 
+
     public void startDocument() throws IOException {
         startDocument("1.0");
     }
-    
+
     public void startDocument(String version) throws IOException {
         w.write("<?xml version=\"" + version + "\"?>" + newLine);
         bDocumentOpen = true;
@@ -74,7 +73,7 @@
 
         writeIndent();
         w.write("<" + name);
-        
+
         openElements.push(name);
         bStartTagOpen = true;
     }
@@ -82,7 +81,7 @@
 
     public void endDocument() throws IOException {
         // End all open elements.
-        while (openElements.size() > 0) {
+        while (!openElements.isEmpty()) {
             endElement();
         }
     }
@@ -100,7 +99,7 @@
         }
 
         // Set document closed when last element is closed
-        if (openElements.size() == 0) {
+        if (openElements.isEmpty()) {
             bDocumentOpen = false;
         }
     }
@@ -117,6 +116,16 @@
         }
     }
 
+    public void writeAttribute(String name, int content)
+        throws IOException, XMLWriterException {
+        writeAttribute(name, String.valueOf(content));
+    }
+
+    public void writeAttribute(String name, float content)
+        throws IOException, XMLWriterException {
+        writeAttribute(name, String.valueOf(content));
+    }
+
     public void writeCDATA(String content) throws IOException {
         if (bStartTagOpen) {
             w.write(">" + newLine);

Modified: trunk/src/tiled/mapeditor/MapEditor.java
===================================================================
--- trunk/src/tiled/mapeditor/MapEditor.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/mapeditor/MapEditor.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -20,6 +20,7 @@
 import java.io.*;
 import java.util.Stack;
 import java.util.Vector;
+import java.util.prefs.Preferences;
 
 import javax.imageio.ImageIO;
 import javax.swing.*;
@@ -52,7 +53,6 @@
 import tiled.io.MapReader;
 import tiled.io.MapWriter;
 
-
 /**
  * The main class for the Tiled Map Editor.
  */
@@ -89,9 +89,8 @@
     private final UndoableEditSupport undoSupport;
     private final MapEventAdapter mapEventAdapter;
     private final PluginClassLoader pluginLoader;
-    private final TiledConfiguration configuration;
+    private final Preferences prefs = TiledConfiguration.root();
 
-
     int currentPointerState;
     Tile currentTile;
     int currentLayer = -1;
@@ -155,17 +154,13 @@
     final Action selectAllAction, inverseAction, cancelSelectionAction;
 
     public MapEditor() {
-        // Get instance of configuration
-        configuration = TiledConfiguration.getInstance();
-
         /*eraserBrush = new Eraser();
         brushes.add(eraserBrush());
         setBrush(eraserBrush);*/
 
         /*
         try {
-            Image imgPaintCursor = loadImageResource(
-                    "resources/cursor-pencil.png");
+            Image imgPaintCursor = Resources.getImage("cursor-pencil.png");
 
             curPaint = Toolkit.getDefaultToolkit().createCustomCursor(
                     imgPaintCursor, new Point(0,0), "paint");
@@ -184,8 +179,7 @@
 
         cursorHighlight = new SelectionLayer(1, 1);
         cursorHighlight.select(0, 0);
-        cursorHighlight.setVisible(configuration.keyHasValue(
-                    "tiled.cursorhighlight", 1));
+        cursorHighlight.setVisible(prefs.getBoolean("cursorhighlight", true));
 
         mapEventAdapter = new MapEventAdapter();
 
@@ -248,7 +242,7 @@
                 JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
         mapScrollPane.setBorder(null);
 
-        createToolbox();
+        createToolBar();
         createData();
         createStatusBar();
 
@@ -266,11 +260,6 @@
 
     private void exit() {
         if (checkSave()) {
-            try {
-                configuration.write("tiled.conf");
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
             System.exit(0);
         }
     }
@@ -433,8 +422,7 @@
         gridMenuItem.setAccelerator(KeyStroke.getKeyStroke("control G"));
 
         cursorMenuItem = new JCheckBoxMenuItem("Highlight Cursor");
-        cursorMenuItem.setSelected(configuration.keyHasValue(
-                    "tiled.cursorhighlight", 1));
+        cursorMenuItem.setSelected(prefs.getBoolean("cursorhighlight", true));
         cursorMenuItem.addActionListener(this);
         cursorMenuItem.setToolTipText(
                 "Toggle highlighting on-map cursor position");
@@ -482,17 +470,16 @@
     }
 
     /**
-     * Creates the left hand main toolbox
-     *
+     * Creates the tool bar.
      */
-    private void createToolbox() {
-        Icon iconMove = loadIcon("resources/gimp-tool-move-22.png");
-        Icon iconPaint = loadIcon("resources/gimp-tool-pencil-22.png");
-        Icon iconErase = loadIcon("resources/gimp-tool-eraser-22.png");
-        Icon iconPour = loadIcon("resources/gimp-tool-bucket-fill-22.png");
-        Icon iconEyed = loadIcon("resources/gimp-tool-color-picker-22.png");
-        Icon iconMarquee = loadIcon("resources/gimp-tool-rect-select-22.png");
-        Icon iconMoveObject = loadIcon("resources/gimp-tool-object-move-22.png");
+    private void createToolBar() {
+        Icon iconMove = Resources.getIcon("gimp-tool-move-22.png");
+        Icon iconPaint = Resources.getIcon("gimp-tool-pencil-22.png");
+        Icon iconErase = Resources.getIcon("gimp-tool-eraser-22.png");
+        Icon iconPour = Resources.getIcon("gimp-tool-bucket-fill-22.png");
+        Icon iconEyed = Resources.getIcon("gimp-tool-color-picker-22.png");
+        Icon iconMarquee = Resources.getIcon("gimp-tool-rect-select-22.png");
+        Icon iconMoveObject = Resources.getIcon("gimp-tool-object-move-22.png");
 
         paintButton = createToggleButton(iconPaint, "paint", "Paint");
         eraseButton = createToggleButton(iconErase, "erase", "Erase");
@@ -543,11 +530,11 @@
         dataPanel = new JPanel(new BorderLayout());
 
         // Try to load the icons
-        Icon imgAdd = loadIcon("resources/gnome-new.png");
-        Icon imgDel = loadIcon("resources/gnome-delete.png");
-        Icon imgDup = loadIcon("resources/gimp-duplicate-16.png");
-        Icon imgUp = loadIcon("resources/gnome-up.png");
-        Icon imgDown = loadIcon("resources/gnome-down.png");
+        Icon imgAdd = Resources.getIcon("gnome-new.png");
+        Icon imgDel = Resources.getIcon("gnome-delete.png");
+        Icon imgDup = Resources.getIcon("gimp-duplicate-16.png");
+        Icon imgUp = Resources.getIcon("gnome-up.png");
+        Icon imgDown = Resources.getIcon("gnome-down.png");
 
         //navigation and tool options
         // TODO: the minimap is prohibitively slow, need to speed this up
@@ -1109,7 +1096,7 @@
     }
 
     private void updateCursorHighlight(Point tile) {
-        if (configuration.keyHasValue("tiled.cursorhighlight", 1)) {
+        if (prefs.getBoolean("cursorhighlight", true)) {
             Rectangle redraw = cursorHighlight.getBounds();
 
             if (redraw.x != tile.x || redraw.y != tile.y) {
@@ -1265,8 +1252,7 @@
             mapView.toggleMode(MapView.PF_COORDINATES);
             mapView.repaint();
         } else if (command.equals("Highlight Cursor")) {
-            configuration.addConfigPair("tiled.cursorhighlight",
-                    Integer.toString(cursorMenuItem.isSelected() ? 1 : 0));
+            prefs.putBoolean("cursorhighlight", cursorMenuItem.isSelected());
             cursorHighlight.setVisible(cursorMenuItem.isSelected());
         } else if (command.equals("Resize")) {
             ResizeDialog rd = new ResizeDialog(appFrame, this);
@@ -1284,11 +1270,10 @@
                 new PluginDialog(appFrame, pluginLoader);
             pluginDialog.setVisible(true);
         } else if (command.startsWith("_open")) {
-            try {
-                loadMap(configuration.getValue(
-                            "tiled.recent." + command.substring(5)));
-            } catch (Exception e) {
-                e.printStackTrace();
+            Preferences recentFiles = prefs.node("recent");
+            String file = recentFiles.get("file" + command.substring(5), "");
+            if (file.length() > 0) {
+                loadMap(file);
             }
         } else if (command.equals("Preferences...")) {
             ConfigurationDialog d = new ConfigurationDialog(appFrame);
@@ -1391,33 +1376,33 @@
                     putValue(SHORT_DESCRIPTION,
                             "Rotate layer 90 degrees clockwise");
                     putValue(SMALL_ICON,
-                            loadIcon("resources/gimp-rotate-90-16.png"));
+                            Resources.getIcon("gimp-rotate-90-16.png"));
                     break;
                 case MapLayer.ROTATE_180:
                     putValue(NAME, "Rotate 180 degrees CW");
                     putValue(SHORT_DESCRIPTION,
                             "Rotate layer 180 degrees clockwise");
                     putValue(SMALL_ICON,
-                            loadIcon("resources/gimp-rotate-180-16.png"));
+                            Resources.getIcon("gimp-rotate-180-16.png"));
                     break;
                 case MapLayer.ROTATE_270:
                     putValue(NAME, "Rotate 90 degrees CCW");
                     putValue(SHORT_DESCRIPTION,
                             "Rotate layer 90 degrees counterclockwise");
                     putValue(SMALL_ICON,
-                            loadIcon("resources/gimp-rotate-270-16.png"));
+                            Resources.getIcon("gimp-rotate-270-16.png"));
                     break;
                 case MapLayer.MIRROR_VERTICAL:
                     putValue(NAME, "Flip vertically");
                     putValue(SHORT_DESCRIPTION, "Flip layer vertically");
                     putValue(SMALL_ICON,
-                            loadIcon("resources/gimp-flip-vertical-16.png"));
+                            Resources.getIcon("gimp-flip-vertical-16.png"));
                     break;
                 case MapLayer.MIRROR_HORIZONTAL:
                     putValue(NAME, "Flip horizontally");
                     putValue(SHORT_DESCRIPTION, "Flip layer horizontally");
                     putValue(SMALL_ICON,
-                            loadIcon("resources/gimp-flip-horizontal-16.png"));
+                            Resources.getIcon("gimp-flip-horizontal-16.png"));
                     break;
             }
         }
@@ -1534,7 +1519,7 @@
             putValue(ACCELERATOR_KEY,
                     KeyStroke.getKeyStroke("control EQUALS"));
             putValue(SHORT_DESCRIPTION, "Zoom in one level");
-            putValue(SMALL_ICON, loadIcon("resources/gnome-zoom-in.png"));
+            putValue(SMALL_ICON, Resources.getIcon("gnome-zoom-in.png"));
         }
         public void actionPerformed(ActionEvent evt) {
             if (currentMap != null) {
@@ -1554,7 +1539,7 @@
             putValue(ACCELERATOR_KEY,
                     KeyStroke.getKeyStroke("control MINUS"));
             putValue(SHORT_DESCRIPTION, "Zoom out one level");
-            putValue(SMALL_ICON, loadIcon("resources/gnome-zoom-out.png"));
+            putValue(SMALL_ICON, Resources.getIcon("gnome-zoom-out.png"));
         }
         public void actionPerformed(ActionEvent evt) {
             if (currentMap != null) {
@@ -1770,8 +1755,8 @@
     }
 
     private boolean unsavedChanges() {
-        return (currentMap != null && undoStack.canUndo() &&
-                !undoStack.isAllSaved());
+        return currentMap != null && undoStack.canUndo() &&
+                !undoStack.isAllSaved();
     }
 
     /**
@@ -1829,7 +1814,7 @@
                 ch = new JFileChooser(filename);
             }
 
-            MapWriter writers[] = (MapWriter[]) pluginLoader.getWriters();
+            MapWriter[] writers = pluginLoader.getWriters();
             for(int i = 0; i < writers.length; i++) {
                 try {
                     ch.addChoosableFileFilter(new TiledFileFilter(
@@ -1928,22 +1913,18 @@
     }
 
     private void openMap() {
-        String startLocation = "";
-
         // Start at the location of the most recently loaded map file
-        if (configuration.hasOption("tiled.recent.1")) {
-            startLocation = configuration.getValue("tiled.recent.1");
-        }
+        String startLocation = prefs.node("recent").get("file0", "");
 
         JFileChooser ch = new JFileChooser(startLocation);
 
         try {
-            MapReader readers[] = (MapReader[]) pluginLoader.getReaders();
+            MapReader[] readers = pluginLoader.getReaders();
             for(int i = 0; i < readers.length; i++) {
                 ch.addChoosableFileFilter(new TiledFileFilter(
                             readers[i].getFilter(), readers[i].getName()));
             }
-        } catch (Throwable e) {
+        } catch (Exception e) {
             JOptionPane.showMessageDialog(appFrame,
                     "Error while loading plugins: " + e.getMessage(),
                     "Error while loading map",
@@ -1968,7 +1949,7 @@
         }
     }
 
-    private MapLayer createLayerCopy(MapLayer layer) {
+    private static MapLayer createLayerCopy(MapLayer layer) {
         if (layer instanceof TileLayer) {
             return new TileLayer((TileLayer)layer);
         } else if (layer instanceof ObjectGroup) {
@@ -1977,53 +1958,30 @@
         return null;
     }
 
-    private void updateRecent(String mapFile) {
-        Vector recent = new Vector();
-        try {
-            recent.add(configuration.getValue("tiled.recent.1"));
-            recent.add(configuration.getValue("tiled.recent.2"));
-            recent.add(configuration.getValue("tiled.recent.3"));
-            recent.add(configuration.getValue("tiled.recent.4"));
-        } catch (Exception e) {
+    private void updateRecent(String filename) {
+        // If a filename is given, add it to the recent files
+        if (filename != null) {
+            TiledConfiguration.addToRecentFiles(filename);
         }
 
-        // If a map file is given, add it to the recent list
-        if (mapFile != null) {
-            // Remove any existing entry that is the same
-            for (int i = 0; i < recent.size(); i++) {
-                String filename = (String)recent.get(i);
-                if (filename!=null&&filename.equals(mapFile)) {
-                    recent.remove(i);
-                    i--;
-                }
-            }
+        java.util.List files = TiledConfiguration.getRecentFiles();
 
-            recent.add(0, mapFile);
-
-            if (recent.size() > 4) {
-                recent.setSize(4);
-            }
-        }
-
         recentMenu.removeAll();
 
-        for (int i = 0; i < recent.size(); i++) {
-            String file = (String)recent.get(i);
-            if (file != null) {
-                String name =
-                    file.substring(file.lastIndexOf(File.separatorChar) + 1);
+        for (int i = 0; i < files.size(); i++) {
+            String path = (String) files.get(i);
+            String name =
+                path.substring(path.lastIndexOf(File.separatorChar) + 1);
 
-                configuration.addConfigPair("tiled.recent." + (i + 1), file);
-                JMenuItem recentOption = createMenuItem(name, null, null);
-                recentOption.setActionCommand("_open" + (i + 1));
-                recentMenu.add(recentOption);
-            }
+            JMenuItem recentOption = createMenuItem(name, null, null);
+            recentOption.setActionCommand("_open" + i);
+            recentMenu.add(recentOption);
         }
     }
 
     private void setCurrentMap(Map newMap) {
         currentMap = newMap;
-        boolean mapLoaded = (currentMap != null);
+        boolean mapLoaded = currentMap != null;
 
         if (!mapLoaded) {
             mapEventAdapter.fireEvent(MapEventAdapter.ME_MAPINACTIVE);
@@ -2189,27 +2147,6 @@
     }
 
     /**
-     * Loads an image that is part of the distribution jar
-     * 
-     * @param fname
-     * @return A BufferedImage instance of the image
-     * @throws IOException
-     */
-    public static BufferedImage loadImageResource(String fname)
-        throws IOException {
-        return ImageIO.read(MapEditor.class.getResourceAsStream(fname));
-    }
-
-    private static ImageIcon loadIcon(String fname) {
-        try {
-            return new ImageIcon(loadImageResource(fname));
-        } catch (IOException e) {
-            System.out.println("Failed to load icon: " + fname);
-            return null;
-        }
-    }
-
-    /**
      * Starts Tiled.
      *
      * @param args the first argument may be a map file

Copied: trunk/src/tiled/mapeditor/Resources.java (from rev 581, branches/bjorn/src/tiled/mapeditor/Resources.java)

Modified: trunk/src/tiled/mapeditor/animation/AnimationDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/animation/AnimationDialog.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/mapeditor/animation/AnimationDialog.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -21,6 +21,7 @@
 
 import tiled.core.*;
 import tiled.mapeditor.MapEditor;
+import tiled.mapeditor.Resources;
 
 /**
  * This is the multi-purpose animation dialog, which can handle any
@@ -29,274 +30,252 @@
  *
  * @see tiled.core.Sprite
  */
-public class AnimationDialog extends JDialog implements ActionListener{
+public class AnimationDialog extends JDialog implements ActionListener {
 
-	private static final int PLAYING=1;
-	private static final int STOPPED=0;
+    private static final int PLAYING = 1;
+    private static final int STOPPED = 0;
 
-	private Sprite currentSprite;
-	private SpriteCanvas canvas = null;
-	private int state=STOPPED;
-	private JButton playstop=null;
-	private JComboBox keyframe;
-	private JLabel lCurrentFrame=null,
-						lFrameRate=null,
-						lFrameRange=null;
-	
-	private ImageIcon playIcon, stopIcon;
-	
-	public AnimationDialog(Dialog parent, Sprite sprite) {
-		super(parent, "Animation", true);
-		currentSprite = sprite;
-		
-		try {
-			playIcon = new ImageIcon(MapEditor.loadImageResource("resources/play.png"));
-			stopIcon = new ImageIcon(MapEditor.loadImageResource("resources/stop.png"));
-		} catch(IOException e) {}
-		
-		makeUp();
+    private Sprite currentSprite;
+    private SpriteCanvas canvas = null;
+    private int state = STOPPED;
+    private JButton playstop = null;
+    private JComboBox keyframe;
+    private JLabel lCurrentFrame = null;
+    private JLabel lFrameRate = null;
+    private JLabel lFrameRange = null;
+
+    private Icon playIcon, stopIcon;
+
+    public AnimationDialog(Dialog parent, Sprite sprite) {
+        super(parent, "Animation", true);
+        currentSprite = sprite;
+
+        playIcon = Resources.getIcon("play.png");
+        stopIcon = Resources.getIcon("stop.png");
+
+        makeUp();
         pack();
         setLocationRelativeTo(getOwner());
-	}
-	
-	public JPanel makeUp(){
-		JButton b;
-		JLabel l;
-		JPanel main = new JPanel(new BorderLayout()),
-				data = new JPanel(new BorderLayout()),
-				buttons = new JPanel(new GridBagLayout()),
-				opt = new JPanel(new GridBagLayout());
-		canvas = new SpriteCanvas(this);
-		
-		
-		GridBagConstraints c=new GridBagConstraints();		
-		c.fill=GridBagConstraints.BOTH;		
-		c.weightx=1; c.weighty=1;
-		c.gridx=0; c.gridy=0;
-		c.gridheight=1; c.gridwidth=1;
-		ImageIcon icon = new ImageIcon();
-		try {
-			icon = new ImageIcon(MapEditor.loadImageResource("resources/startframe.png"));
-		} catch(IOException e) {}
-		b = new JButton("", icon);
-		b.setActionCommand("startframe");
-		b.setMargin(new Insets(0,0,0,0));
-		b.addActionListener(this);
-		buttons.add(b,c);
-		
-		c.gridx=1;
-		try {
-			icon = new ImageIcon(MapEditor.loadImageResource("resources/back.png"));
-		} catch(IOException e) {}
-		b = new JButton("", icon);
-		b.setActionCommand("back");
-		b.setMargin(new Insets(0,0,0,0));
-		b.addActionListener(this);
-		buttons.add(b,c);
-		
-		c.gridx=2;
-		try {
-			icon = new ImageIcon(MapEditor.loadImageResource("resources/play.png"));
-		} catch(IOException e) {}
-		playstop = new JButton("", icon);
-		playstop.setActionCommand("playstop");
-		playstop.setMargin(new Insets(0,0,0,0));
-		playstop.addActionListener(this);
-		buttons.add(playstop,c);
-		
-		c.gridx=3;
-		try {
-			icon = new ImageIcon(MapEditor.loadImageResource("resources/forward.png"));
-		} catch(IOException e) {}
-		b = new JButton("", icon);
-		b.setActionCommand("forward");
-		b.setMargin(new Insets(0,0,0,0));
-		b.addActionListener(this);
-		buttons.add(b,c);
-		
-		c.gridx=4;
-		try {
-			icon = new ImageIcon(MapEditor.loadImageResource("resources/lastframe.png"));
-		} catch(IOException e) {}
-		b = new JButton("", icon);
-		b.setActionCommand("lastframe");
-		b.setMargin(new Insets(0,0,0,0));
-		b.addActionListener(this);
-		buttons.add(b,c);		
-		
-		c.gridx=0; c.gridy=0; c.gridwidth=2;
-		String [] defaultArr = { "None" };
-		keyframe = new JComboBox(defaultArr);
-		keyframe.addActionListener(this);
-		opt.add(keyframe,c);
-		
-		c.gridwidth=1; c.gridy=1;
-		l=new JLabel("Range:");
-		opt.add(l,c);
-		
-		c.gridx=1;
-		lFrameRange = new JLabel("-");
-		opt.add(lFrameRange,c);
-		
-		c.gridy=2; c.gridx=0;
-		l=new JLabel("Current:");
-		opt.add(l,c);
-		
-		c.gridx=1;
-		lCurrentFrame = new JLabel("?");
-		opt.add(lCurrentFrame,c);
-		
-		c.gridy=3; c.gridx=0;
-		l=new JLabel("Rate:");
-		opt.add(l,c);
-		
-		c.gridx=1;
-		lFrameRate = new JLabel("?");
-		opt.add(lFrameRate,c);
-		
-		data.add(canvas,BorderLayout.CENTER);
-		data.add(buttons,BorderLayout.SOUTH);
-			
-		main.add(data,BorderLayout.CENTER);
-		main.add(opt,BorderLayout.EAST);
-		
-		return main;
-	}
-		
-	public void paintSprite(Graphics g){
-			
-			currentSprite.getCurrentFrame().draw(g, 0, 0, 1.0f);
-			
-			
-			if(state==PLAYING){								
-				if(currentSprite!=null){
-					if(currentSprite.getCurrentKey()==null){
-						JOptionPane.showMessageDialog(this,"There are no keys defined!","No Keys", JOptionPane.ERROR_MESSAGE);
-						state=STOPPED;
-						return;
-					}
-					currentSprite.iterateFrame();
-					updateStats();
-					canvas.repaint();
-					repaint();					
-				}
-			}
-			
-	}
+    }
 
-	public void draw(Graphics g){
-		canvas.repaint();
-		updateList();
-	}
-	
-	public void updateList(){
-		if(currentSprite!=null){		
-			keyframe.removeAllItems();
-			try{			
-				Iterator itr = currentSprite.getKeys();
-				while(itr.hasNext()){
-					keyframe.addItem(((Sprite.KeyFrame)itr.next()).getName());
-				}
-			}catch(Exception e){}
-		}
-	}
-	
-	public void updateStats(){
-		if(currentSprite!=null){
-			Sprite.KeyFrame k = currentSprite.getKey((String)keyframe.getSelectedItem());
-			if(k!=null){			
-				lCurrentFrame.setText(""+currentSprite.getCurrentFrame());
-				lFrameRate.setText(""+k.getFrameRate());
-			}
-		}
-	}
+    public JPanel makeUp(){
+        JButton b;
+        JLabel l;
+        JPanel main = new JPanel(new BorderLayout());
+        JPanel data = new JPanel(new BorderLayout());
+        JPanel buttons = new JPanel(new GridBagLayout());
+        JPanel opt = new JPanel(new GridBagLayout());
+        canvas = new SpriteCanvas(this);
 
-	public void actionPerformed(ActionEvent e) {
-		if(e.getActionCommand().equalsIgnoreCase("New Key...")||e.getActionCommand().equalsIgnoreCase("Modify Key...")){
-			KeyDialog kd = new KeyDialog(this,currentSprite);
-			kd.doKeys();
-		}else if(e.getActionCommand().equalsIgnoreCase("Delete Key")){
-			if(currentSprite!=null){
-				currentSprite.removeKey((String)keyframe.getSelectedItem());
-			}
-		}else if(e.getActionCommand().equalsIgnoreCase("comboBoxChanged")){
-			if(currentSprite!=null){
-				currentSprite.setKeyFrameTo((String)keyframe.getSelectedItem());
-				updateStats();
-				canvas.repaint();
-			}
-		}else{
-			handleFrames(e);
-		}
-		updateList();
-		updateStats();
-	}
-	
-	public void handleFrames(ActionEvent e){
-		if(currentSprite==null){
-			return;
-		}
-		
-		if(e.getActionCommand().equalsIgnoreCase("startframe")){
-			if(currentSprite.getCurrentKey()==null){
-				JOptionPane.showMessageDialog(this,"There are no keys defined!","No Keys", JOptionPane.ERROR_MESSAGE);				
-			}else{
-				currentSprite.keySetFrame(0);
-				canvas.repaint();
-			}
-		}else if(e.getActionCommand().equalsIgnoreCase("back")){
-			if(currentSprite.getCurrentKey()==null){
-				JOptionPane.showMessageDialog(this,"There are no keys defined!","No Keys", JOptionPane.ERROR_MESSAGE);				
-			}else{
-				currentSprite.keyStepBack(1);
-				canvas.repaint();
-			}
-		}else if(e.getActionCommand().equalsIgnoreCase("playstop")){
-			if(currentSprite.getCurrentKey()==null){
-				JOptionPane.showMessageDialog(this,"There are no keys defined!","No Keys", JOptionPane.ERROR_MESSAGE);				
-			}else{
-				if(state==PLAYING){
-					state=STOPPED;
-					currentSprite.stop();
-					playstop.setIcon(playIcon);
-				}else{
-					state=PLAYING;
-					currentSprite.play();
-					playstop.setIcon(stopIcon);
-				}
-				canvas.repaint();
-			}
-		}else if(e.getActionCommand().equalsIgnoreCase("forward")){
-			if(currentSprite.getCurrentKey()==null){
-				JOptionPane.showMessageDialog(this,"There are no keys defined!","No Keys", JOptionPane.ERROR_MESSAGE);				
-			}else{
-				currentSprite.keyStepForward(1);
-				canvas.repaint();
-			}
-		}else if(e.getActionCommand().equalsIgnoreCase("lastframe")){
-			if(currentSprite.getCurrentKey()==null){
-				JOptionPane.showMessageDialog(this,"There are no keys defined!","No Keys", JOptionPane.ERROR_MESSAGE);				
-			}else{
-				currentSprite.keyStepForward(10000);
-				canvas.repaint();
-			}
-		}		
-	}
-	
+
+        GridBagConstraints c=new GridBagConstraints();
+        c.fill=GridBagConstraints.BOTH;
+        c.weightx = 1; c.weighty = 1;
+        c.gridx = 0; c.gridy = 0;
+        c.gridheight = 1; c.gridwidth = 1;
+        b = new JButton("", Resources.getIcon("startframe.png"));
+        b.setActionCommand("startframe");
+        b.setMargin(new Insets(0,0,0,0));
+        b.addActionListener(this);
+        buttons.add(b,c);
+
+        c.gridx = 1;
+        b = new JButton("", Resources.getIcon("back.png"));
+        b.setActionCommand("back");
+        b.setMargin(new Insets(0,0,0,0));
+        b.addActionListener(this);
+        buttons.add(b,c);
+
+        c.gridx = 2;
+        playstop = new JButton("", Resources.getIcon("play.png"));
+        playstop.setActionCommand("playstop");
+        playstop.setMargin(new Insets(0,0,0,0));
+        playstop.addActionListener(this);
+        buttons.add(playstop,c);
+
+        c.gridx = 3;
+        b = new JButton("", Resources.getIcon("forward.png"));
+        b.setActionCommand("forward");
+        b.setMargin(new Insets(0,0,0,0));
+        b.addActionListener(this);
+        buttons.add(b,c);
+
+        c.gridx = 4;
+        b = new JButton("", Resources.getIcon("lastframe.png"));
+        b.setActionCommand("lastframe");
+        b.setMargin(new Insets(0,0,0,0));
+        b.addActionListener(this);
+        buttons.add(b, c);
+
+        c.gridx = 0; c.gridy = 0; c.gridwidth = 2;
+        String[] defaultArr = { "None" };
+        keyframe = new JComboBox(defaultArr);
+        keyframe.addActionListener(this);
+        opt.add(keyframe,c);
+
+        c.gridwidth = 1; c.gridy = 1;
+        l = new JLabel("Range:");
+        opt.add(l,c);
+
+        c.gridx = 1;
+        lFrameRange = new JLabel("-");
+        opt.add(lFrameRange,c);
+
+        c.gridy = 2; c.gridx = 0;
+        l = new JLabel("Current:");
+        opt.add(l,c);
+
+        c.gridx = 1;
+        lCurrentFrame = new JLabel("?");
+        opt.add(lCurrentFrame,c);
+
+        c.gridy = 3; c.gridx = 0;
+        l = new JLabel("Rate:");
+        opt.add(l,c);
+
+        c.gridx = 1;
+        lFrameRate = new JLabel("?");
+        opt.add(lFrameRate,c);
+
+        data.add(canvas,BorderLayout.CENTER);
+        data.add(buttons,BorderLayout.SOUTH);
+
+        main.add(data,BorderLayout.CENTER);
+        main.add(opt,BorderLayout.EAST);
+
+        return main;
+    }
+
+    public void paintSprite(Graphics g) {
+        currentSprite.getCurrentFrame().draw(g, 0, 0, 1.0f);
+
+        if (state == PLAYING) {
+            if (currentSprite != null) {
+                if (currentSprite.getCurrentKey() == null) {
+                    JOptionPane.showMessageDialog(this,"There are no keys defined!","No Keys", JOptionPane.ERROR_MESSAGE);
+                    state=STOPPED;
+                    return;
+                }
+                currentSprite.iterateFrame();
+                updateStats();
+                canvas.repaint();
+                repaint();
+            }
+        }
+    }
+
+    public void draw(Graphics g) {
+        canvas.repaint();
+        updateList();
+    }
+
+    public void updateList() {
+        if (currentSprite != null){
+            keyframe.removeAllItems();
+            try{
+                Iterator itr = currentSprite.getKeys();
+                while(itr.hasNext()){
+                    keyframe.addItem(((Sprite.KeyFrame)itr.next()).getName());
+                }
+            }catch(Exception e){}
+        }
+    }
+
+    public void updateStats(){
+        if (currentSprite != null) {
+            Sprite.KeyFrame k = currentSprite.getKey((String)keyframe.getSelectedItem());
+            if (k != null) {
+                lCurrentFrame.setText("" + currentSprite.getCurrentFrame());
+                lFrameRate.setText("" + k.getFrameRate());
+            }
+        }
+    }
+
+    public void actionPerformed(ActionEvent e) {
+        if (e.getActionCommand().equalsIgnoreCase("New Key...")||e.getActionCommand().equalsIgnoreCase("Modify Key...")) {
+            KeyDialog kd = new KeyDialog(this,currentSprite);
+            kd.doKeys();
+        } else if (e.getActionCommand().equalsIgnoreCase("Delete Key")) {
+            if (currentSprite != null) {
+                currentSprite.removeKey((String)keyframe.getSelectedItem());
+            }
+        } else if (e.getActionCommand().equalsIgnoreCase("comboBoxChanged")) {
+            if (currentSprite != null) {
+                currentSprite.setKeyFrameTo((String)keyframe.getSelectedItem());
+                updateStats();
+                canvas.repaint();
+            }
+        } else {
+            handleFrames(e);
+        }
+        updateList();
+        updateStats();
+    }
+
+    public void handleFrames(ActionEvent e){
+        if (currentSprite == null) {
+            return;
+        }
+
+        if (e.getActionCommand().equalsIgnoreCase("startframe")) {
+            if (currentSprite.getCurrentKey()==null) {
+                JOptionPane.showMessageDialog(this,"There are no keys defined!","No Keys", JOptionPane.ERROR_MESSAGE);
+            } else {
+                currentSprite.keySetFrame(0);
+                canvas.repaint();
+            }
+        } else if (e.getActionCommand().equalsIgnoreCase("back")) {
+            if (currentSprite.getCurrentKey() == null) {
+                JOptionPane.showMessageDialog(this,"There are no keys defined!","No Keys", JOptionPane.ERROR_MESSAGE);
+            } else {
+                currentSprite.keyStepBack(1);
+                canvas.repaint();
+            }
+        }else if(e.getActionCommand().equalsIgnoreCase("playstop")){
+            if(currentSprite.getCurrentKey()==null){
+                JOptionPane.showMessageDialog(this,"There are no keys defined!","No Keys", JOptionPane.ERROR_MESSAGE);
+            }else{
+                if(state==PLAYING){
+                    state=STOPPED;
+                    currentSprite.stop();
+                    playstop.setIcon(playIcon);
+                }else{
+                    state=PLAYING;
+                    currentSprite.play();
+                    playstop.setIcon(stopIcon);
+                }
+                canvas.repaint();
+            }
+        }else if(e.getActionCommand().equalsIgnoreCase("forward")){
+            if(currentSprite.getCurrentKey()==null){
+                JOptionPane.showMessageDialog(this,"There are no keys defined!","No Keys", JOptionPane.ERROR_MESSAGE);
+            }else{
+                currentSprite.keyStepForward(1);
+                canvas.repaint();
+            }
+        }else if(e.getActionCommand().equalsIgnoreCase("lastframe")){
+            if(currentSprite.getCurrentKey()==null){
+                JOptionPane.showMessageDialog(this,"There are no keys defined!","No Keys", JOptionPane.ERROR_MESSAGE);
+            }else{
+                currentSprite.keyStepForward(10000);
+                canvas.repaint();
+            }
+        }
+    }
 }
 
 class SpriteCanvas extends JPanel{
-	
-	private AnimationDialog owner;
-	private Image buffer = null;
-	private Dimension osd;	
-	
-	SpriteCanvas(AnimationDialog o){
-		
-		owner = o;
-	}		
-	
-	/**
+
+    private AnimationDialog owner;
+    private Image buffer = null;
+    private Dimension osd;	
+
+    SpriteCanvas(AnimationDialog o){
+
+        owner = o;
+    }		
+
+    /**
      * Draws checkerboard background.
      */
     private void paintBackground(Graphics g) {
@@ -322,32 +301,32 @@
             }
         }
     }
-	
-	public void paint(Graphics g){
-		
-		if(owner!=null)
-		{
-			Dimension d = this.getSize();
-			if(buffer == null){
-				osd=d;
-				buffer=createImage(d.width,d.height);
-			}
-			
-			if(d.width!=osd.width||d.height!=osd.height){		
-				osd = d;				
-				buffer=createImage(d.width,d.height);
-			}
-			paintBackground(g);
-			if(buffer != null){
 
-				Graphics osg = buffer.getGraphics();		
-			
-				owner.paintSprite(osg);
-			
-				g.drawImage(buffer,0,0,null);
-			}else{
-				owner.paintSprite(g);
-			}
-		}		
-	}
-}
\ No newline at end of file
+    public void paint(Graphics g){
+
+        if(owner!=null)
+        {
+            Dimension d = this.getSize();
+            if(buffer == null){
+                osd=d;
+                buffer=createImage(d.width,d.height);
+            }
+
+            if(d.width!=osd.width||d.height!=osd.height){		
+                osd = d;				
+                buffer=createImage(d.width,d.height);
+            }
+            paintBackground(g);
+            if(buffer != null){
+
+                Graphics osg = buffer.getGraphics();		
+
+                owner.paintSprite(osg);
+
+                g.drawImage(buffer,0,0,null);
+            }else{
+                owner.paintSprite(g);
+            }
+        }		
+    }
+}

Modified: trunk/src/tiled/mapeditor/brush/CustomBrush.java
===================================================================
--- trunk/src/tiled/mapeditor/brush/CustomBrush.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/mapeditor/brush/CustomBrush.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -26,7 +26,6 @@
 public class CustomBrush extends AbstractBrush
 {
     public CustomBrush() {
-        super();
     }
 
     public CustomBrush(MultilayerPlane m) {
@@ -71,8 +70,8 @@
     {
         int layer = initLayer;
         Rectangle bounds = getBounds();
-        int centerx = x - (bounds.width / 2);
-        int centery = y - (bounds.height / 2);
+        int centerx = x - bounds.width / 2;
+        int centery = y - bounds.height / 2;
 
         super.doPaint(x, y);
 

Modified: trunk/src/tiled/mapeditor/brush/RandomBrush.java
===================================================================
--- trunk/src/tiled/mapeditor/brush/RandomBrush.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/mapeditor/brush/RandomBrush.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -27,11 +27,6 @@
     private final MersenneTwister mt;
     private double ratio = 0.5;
 
-    public RandomBrush() {
-        super();
-        mt = new MersenneTwister(System.currentTimeMillis());
-    }
-
     public RandomBrush(Area shape) {
         super(shape);
         mt = new MersenneTwister(System.currentTimeMillis());
@@ -69,15 +64,15 @@
             int initLayer)
     {
         Rectangle bounds = shape.getBounds();
-        int centerx = x - (bounds.width / 2);
-        int centery = y - (bounds.height / 2);
+        int centerx = x - bounds.width / 2;
+        int centery = y - bounds.height / 2;
 
         for (int i = 0; i < numLayers; i++) {
             TileLayer tl = (TileLayer)mp.getLayer(initLayer - i);
             if (tl != null) {
                 for (int cy = 0; cy <= bounds.height; cy++) {
                     for (int cx = 0; cx < bounds.width; cx++) {
-                        if (shape.contains(cx, cy) && (mt.genrand() % 101) <= (100 * ratio)) {
+                        if (shape.contains(cx, cy) && mt.genrand() % 101 <= 100 * ratio) {
                             tl.setTileAt(
                                     cx + centerx, cy + centery, paintTile);
                         }

Modified: trunk/src/tiled/mapeditor/brush/ShapeBrush.java
===================================================================
--- trunk/src/tiled/mapeditor/brush/ShapeBrush.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/mapeditor/brush/ShapeBrush.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -29,11 +29,9 @@
     protected Tile paintTile;
 
     public ShapeBrush() {
-        super();
     }
 
     public ShapeBrush(Area shape) {
-        super();
         this.shape = shape;
     }
 
@@ -52,7 +50,7 @@
      */
     public void makeCircleBrush(double rad) {
         shape = new Area(new Ellipse2D.Double(0, 0, rad * 2, rad * 2));
-        this.resize((int)(rad * 2), (int)(rad * 2), 0, 0);
+        resize((int)(rad * 2), (int)(rad * 2), 0, 0);
     }
 
     /**
@@ -62,7 +60,7 @@
      */
     public void makeQuadBrush(Rectangle r) {
         shape = new Area(new Rectangle2D.Double(r.x, r.y, r.width, r.height));
-        this.resize(r.width, r.height, 0, 0);
+        resize(r.width, r.height, 0, 0);
     }
 
     public void makePolygonBrush(Polygon p) {

Modified: trunk/src/tiled/mapeditor/dialogs/AboutDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/AboutDialog.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/mapeditor/dialogs/AboutDialog.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -12,43 +12,42 @@
 
 package tiled.mapeditor.dialogs;
 
-import java.io.IOException;
-import javax.imageio.ImageIO;
-import javax.swing.*;
+import java.awt.event.MouseEvent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.BorderFactory;
+import javax.swing.JDialog;
+import javax.swing.event.MouseInputAdapter;
 
 import tiled.mapeditor.MapEditor;
+import tiled.mapeditor.Resources;
 
-
 /**
  * The about dialog.
  *
  * @version $Id$
  */
-public class AboutDialog extends JFrame
+public class AboutDialog extends JDialog
 {
-    final JFrame parent;
+    private final JFrame parent;
 
     public AboutDialog(JFrame parent) {
-        super("Tiled v" + MapEditor.version);
+        super(parent, "Tiled v" + MapEditor.version);
 
         this.parent = parent;
-        ImageIcon icon;
 
-        try {
-            icon = new ImageIcon(ImageIO.read(MapEditor.class.
-                        getResourceAsStream("resources/logo.png")));
+        JLabel label = new JLabel(Resources.getIcon("logo.png"));
+        label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+        label.addMouseListener(new MouseInputAdapter() {
+            public void mouseClicked(MouseEvent mouseEvent) {
+                setVisible(false);
+            }
+        });
 
-            JPanel content = new JPanel();
-            JLabel label = new JLabel(icon);
-            content.add(label);
-
-            setContentPane(content);
-            setResizable(false);
-            setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
-            pack();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
+        setContentPane(label);
+        setResizable(false);
+        setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
+        pack();
     }
 
     public void setVisible(boolean visible) {

Modified: trunk/src/tiled/mapeditor/dialogs/BrushDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/BrushDialog.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/mapeditor/dialogs/BrushDialog.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -19,6 +19,7 @@
 import java.awt.event.ItemListener;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.util.prefs.Preferences;
 import javax.swing.*;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
@@ -37,6 +38,7 @@
 import tiled.mapeditor.widget.IntegerSpinner;
 import tiled.mapeditor.widget.MiniMapViewer;
 import tiled.mapeditor.widget.VerticalStaticJPanel;
+import tiled.mapeditor.Resources;
 import tiled.util.TiledConfiguration;
 
 /**
@@ -54,12 +56,11 @@
     private JSlider sRandomAmount;
     private JButton bOk, bApply, bCancel;
     private BrushBrowser brushes;
-    private MiniMapViewer mmv;
 
     public BrushDialog(MapEditor editor, JFrame parent,
                        AbstractBrush currentBrush)
     {
-        super(parent, "Brush Options", false);
+        super(parent, Resources.getString("dialog.brush.title"), false);
         myBrush = currentBrush;
         this.editor = editor;
 
@@ -144,14 +145,14 @@
     private JPanel createCustomPanel() {
         JPanel customPanel = new JPanel();
 
-        mmv = new MiniMapViewer();
+        MiniMapViewer mmv = new MiniMapViewer();
         if (myBrush instanceof CustomBrush) {
             //mmv.setView(((CustomBrush)myBrush));
         }
 
         JScrollPane miniSp = new JScrollPane();
         miniSp.getViewport().setView(mmv);
-        miniSp.setPreferredSize(new Dimension(100,100));
+        miniSp.setPreferredSize(new Dimension(100, 100));
         JButton bCreate = new JButton("Create...");
         bCreate.addActionListener(this);
         //TODO: create functionality is not available yet
@@ -313,13 +314,9 @@
     }
 
     private void openMap() throws Exception {
-        String startLocation = "";
-        TiledConfiguration configuration = TiledConfiguration.getInstance();
-
         // Start at the location of the most recently loaded map file
-        if (configuration.hasOption("tiled.recent.1")) {
-            startLocation = configuration.getValue("tiled.recent.1");
-        }
+        Preferences prefs = TiledConfiguration.node("recent");
+        String startLocation = prefs.get("file0", "");
 
         JFileChooser ch = new JFileChooser(startLocation);
 
@@ -329,7 +326,7 @@
                 ch.addChoosableFileFilter(new TiledFileFilter(
                             readers[i].getFilter(), readers[i].getName()));
             }
-        } catch (Throwable e) {
+        } catch (Exception e) {
             JOptionPane.showMessageDialog(this,
                     "Error while loading plugins: " + e.getMessage(),
                     "Error while loading map",

Modified: trunk/src/tiled/mapeditor/dialogs/ConfigurationDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/ConfigurationDialog.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/mapeditor/dialogs/ConfigurationDialog.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -13,33 +13,37 @@
 package tiled.mapeditor.dialogs;
 
 import java.awt.*;
-import java.awt.event.*;
-
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.prefs.Preferences;
 import javax.swing.*;
-import javax.swing.event.ChangeListener;
 import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
 
-import tiled.util.TiledConfiguration;
 import tiled.mapeditor.widget.IntegerSpinner;
 import tiled.mapeditor.widget.VerticalStaticJPanel;
+import tiled.util.TiledConfiguration;
 
-
-public class ConfigurationDialog extends JDialog implements ActionListener,
-       ChangeListener, ItemListener
+/**
+ * @version $Id$
+ */
+public class ConfigurationDialog extends JDialog
 {
-    private JButton bOk, bApply, bCancel;
-    private JPanel layerOps, generalOps, tilesetOps, gridOps;
     private IntegerSpinner undoDepth, gridOpacity;
     private JCheckBox cbBinaryEncode, cbCompressLayerData, cbEmbedImages;
     private JCheckBox cbReportIOWarnings;
     private JRadioButton rbEmbedInTiles, rbEmbedInSet;
     private JCheckBox cbGridAA;
-    private JColorChooser gridColor;
-    private final TiledConfiguration configuration;
+    //private JColorChooser gridColor;
 
+    private final Preferences prefs = TiledConfiguration.root();
+    private final Preferences savingPrefs = prefs.node("saving");
+    private final Preferences ioPrefs = prefs.node("io");
+
     public ConfigurationDialog(JFrame parent) {
         super(parent, "Preferences", true);
-        configuration = TiledConfiguration.getInstance();
         init();
         setLocationRelativeTo(parent);
     }
@@ -60,39 +64,11 @@
         cbGridAA = new JCheckBox("Antialiasing");
         gridOpacity = new IntegerSpinner(0, 0, 255);
         //gridColor = new JColorChooser();
-        cbBinaryEncode.addItemListener(this);
-        cbCompressLayerData.addItemListener(this);
-        cbEmbedImages.addItemListener(this);
-        cbReportIOWarnings.addItemListener(this);
-        cbGridAA.addItemListener(this);
-        undoDepth.addChangeListener(this);
-        gridOpacity.addChangeListener(this);
-        //gridColor.addChangeListener(this);
 
-        cbBinaryEncode.setActionCommand("tmx.save.encodeLayerData");
-        cbCompressLayerData.setActionCommand("tmx.save.layerCompression");
-        //cbEmbedImages.setActionCommand("tmx.save.embedImages");
-        cbReportIOWarnings.setActionCommand("tiled.report.io");
+        // Set up the layout
 
-        rbEmbedInTiles.setActionCommand("tmx.save.embedImages");
-        rbEmbedInTiles.setEnabled(false);
-        rbEmbedInSet.setActionCommand("tmx.save.tileSetImages");
-        rbEmbedInSet.setEnabled(false);
-        undoDepth.setName("tiled.undo.depth");
-        cbGridAA.setActionCommand("tiled.grid.antialias");
-        gridOpacity.setName("tiled.grid.opacity");
-        //gridColor.setName("tiled.grid.color");
-
-        bOk = new JButton("OK");
-        bApply = new JButton("Apply");
-        bCancel = new JButton("Cancel");
-        bOk.addActionListener(this);
-        bApply.addActionListener(this);
-        bCancel.addActionListener(this);
-        bApply.setEnabled(false);
-
         /* LAYER OPTIONS */
-        layerOps = new VerticalStaticJPanel();
+        JPanel layerOps = new VerticalStaticJPanel();
         layerOps.setLayout(new GridBagLayout());
         layerOps.setBorder(BorderFactory.createCompoundBorder(
                     BorderFactory.createTitledBorder("Layer Options"),
@@ -108,7 +84,7 @@
         layerOps.add(cbCompressLayerData, c);
 
         /* GENERAL OPTIONS */
-        generalOps = new VerticalStaticJPanel();
+        JPanel generalOps = new VerticalStaticJPanel();
         generalOps.setLayout(new GridBagLayout());
         generalOps.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
         c = new GridBagConstraints();
@@ -123,7 +99,7 @@
         generalOps.add(cbReportIOWarnings, c);
 
         /* TILESET OPTIONS */
-        tilesetOps = new VerticalStaticJPanel();
+        JPanel tilesetOps = new VerticalStaticJPanel();
         tilesetOps.setLayout(new GridBagLayout());
         tilesetOps.setBorder(BorderFactory.createCompoundBorder(
                     BorderFactory.createTitledBorder("Tileset Options"),
@@ -138,7 +114,7 @@
         tilesetOps.add(rbEmbedInSet, c);
 
         /* GRID OPTIONS */
-        gridOps = new VerticalStaticJPanel();
+        JPanel gridOps = new VerticalStaticJPanel();
         gridOps.setLayout(new GridBagLayout());
         gridOps.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
         c = new GridBagConstraints();
@@ -153,17 +129,19 @@
         //c.gridx = 1;
         //gridOps.add(gridColor, c);
 
+        JButton bClose = new JButton("Close");
+        bClose.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent actionEvent) {
+                dispose();
+            }
+        });
+
         /* BUTTONS PANEL */
         JPanel buttons = new VerticalStaticJPanel();
         buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
         buttons.add(Box.createGlue());
-        buttons.add(bOk);
-        buttons.add(Box.createRigidArea(new Dimension(5, 0)));
-        buttons.add(bApply);
-        buttons.add(Box.createRigidArea(new Dimension(5, 0)));
-        buttons.add(bCancel);
+        buttons.add(bClose);
 
-
         JPanel saving = new JPanel();
         saving.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
         saving.setLayout(new BoxLayout(saving, BoxLayout.Y_AXIS));
@@ -196,111 +174,103 @@
         mainPanel.add(buttons);
 
         getContentPane().add(mainPanel);
-        getRootPane().setDefaultButton(bOk);
+        getRootPane().setDefaultButton(bClose);
         pack();
-    }
 
-    public void configure() {
-        updateFromConf();
-        setVisible(true);
-    }
+        // Associate listeners with the configuration widgets
 
-    private void updateFromConf() {
-        undoDepth.setValue(configuration.getIntValue(undoDepth.getName(), 30));
-        gridOpacity.setValue(
-                configuration.getIntValue(gridOpacity.getName(), 255));
+        cbBinaryEncode.addItemListener(new ItemListener() {
+            public void itemStateChanged(ItemEvent itemEvent) {
+                final boolean selected = cbBinaryEncode.isSelected();
+                savingPrefs.putBoolean("encodeLayerData", selected);
+                cbCompressLayerData.setEnabled(selected);
+            }
+        });
 
-        if (configuration.keyHasValue("tmx.save.embedImages", "1")) {
-            cbEmbedImages.setSelected(true);
-            rbEmbedInTiles.setSelected(true);
-        }
+        cbCompressLayerData.addItemListener(new ItemListener() {
+            public void itemStateChanged(ItemEvent itemEvent) {
+                savingPrefs.putBoolean("layerCompression",
+                        cbCompressLayerData.isSelected());
+            }
+        });
 
-        // Handle checkboxes
-        updateFromConf(layerOps);
-        updateFromConf(generalOps);
-        updateFromConf(tilesetOps);
-        updateFromConf(gridOps);
+        cbEmbedImages.addItemListener(new ItemListener() {
+            public void itemStateChanged(ItemEvent itemEvent) {
+                final boolean embed = cbEmbedImages.isSelected();
+                savingPrefs.putBoolean("embedImages", embed);
+                rbEmbedInTiles.setSelected(embed && rbEmbedInTiles.isSelected());
+                rbEmbedInTiles.setEnabled(embed);
+                rbEmbedInSet.setSelected(embed && rbEmbedInSet.isSelected());
+                rbEmbedInSet.setEnabled(embed);
+            }
+        });
 
-        cbCompressLayerData.setEnabled(cbBinaryEncode.isSelected());
+        cbReportIOWarnings.addItemListener(new ItemListener() {
+            public void itemStateChanged(ItemEvent itemEvent) {
+                ioPrefs.putBoolean("reportWarnings",
+                        cbReportIOWarnings.isSelected());
+            }
+        });
 
-        bApply.setEnabled(false);
-    }
+        cbGridAA.addItemListener(new ItemListener() {
+            public void itemStateChanged(ItemEvent itemEvent) {
+                prefs.putBoolean("gridAntialias", cbGridAA.isSelected());
+            }
+        });
 
-    private void updateFromConf(Container container) {
-        for (int i = 0; i < container.getComponentCount(); i++) {
-            Component c = container.getComponent(i);
-            try {
-                AbstractButton b = (AbstractButton)c;
-                if (b.getClass().equals(JCheckBox.class)) {
-                    if (configuration.keyHasValue(b.getActionCommand(), "1")) {
-                        b.setSelected(true);
-                    }
-                }
-            } catch (ClassCastException e) {
+        undoDepth.addChangeListener(new ChangeListener() {
+            public void stateChanged(ChangeEvent changeEvent) {
+                prefs.putInt("undoDepth", undoDepth.intValue());
             }
-        }
-    }
+        });
 
-    private void processOptions() {
-        configuration.addConfigPair(
-                undoDepth.getName(), "" + undoDepth.intValue());
-        configuration.addConfigPair(
-                gridOpacity.getName(), "" + gridOpacity.intValue());
+        gridOpacity.addChangeListener(new ChangeListener() {
+            public void stateChanged(ChangeEvent changeEvent) {
+                prefs.putInt("gridOpacity", gridOpacity.intValue());
+            }
+        });
 
-        // Handle checkboxes
-        processOptions(layerOps);
-        processOptions(generalOps);
-        processOptions(tilesetOps);
-        processOptions(gridOps);
+        //gridColor.addChangeListener(...);
 
-        bApply.setEnabled(false);
-    }
+        rbEmbedInTiles.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent actionEvent) {
+                savingPrefs.putBoolean("embedImages",
+                        rbEmbedInTiles.isSelected());
+            }
+        });
 
-    private void processOptions(Container container) {
-        for (int i = 0; i < container.getComponentCount(); i++) {
-            Component c = container.getComponent(i);
-            try {
-                AbstractButton b = (AbstractButton)c;
-                if (b.getClass().equals(JCheckBox.class)) {
-                    configuration.addConfigPair(
-                            b.getActionCommand(), b.isSelected() ? "1" : "0");
-                }
-            } catch (ClassCastException e) {
+        rbEmbedInSet.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent actionEvent) {
+                savingPrefs.putBoolean("tileSetImages",
+                        rbEmbedInSet.isSelected());
             }
-        }
-    }
+        });
 
-    public void actionPerformed(ActionEvent event) {
-        Object source = event.getSource();
+        rbEmbedInTiles.setEnabled(false);
+        rbEmbedInSet.setEnabled(false);
 
-        if (source == bOk) {
-            processOptions();
-            dispose();
-        } else if (source == bCancel) {
-            dispose();
-        } else if (source == bApply) {
-            processOptions();
-        }
+        //gridColor.setName("tiled.grid.color");
     }
 
-    public void stateChanged(ChangeEvent event) {
-        bApply.setEnabled(true);
+    public void configure() {
+        updateFromConfiguration();
+        setVisible(true);
     }
 
-    public void itemStateChanged(ItemEvent event) {
-        Object source = event.getItemSelectable();
+    private void updateFromConfiguration() {
+        undoDepth.setValue(prefs.getInt("undoDepth", 30));
+        gridOpacity.setValue(prefs.getInt("gridOpacity", 255));
 
-        if (source == cbBinaryEncode) {
-            cbCompressLayerData.setEnabled(cbBinaryEncode.isSelected());
-        } else if (source == cbEmbedImages) {
-            rbEmbedInTiles.setSelected(
-                    cbEmbedImages.isSelected() && rbEmbedInTiles.isSelected());
-            rbEmbedInTiles.setEnabled(cbEmbedImages.isSelected());
-            rbEmbedInSet.setSelected(
-                    cbEmbedImages.isSelected() && rbEmbedInSet.isSelected());
-            rbEmbedInSet.setEnabled(cbEmbedImages.isSelected());
+        if (savingPrefs.getBoolean("embedImages", true)) {
+            cbEmbedImages.setSelected(true);
+            rbEmbedInTiles.setSelected(true);
         }
 
-        bApply.setEnabled(true);
+        cbBinaryEncode.setSelected(savingPrefs.getBoolean("encodeLayerData", true));
+        cbCompressLayerData.setSelected(savingPrefs.getBoolean("layerCompression", true));
+        cbGridAA.setSelected(savingPrefs.getBoolean("gridAntialias", true));
+        cbReportIOWarnings.setSelected(ioPrefs.getBoolean("reportWarnings", false));
+
+        cbCompressLayerData.setEnabled(cbBinaryEncode.isSelected());
     }
 }

Modified: trunk/src/tiled/mapeditor/dialogs/ImageColorDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/ImageColorDialog.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/mapeditor/dialogs/ImageColorDialog.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -34,14 +34,9 @@
     private JButton bCancel;
     private Color color;
     private JPanel colorPanel;
-    private int pixels[];
+    private int[] pixels;
 
-    public ImageColorDialog() {
-        super();
-    }
-
     public ImageColorDialog(Image i) {
-        this();
         image = i;
         PixelGrabber pg = new PixelGrabber(i, 0, 0, -1, -1, true);
 
@@ -141,9 +136,9 @@
         int w = image.getWidth(null);
         int h = image.getHeight(null);
         if (pixels != null && (x < w && y < h)) {
-            int r = (pixels[y * w + x] >> 16) & 0xff;
-            int g = (pixels[y * w + x] >> 8) & 0xff;
-            int b = (pixels[y * w + x]) & 0xff;
+            int r = pixels[y * w + x] >> 16 & 0xff;
+            int g = pixels[y * w + x] >> 8 & 0xff;
+            int b = pixels[y * w + x] & 0xff;
 
             color = new Color(r, g, b);
             colorPanel.setBackground(color);

Modified: trunk/src/tiled/mapeditor/dialogs/NewMapDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/NewMapDialog.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/mapeditor/dialogs/NewMapDialog.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -12,16 +12,24 @@
 
 package tiled.mapeditor.dialogs;
 
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.prefs.Preferences;
 import javax.swing.*;
 import java.io.*;
 
-import tiled.core.*;
-import tiled.util.TiledConfiguration;
+import tiled.core.Map;
 import tiled.mapeditor.widget.IntegerSpinner;
 import tiled.mapeditor.widget.VerticalStaticJPanel;
+import tiled.util.TiledConfiguration;
 
+/**
+ * @version $Id$
+ */
 public class NewMapDialog extends JDialog implements ActionListener
 {
     private Map newMap;
@@ -29,6 +37,8 @@
     private IntegerSpinner tileWidth, tileHeight;
     private JComboBox mapTypeChooser;
 
+    private final Preferences prefs = TiledConfiguration.node("dialog/newmap");
+
     public NewMapDialog(JFrame parent) {
         super(parent, "New Map", true);
         init();
@@ -41,13 +51,11 @@
 
         // Load dialog defaults
 
-        TiledConfiguration conf = TiledConfiguration.getInstance();
+        int defaultMapWidth = prefs.getInt("mapWidth", 64);
+        int defaultMapHeight = prefs.getInt("mapHeight", 64);
+        int defaultTileWidth = prefs.getInt("tileWidth", 35);
+        int defaultTileHeight = prefs.getInt("tileHeight", 35);
 
-        int defaultMapWidth = conf.getIntValue("tiled.newmapdialog.mapwidth", 64);
-        int defaultMapHeight = conf.getIntValue("tiled.newmapdialog.mapheight", 64);
-        int defaultTileWidth = conf.getIntValue("tiled.newmapdialog.tilewidth", 35);
-        int defaultTileHeight = conf.getIntValue("tiled.newmapdialog.tileheight", 35);
-
         // Create the primitives
 
         mapWidth = new IntegerSpinner(defaultMapWidth, 1);
@@ -182,13 +190,10 @@
 
             // Save dialog options
 
-            TiledConfiguration conf = TiledConfiguration.getInstance();
-            conf.addConfigPair("tiled.newmapdialog.mapwidth", Integer.toString(mapWidth.intValue()));
-            conf.addConfigPair("tiled.newmapdialog.mapheight", Integer.toString(mapHeight.intValue()));
-            conf.addConfigPair("tiled.newmapdialog.tilewidth", Integer.toString(tileWidth.intValue()));
-            conf.addConfigPair("tiled.newmapdialog.tileheight", Integer.toString(tileHeight.intValue()));
-
-            conf.flush();
+            prefs.putInt("mapWidth", mapWidth.intValue());
+            prefs.putInt("mapHeight", mapHeight.intValue());
+            prefs.putInt("tileWidth", tileWidth.intValue());
+            prefs.putInt("tileHeight", tileHeight.intValue());
         }
         dispose();
     }

Modified: trunk/src/tiled/mapeditor/dialogs/NewTilesetDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/NewTilesetDialog.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/mapeditor/dialogs/NewTilesetDialog.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -31,34 +31,50 @@
 import tiled.mapeditor.widget.IntegerSpinner;
 import tiled.mapeditor.widget.ColorButton;
 import tiled.mapeditor.widget.VerticalStaticJPanel;
+import tiled.mapeditor.Resources;
 
-
 /**
  * A dialog for creating a new tileset.
  *
  * @version $Id$
  */
-public class NewTilesetDialog extends JDialog implements ActionListener,
-       ChangeListener
+public class NewTilesetDialog extends JDialog implements ChangeListener
 {
     private Map map;
     private TileSet newTileset;
-    private JTextField tileWidth, tileHeight;
+    private IntegerSpinner tileWidth, tileHeight;
     private IntegerSpinner tileSpacing;
     private JTextField tilesetName;
     private JTextField tilebmpFile;
-    private JLabel nameLabel, tileWidthLabel, tileHeightLabel, spacingLabel;
+    private JLabel spacingLabel;
     private JLabel tilebmpFileLabel, cutterLabel;
     private JCheckBox tilebmpCheck, tileAutoCheck, transCheck;
     private JComboBox cutterBox;
-    //private JRadioButton importRadio;
-    //private JRadioButton referenceRadio;
-    private JButton okButton, cancelButton, browseButton, propsButton;
+    private JButton browseButton;
+    private JButton propsButton;
     private ColorButton colorButton;
     private String path;
 
+    private static final String DIALOG_TITLE = Resources.getString("dialog.newtileset.title");
+    private static final String NAME_LABEL = Resources.getString("dialog.newtileset.name.label");
+    private static final String TILE_WIDTH_LABEL = Resources.getString("dialog.newtileset.tilewidth.label");
+    private static final String TILE_HEIGHT_LABEL = Resources.getString("dialog.newtileset.tileheight.label");
+    private static final String TILE_SPACING_LABEL = Resources.getString("dialog.newtileset.tilespacing.label");
+    private static final String IMAGE_LABEL = Resources.getString("dialog.newtileset.image.label");
+    private static final String UNTITLED_FILE = Resources.getString("general.file.untitled");
+    private static final String TILESET_IMG_LABEL = Resources.getString("dialog.newtileset.tilesetimgref.label");
+    private static final String AUTO_TILES_LABEL = Resources.getString("dialog.newtileset.autotiles.label");
+    private static final String USE_TRANS_COLOR_LABEL = Resources.getString("dialog.newtileset.usetransparentcolor.label");
+    private static final String OK_BUTTON = Resources.getString("general.button.ok");
+    private static final String CANCEL_BUTTON = Resources.getString("general.button.cancel");
+    private static final String BROWSE_BUTTON = Resources.getString("general.button.browse");
+    private static final String FROM_TILESET_IMG_TITLE = Resources.getString("dialog.newtileset.fromtilesetimg.title");
+    private static final String IMPORT_ERROR_MSG = Resources.getString("dialog.newtileset.import.error.message");
+    private static final String IMG_LOAD_ERROR = Resources.getString("dialog.newtileset.imgload.error.message");
+    private static final String COLOR_CHOOSE_ERROR_TITLE = Resources.getString("dialog.newtileset.colorchoose.error.title");
+
     public NewTilesetDialog(JFrame parent, Map map) {
-        super(parent, "New Tileset", true);
+        super(parent, DIALOG_TITLE, true);
         this.map = map;
         path = map.getFilename();
         init();
@@ -69,59 +85,60 @@
     private void init() {
         // Create the primitives
 
-        nameLabel = new JLabel("Tileset name: ");
-        tileWidthLabel = new JLabel("Tile width: ");
-        tileHeightLabel = new JLabel("Tile height: ");
-        spacingLabel = new JLabel("Tile spacing: ");
-        tilebmpFileLabel = new JLabel("Tile image: ");
+        JLabel nameLabel = new JLabel(NAME_LABEL);
+        JLabel tileWidthLabel = new JLabel(TILE_WIDTH_LABEL);
+        JLabel tileHeightLabel = new JLabel(TILE_HEIGHT_LABEL);
+        spacingLabel = new JLabel(TILE_SPACING_LABEL);
+        tilebmpFileLabel = new JLabel(IMAGE_LABEL);
         cutterLabel = new JLabel("Tile Cutter: ");
 
-        tilesetName = new JTextField("Untitled");
-        tileWidth = new JTextField("" + map.getTileWidth(), 3);
-        tileHeight = new JTextField("" + map.getTileHeight(), 3);
+        tilesetName = new JTextField(UNTITLED_FILE);
+        tileWidth = new IntegerSpinner(map.getTileWidth(), 1, 1024);
+        tileHeight = new IntegerSpinner(map.getTileHeight(), 1, 1024);
         tileSpacing = new IntegerSpinner(0, 0);
         tilebmpFile = new JTextField(10);
         tilebmpFile.setEnabled(false);
 
+        nameLabel.setLabelFor(tilesetName);
+        tileWidthLabel.setLabelFor(tileWidth);
+        tileHeightLabel.setLabelFor(tileHeight);
+        spacingLabel.setLabelFor(tileSpacing);
+        tilebmpFileLabel.setLabelFor(tilebmpFile);
+
         tileWidthLabel.setEnabled(false);
-        tileHeightLabel.setEnabled(false);
         tileWidth.setEnabled(false);
-        tileHeight.setEnabled(false);
 
         cutterBox = new JComboBox(new String[] {"Basic", "Border"});
         cutterBox.setEditable(false);
         cutterBox.setEnabled(false);
         cutterLabel.setEnabled(false);
-        
-        tilebmpCheck = new JCheckBox("Reference tileset image", false);
+
+        tilebmpCheck = new JCheckBox(TILESET_IMG_LABEL, false);
         tilebmpCheck.addChangeListener(this);
 
-        tileAutoCheck = new JCheckBox("Automatically create tiles from images",
-                                      true);
+        tileAutoCheck = new JCheckBox(AUTO_TILES_LABEL, true);
         tileAutoCheck.setEnabled(false);
 
-        transCheck = new JCheckBox("Use transparent color");
+        transCheck = new JCheckBox(USE_TRANS_COLOR_LABEL);
         transCheck.addChangeListener(this);
 
-        okButton = new JButton("OK");
-        cancelButton = new JButton("Cancel");
-        browseButton = new JButton("Browse...");
+        JButton okButton = new JButton(OK_BUTTON);
+        JButton cancelButton = new JButton(CANCEL_BUTTON);
+        browseButton = new JButton(BROWSE_BUTTON);
         propsButton = new JButton("Set Default Properties...");
         colorButton = new ColorButton(new Color(255, 0, 255));
-        okButton.addActionListener(this);
-        cancelButton.addActionListener(this);
-        browseButton.addActionListener(this);
-        propsButton.addActionListener(this);
-        colorButton.addActionListener(this);
 
         // Combine browse button and tile bitmap path text field
 
         JPanel tilebmpPathPanel = new JPanel(new GridBagLayout());
         GridBagConstraints c = new GridBagConstraints();
-        c.gridx = 0; c.gridy = 0; c.weightx = 1;
+        c.gridx = 0;
+        c.gridy = 0;
+        c.weightx = 1;
         c.fill = GridBagConstraints.HORIZONTAL;
         tilebmpPathPanel.add(tilebmpFile, c);
-        c.gridx = 1; c.weightx = 0;
+        c.gridx = 1;
+        c.weightx = 0;
         c.fill = GridBagConstraints.NONE;
         c.insets = new Insets(0, 5, 0, 0);
         tilebmpPathPanel.add(browseButton, c);
@@ -130,7 +147,9 @@
 
         JPanel tileColorPanel = new JPanel(new GridBagLayout());
         c = new GridBagConstraints();
-        c.gridx = 0; c.gridy = 0; c.weightx = 1;
+        c.gridx = 0;
+        c.gridy = 0;
+        c.weightx = 1;
         c.fill = GridBagConstraints.HORIZONTAL;
         tileColorPanel.add(transCheck, c);
         c.gridx = 1;
@@ -141,9 +160,11 @@
         JPanel tilebmpPanel = new VerticalStaticJPanel();
         tilebmpPanel.setLayout(new GridBagLayout());
         tilebmpPanel.setBorder(BorderFactory.createCompoundBorder(
-                    BorderFactory.createTitledBorder("From tileset image"),
-                    BorderFactory.createEmptyBorder(0, 5, 5, 5)));
-        c.gridx = 0; c.gridy = 0; c.weightx = 0;
+                BorderFactory.createTitledBorder(FROM_TILESET_IMG_TITLE),
+                BorderFactory.createEmptyBorder(0, 5, 5, 5)));
+        c.gridx = 0;
+        c.gridy = 0;
+        c.weightx = 0;
         c.insets = new Insets(5, 0, 0, 0);
         c.anchor = GridBagConstraints.EAST;
         c.fill = GridBagConstraints.HORIZONTAL;
@@ -151,24 +172,31 @@
         tilebmpPanel.add(tilebmpCheck, c);
         c.gridy = 1;
         tilebmpPanel.add(tileAutoCheck, c);
-        c.gridy = 2; c.gridwidth = 1;
+        c.gridy = 2;
+        c.gridwidth = 1;
+        c.insets = new Insets(5, 0, 0, 5);
         c.fill = GridBagConstraints.NONE;
         tilebmpPanel.add(tilebmpFileLabel, c);
         c.gridy = 3;
         tilebmpPanel.add(spacingLabel, c);
         c.gridy = 4;
-        tilebmpPanel.add(cutterLabel,c );
-        c.gridx = 1; c.gridy = 2; c.weightx = 1;
+        tilebmpPanel.add(cutterLabel, c);
+        c.gridx = 1;
+        c.gridy = 2;
+        c.insets = new Insets(5, 0, 0, 0);
         c.fill = GridBagConstraints.HORIZONTAL;
         tilebmpPanel.add(tilebmpPathPanel, c);
         c.gridy = 3;
         tilebmpPanel.add(tileSpacing, c);
         c.gridy = 4;
-        tilebmpPanel.add(cutterBox,c);
-        c.gridx = 0; c.gridy = 5; c.gridwidth = 2;
+        tilebmpPanel.add(cutterBox, c);
+        c.gridx = 0;
+        c.gridy = 5;
+        c.gridwidth = 2;
         tilebmpPanel.add(tileColorPanel, c);
-        c.gridx = 1; c.gridwidth = 1;
-        
+        c.gridx = 1;
+        c.gridwidth = 1;
+
         // OK and Cancel buttons
 
         JPanel buttons = new VerticalStaticJPanel();
@@ -178,22 +206,26 @@
         buttons.add(Box.createRigidArea(new Dimension(5, 0)));
         buttons.add(cancelButton);
 
-
         // Top part of form
 
         JPanel miscPropPanel = new VerticalStaticJPanel();
         miscPropPanel.setLayout(new GridBagLayout());
         miscPropPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
-        c.gridx = 0; c.gridy = 0; c.weightx = 0;
+        c.gridx = 0;
+        c.gridy = 0;
+        c.weightx = 0;
         c.fill = GridBagConstraints.NONE;
-        c.insets = new Insets(5, 0, 0, 0);
+        c.insets = new Insets(5, 0, 0, 5);
         miscPropPanel.add(nameLabel, c);
         c.gridy = 1;
         miscPropPanel.add(tileWidthLabel, c);
         c.gridy = 2;
         miscPropPanel.add(tileHeightLabel, c);
+        c.insets = new Insets(5, 0, 0, 0);
         c.fill = GridBagConstraints.HORIZONTAL;
-        c.gridx = 1; c.gridy = 0; c.weightx = 1;
+        c.gridx = 1;
+        c.gridy = 0;
+        c.weightx = 1;
         miscPropPanel.add(tilesetName, c);
         c.gridy = 1;
         miscPropPanel.add(tileWidth, c);
@@ -201,7 +233,7 @@
         miscPropPanel.add(tileHeight, c);
         c.gridy = 3;
         miscPropPanel.add(propsButton, c);
-        
+
         // Main panel
 
         JPanel mainPanel = new JPanel();
@@ -217,6 +249,38 @@
         getRootPane().setDefaultButton(okButton);
 
         setUseTileBitmap(tilebmpCheck.isSelected());
+
+        // Attach the behaviour
+
+        okButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent actionEvent) {
+                createSetAndDispose();
+            }
+        });
+
+        cancelButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent actionEvent) {
+                dispose();
+            }
+        });
+
+        browseButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent actionEvent) {
+                JFileChooser ch = new JFileChooser(path);
+
+                int ret = ch.showOpenDialog(NewTilesetDialog.this);
+                if (ret == JFileChooser.APPROVE_OPTION) {
+                    path = ch.getSelectedFile().getAbsolutePath();
+                    tilebmpFile.setText(path);
+                }
+            }
+        });
+
+        colorButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent actionEvent) {
+                chooseColorFromImage();
+            }
+        });
     }
 
     public TileSet create() {
@@ -225,96 +289,79 @@
     }
 
     public TileCutter getCutter(int w, int h, int s) {
-    	if(((String)cutterBox.getSelectedItem()).equalsIgnoreCase("basic")) {
-    		return new BasicTileCutter(w, h, s, 0);
-    	} else if(((String)cutterBox.getSelectedItem()).equalsIgnoreCase("border")) {
-    		return new BorderTileCutter();
-    	}
-    	
-    	return null;
+        final String selectedItem = (String) cutterBox.getSelectedItem();
+        if (selectedItem.equalsIgnoreCase("basic")) {
+            return new BasicTileCutter(w, h, s, 0);
+        } else if (selectedItem.equalsIgnoreCase("border")) {
+            return new BorderTileCutter();
+        }
+
+        return null;
     }
-    
-    public void actionPerformed(ActionEvent event) {
-        Object source = event.getSource();
 
-        if (source == okButton) {
-            newTileset = new TileSet();
-            newTileset.setName(tilesetName.getText());
+    private void createSetAndDispose() {
+        newTileset = new TileSet();
+        newTileset.setName(tilesetName.getText());
 
-            if (tilebmpCheck.isSelected()) {
-                String file = tilebmpFile.getText();
-                int spacing = tileSpacing.intValue();
-                try {
-                    if (!transCheck.isSelected()) {
-                    	newTileset.importTileBitmap(file,
-                                getCutter(map.getTileWidth(),
-                                map.getTileHeight(),
-                                spacing),
-                                tileAutoCheck.isSelected());
-                    } else {
-                        try {
-                            Toolkit tk = Toolkit.getDefaultToolkit();
-                            Image orig = ImageIO.read(new File(file));
-                            Image trans = tk.createImage(
-                                    new FilteredImageSource(orig.getSource(),
+        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),
+                            tileAutoCheck.isSelected());
+                } 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);
+                                                colorButton.getColor().getRGB())));
+                        BufferedImage img = new BufferedImage(
+                                trans.getWidth(null),
+                                trans.getHeight(null),
+                                BufferedImage.TYPE_INT_ARGB);
 
-                            img.getGraphics().drawImage(trans, 0, 0, null);
+                        img.getGraphics().drawImage(trans, 0, 0, null);
 
-                            newTileset.importTileBitmap(img,
-                                    getCutter(map.getTileWidth(),
-                                    map.getTileHeight(),
-                                    spacing),
-                                    tileAutoCheck.isSelected());
+                        newTileset.importTileBitmap(img,
+                                getCutter(width, height, spacing),
+                                tileAutoCheck.isSelected());
 
-                            newTileset.setTransparentColor(
-                                    colorButton.getColor());
+                        newTileset.setTransparentColor(
+                                colorButton.getColor());
 
-                            newTileset.setTilesetImageFilename(file);
-                        } catch (Exception e) {
-                        }
+                        newTileset.setTilesetImageFilename(file);
+                    } catch (IOException e) {
                     }
-                } catch (Exception e) {
-                    JOptionPane.showMessageDialog(this,
-                                                  e.getMessage(), "Error while importing tileset",
-                                                  JOptionPane.ERROR_MESSAGE);
-                    newTileset = null;
                 }
+            } catch (Exception e) {
+                JOptionPane.showMessageDialog(this, e.getMessage(),
+                        IMPORT_ERROR_MSG, JOptionPane.ERROR_MESSAGE);
+                newTileset = null;
             }
+        }
 
-            dispose();
-        } else if (source == browseButton) {
-            JFileChooser ch = new JFileChooser(path);
+        dispose();
+    }
 
-            int ret = ch.showOpenDialog(this);
-            if (ret == JFileChooser.APPROVE_OPTION) {
-                path = ch.getSelectedFile().getAbsolutePath();
-                tilebmpFile.setText(path);
+    private void chooseColorFromImage() {
+        ImageColorDialog icd;
+        try {
+            icd = new ImageColorDialog(
+                    ImageIO.read(new File(tilebmpFile.getText())));
+            Color c = icd.showDialog();
+            if (c != null) {
+                colorButton.setColor(c);
             }
-        } else if (source == colorButton) {
-            ImageColorDialog icd;
-            try {
-                icd = new ImageColorDialog(
-                        ImageIO.read(new File(tilebmpFile.getText())));
-                Color c = icd.showDialog();
-                if (c != null) {
-                    colorButton.setColor(c);
-                }
-            } catch (IOException e) {
-                JOptionPane.showMessageDialog(getOwner(),
-                                              "Error while loading image: " + e.getMessage(),
-                                              "Error while choosing color",
-                                              JOptionPane.ERROR_MESSAGE);
-            }
-        } else if (source == propsButton) {
-        	
-        } else {
-            dispose();
+        } catch (IOException e) {
+            JOptionPane.showMessageDialog(getOwner(),
+                    IMG_LOAD_ERROR + e.getMessage(),
+                    COLOR_CHOOSE_ERROR_TITLE, JOptionPane.ERROR_MESSAGE);
         }
     }
 

Modified: trunk/src/tiled/mapeditor/dialogs/ObjectDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/ObjectDialog.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/mapeditor/dialogs/ObjectDialog.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -14,11 +14,12 @@
 
 import javax.swing.JDialog;
 
-
+/**
+ * @version $Id$
+ */
 public class ObjectDialog extends JDialog
 {
     ObjectDialog() {
-        super();
     }
 
     public void init() {

Modified: trunk/src/tiled/mapeditor/dialogs/PluginDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/PluginDialog.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/mapeditor/dialogs/PluginDialog.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -33,7 +33,7 @@
        ListSelectionListener
 {
     private final PluginClassLoader pluginLoader;
-    private JList pluginList = null;
+    private JList pluginList;
     private JButton closeButton, infoButton, removeButton;
 
     public PluginDialog(JFrame parent, PluginClassLoader pluginLoader) {
@@ -47,8 +47,8 @@
 
     private void init() {
         /* LIST PANEL */
-        MapReader readers[];
-        MapWriter writers[];
+        MapReader[] readers;
+        MapWriter[] writers;
 
         try {
             readers = pluginLoader.getReaders();
@@ -108,7 +108,7 @@
         Object source = event.getSource();
 
         if (source == closeButton) {
-            this.dispose();
+            dispose();
         } else if (source == removeButton) {
             // TODO: Implement plugin remove functionality
         } else if (source == infoButton) {

Modified: trunk/src/tiled/mapeditor/dialogs/PropertiesDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/PropertiesDialog.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/mapeditor/dialogs/PropertiesDialog.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -15,16 +15,15 @@
 import java.awt.Dimension;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.io.IOException;
 import java.util.Enumeration;
 import java.util.Properties;
 import javax.swing.*;
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
 
-import tiled.mapeditor.MapEditor;
-import tiled.mapeditor.util.*;
-import tiled.mapeditor.widget.*;
+import tiled.mapeditor.Resources;
+import tiled.mapeditor.util.PropertiesTableModel;
+import tiled.mapeditor.widget.VerticalStaticJPanel;
 
 public class PropertiesDialog extends JDialog implements ActionListener,
        ListSelectionListener
@@ -50,12 +49,8 @@
 
         bOk = new JButton("OK");
         bCancel = new JButton("Cancel");
-        try {
-            bDel = new JButton(new ImageIcon(MapEditor.loadImageResource("resources/gnome-delete.png")));
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        
+        bDel = new JButton(Resources.getIcon("gnome-delete.png"));
+
         bOk.addActionListener(this);
         bCancel.addActionListener(this);
         bDel.addActionListener(this);

Modified: trunk/src/tiled/mapeditor/dialogs/ResizeDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/ResizeDialog.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/mapeditor/dialogs/ResizeDialog.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -23,6 +23,7 @@
 
 import tiled.core.Map;
 import tiled.mapeditor.MapEditor;
+import tiled.mapeditor.Resources;
 import tiled.mapeditor.widget.*;
 
 /**
@@ -36,8 +37,19 @@
     private JButton bOk, bCancel;
     private ResizePanel orient;
 
+    private static final String DIALOG_TITLE = Resources.getString("dialog.resizemap.title");
+    private static final String OK_BUTTON = Resources.getString("general.button.ok");
+    private static final String CANCEL_BUTTON = Resources.getString("general.button.cancel");
+    private static final String OFFSET_TITLE = Resources.getString("dialog.resizemap.offset.title");
+    private static final String X_LABEL = Resources.getString("dialog.resizemap.x.label");
+    private static final String Y_LABEL = Resources.getString("dialog.resizemap.y.label");
+    private static final String NEWSIZE_TITLE = Resources.getString("dialog.resizemap.newsize.title");
+    private static final String WIDTH_LABEL = Resources.getString("dialog.resizemap.width.label");
+    private static final String HEIGHT_LABEL = Resources.getString("dialog.resizemap.height.label");
+    private static final String CURRENT_SIZE_TITLE = Resources.getString("dialog.resizemap.currentsize.title");
+
     public ResizeDialog(JFrame parent, MapEditor m) {
-        super(parent, "Resize Map", true);
+        super(parent, DIALOG_TITLE, true);
         currentMap = m.getCurrentMap();
         init();
         setLocationRelativeTo(getOwner());
@@ -46,8 +58,8 @@
     private void init() {
         // Create the primitives
 
-        bOk = new JButton("OK");
-        bCancel = new JButton("Cancel");
+        bOk = new JButton(OK_BUTTON);
+        bCancel = new JButton(CANCEL_BUTTON);
 
         width = new IntegerSpinner(currentMap.getWidth(), 1);
         height = new IntegerSpinner(currentMap.getHeight(), 1);
@@ -63,16 +75,16 @@
         // Offset panel
         JPanel offsetPanel = new VerticalStaticJPanel();
         offsetPanel.setBorder(BorderFactory.createCompoundBorder(
-                    BorderFactory.createTitledBorder("Offset"),
+                    BorderFactory.createTitledBorder(OFFSET_TITLE),
                     BorderFactory.createEmptyBorder(0, 5, 5, 5)));
         offsetPanel.setLayout(new GridBagLayout());
         GridBagConstraints c = new GridBagConstraints();
         c.anchor = GridBagConstraints.WEST;
         c.fill = GridBagConstraints.BOTH; c.weighty = 1;
         c.insets = new Insets(5, 0, 0, 0);
-        offsetPanel.add(new JLabel("X: "), c);
+        offsetPanel.add(new JLabel(X_LABEL), c);
         c.gridy = 1;
-        offsetPanel.add(new JLabel("Y: "), c);
+        offsetPanel.add(new JLabel(Y_LABEL), c);
         c.gridx = 1; c.gridy = 0;
         offsetPanel.add(offsetX, c);
         c.gridy = 1;
@@ -85,15 +97,15 @@
         // New size panel
         JPanel newSizePanel = new VerticalStaticJPanel(new GridBagLayout());
         newSizePanel.setBorder(BorderFactory.createCompoundBorder(
-                    BorderFactory.createTitledBorder("New size"),
+                    BorderFactory.createTitledBorder(NEWSIZE_TITLE),
                     BorderFactory.createEmptyBorder(0, 5, 5, 5)));
         c = new GridBagConstraints();
         c.anchor = GridBagConstraints.WEST;
         c.fill = GridBagConstraints.BOTH; c.weighty = 1;
         c.insets = new Insets(5, 0, 0, 0);
-        newSizePanel.add(new JLabel("Width: "), c);
+        newSizePanel.add(new JLabel(WIDTH_LABEL), c);
         c.gridy = 1;
-        newSizePanel.add(new JLabel("Height: "), c);
+        newSizePanel.add(new JLabel(HEIGHT_LABEL), c);
         c.fill = GridBagConstraints.HORIZONTAL;
         c.gridx = 1; c.gridy = 0; c.weightx = 1;
         newSizePanel.add(width, c);
@@ -103,21 +115,21 @@
         // Original size panel
         JPanel origSizePanel = new VerticalStaticJPanel(new GridBagLayout());
         origSizePanel.setBorder(BorderFactory.createCompoundBorder(
-                    BorderFactory.createTitledBorder("Current size"),
+                    BorderFactory.createTitledBorder(CURRENT_SIZE_TITLE),
                     BorderFactory.createEmptyBorder(0, 5, 5, 5)));
         c = new GridBagConstraints();
         c.anchor = GridBagConstraints.EAST;
         c.fill = GridBagConstraints.BOTH; c.weighty = 1; c.weightx = 1;
         c.insets = new Insets(5, 0, 0, 0);
-        origSizePanel.add(new JLabel("Width: "), c);
+        origSizePanel.add(new JLabel(WIDTH_LABEL), c);
         c.gridy = 1;
-        origSizePanel.add(new JLabel("Height: "), c);
+        origSizePanel.add(new JLabel(HEIGHT_LABEL), c);
         c.anchor = GridBagConstraints.WEST;
         c.insets = new Insets(5, 10, 0, 0);
         c.gridx = 1; c.gridy = 0;
-        origSizePanel.add(new JLabel("" + currentMap.getWidth()), c);
+        origSizePanel.add(new JLabel(String.valueOf(currentMap.getWidth())), c);
         c.gridy = 1;
-        origSizePanel.add(new JLabel("" + currentMap.getHeight()), c);
+        origSizePanel.add(new JLabel(String.valueOf(currentMap.getHeight())), c);
 
         // Putting two size panels next to eachother
         JPanel sizePanels = new VerticalStaticJPanel(new GridBagLayout());

Modified: trunk/src/tiled/mapeditor/dialogs/TileDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/TileDialog.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/mapeditor/dialogs/TileDialog.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -418,7 +418,7 @@
 
         if (source == bOk) {
             tileset.setName(tilesetNameEntry.getText());
-            this.dispose();
+            dispose();
         } else if (source == bDelete) {
             int answer = JOptionPane.showConfirmDialog(
                     this, "Delete tile?", "Are you sure?",

Modified: trunk/src/tiled/mapeditor/dialogs/TilesetManager.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/TilesetManager.java	2006-02-12 14:51:25 UTC (rev 581)
+++ trunk/src/tiled/mapeditor/dialogs/TilesetManager.java	2006-02-17 21:33:23 UTC (rev 582)
@@ -27,6 +27,7 @@
 import tiled.io.MapWriter;
 import tiled.mapeditor.util.*;
 import tiled.mapeditor.plugin.PluginClassLoader;
+import tiled.mapeditor.Resources;
 
 
 public class TilesetManager extends JDialog implements ActionListener,
@@ -122,23 +123,23 @@
                     int ret = JOptionPane.showConfirmDialog(this,
                             "This tileset is currently in use. " +
                             "Are you sure you wish to remove it?",
-                            "Sure?", JOptionPane.YES_NO_CANCEL_OPTION);
-                    if (ret == JOptionPane.YES_OPTION) {
-                        map.removeTileset(set);
-                        updateTilesetTable();
+                            "Sure?", JOptionPane.YES_NO_OPTION);
+                    if (ret != JOptionPane.YES_OPTION) {
+                        return;
                     }
-                } else {
-                    map.removeTileset(set);
-                    updateTilesetTable();
                 }
-            } catch (ArrayIndexOutOfBoundsException a) {
-            } catch (Exception e) {
-                JOptionPane.showMessageDialog(this, e.getMessage());
+                map.removeTileset(set);
+                updateTilesetTable();
+            } catch (LayerLockedException e) {
+                JOptionPane.showMessageDialog(this,
+                        Resources.getString("action.tileset.remove.error.layer-locked.message"),
+                        Resources.getString("action.tileset.remove.error.title"),
+                        JOptionPane.ERROR_MESSAGE);
             }
         } else if (command.equals("Save as...")) {
             JFileChooser ch = new JFileChooser(map.getFilename());
 
-            MapWriter writers[] = PluginClassLoader.getInstance().getWriters();
+            MapWriter[] writers = PluginClassLoader.getInstance().getWriters();
             for (int i = 0; i < writers.length; i++) {
                 try {
                     ch.addChoosableFileFilter(new TiledFileFilter(
@@ -154,11 +155,9 @@
                 String filename = ch.getSelectedFile().getAbsolutePath();
                 File exist = new File(filename);
 
-                if ((exist.exists()
-                      && JOptionPane.show