Index: src/org/openstreetmap/josm/actions/OpenLocationAction.java
===================================================================
--- src/org/openstreetmap/josm/actions/OpenLocationAction.java	(revision 6094)
+++ src/org/openstreetmap/josm/actions/OpenLocationAction.java	(working copy)
@@ -132,8 +132,7 @@
      */
     public Collection<DownloadTask> findDownloadTasks(final String url) {
         List<DownloadTask> result = new ArrayList<DownloadTask>();
-        for (int i = 0; i < downloadTasks.size(); i++) {
-            Class<? extends DownloadTask> taskClass = downloadTasks.get(i);
+        for (Class<? extends DownloadTask> taskClass : downloadTasks) {
             if (taskClass != null) {
                 try {
                     DownloadTask task = taskClass.getConstructor().newInstance();
Index: src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
===================================================================
--- src/org/openstreetmap/josm/actions/mapmode/DrawAction.java	(revision 6094)
+++ src/org/openstreetmap/josm/actions/mapmode/DrawAction.java	(working copy)
@@ -1669,11 +1669,11 @@
 
         private double getNearestAngle(double angle) {
             double delta,minDelta=1e5, bestAngle=0.0;
-            for (int i=0; i < snapAngles.length; i++) {
-                delta = getAngleDelta(angle,snapAngles[i]);
+            for (double snapAngle : snapAngles) {
+                delta = getAngleDelta(angle, snapAngle);
                 if (delta < minDelta) {
-                    minDelta=delta;
-                    bestAngle=snapAngles[i];
+                    minDelta = delta;
+                    bestAngle = snapAngle;
                 }
             }
             if (Math.abs(bestAngle-360) < 1e-3) {
Index: src/org/openstreetmap/josm/data/AutosaveTask.java
===================================================================
--- src/org/openstreetmap/josm/data/AutosaveTask.java	(revision 6094)
+++ src/org/openstreetmap/josm/data/AutosaveTask.java	(working copy)
@@ -113,9 +113,9 @@
 
     private String getFileName(String layerName, int index) {
         String result = layerName;
-        for (int i=0; i<ILLEGAL_CHARACTERS.length; i++) {
-            result = result.replaceAll(Pattern.quote(String.valueOf(ILLEGAL_CHARACTERS[i])),
-                    '&' + String.valueOf((int)ILLEGAL_CHARACTERS[i]) + ';');
+        for (char illegalCharacter : ILLEGAL_CHARACTERS) {
+            result = result.replaceAll(Pattern.quote(String.valueOf(illegalCharacter)),
+                    '&' + String.valueOf((int) illegalCharacter) + ';');
         }
         if (index != 0) {
             result = result + '_' + index;
Index: src/org/openstreetmap/josm/data/osm/Way.java
===================================================================
--- src/org/openstreetmap/josm/data/osm/Way.java	(revision 6094)
+++ src/org/openstreetmap/josm/data/osm/Way.java	(working copy)
@@ -150,8 +150,8 @@
         if (node == null) return false;
 
         Node[] nodes = this.nodes;
-        for (int i=0; i<nodes.length; i++) {
-            if (nodes[i].equals(node))
+        for (Node n : nodes) {
+            if (n.equals(node))
                 return true;
         }
         return false;
Index: src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java
===================================================================
--- src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java	(revision 6094)
+++ src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java	(working copy)
@@ -297,8 +297,8 @@
                     nodes.addAll(w.getNodes());
                 } else {
                     List<Way> waysToJoin = new ArrayList<Way>();
-                    for (Iterator<Long> it = wayIds.iterator(); it.hasNext(); ) {
-                        Way w = (Way) ds.getPrimitiveById(it.next(), OsmPrimitiveType.WAY);
+                    for (Long wayId : wayIds) {
+                        Way w = (Way) ds.getPrimitiveById(wayId, OsmPrimitiveType.WAY);
                         if (w != null && w.getNodesCount() > 0) { // fix #7173 (empty ways on purge)
                             waysToJoin.add(w);
                         }
Index: src/org/openstreetmap/josm/data/projection/CustomProjection.java
===================================================================
--- src/org/openstreetmap/josm/data/projection/CustomProjection.java	(revision 6094)
+++ src/org/openstreetmap/josm/data/projection/CustomProjection.java	(working copy)
@@ -159,8 +159,7 @@
         if (pref.trim().isEmpty()) {
             parts = new String[0];
         }
-        for (int i = 0; i < parts.length; i++) {
-            String part = parts[i];
+        for (String part : parts) {
             if (part.isEmpty() || part.charAt(0) != '+')
                 throw new ProjectionConfigurationException(tr("Parameter must begin with a ''+'' character (found ''{0}'')", part));
             Matcher m = Pattern.compile("\\+([a-zA-Z0-9_]+)(=(.*))?").matcher(part);
@@ -287,16 +286,16 @@
         if (numStr.length != 3 && numStr.length != 7)
             throw new ProjectionConfigurationException(tr("Unexpected number of arguments for parameter ''towgs84'' (must be 3 or 7)"));
         List<Double> towgs84Param = new ArrayList<Double>();
-        for (int i = 0; i < numStr.length; i++) {
+        for (String str : numStr) {
             try {
-                towgs84Param.add(Double.parseDouble(numStr[i]));
+                towgs84Param.add(Double.parseDouble(str));
             } catch (NumberFormatException e) {
-                throw new ProjectionConfigurationException(tr("Unable to parse value of parameter ''towgs84'' (''{0}'')", numStr[i]));
+                throw new ProjectionConfigurationException(tr("Unable to parse value of parameter ''towgs84'' (''{0}'')", str));
             }
         }
         boolean isCentric = true;
-        for (int i = 0; i<towgs84Param.size(); i++) {
-            if (towgs84Param.get(i) != 0.0) {
+        for (Double param : towgs84Param) {
+            if (param != 0.0) {
                 isCentric = false;
                 break;
             }
Index: src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java
===================================================================
--- src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java	(revision 6094)
+++ src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java	(working copy)
@@ -162,9 +162,9 @@
             if (subGrid == null)
                 return this;
             else {
-                for (int i = 0; i < subGrid.length; i++) {
-                    if (subGrid[i].isCoordWithin(lon, lat))
-                        return subGrid[i].getSubGridForCoord(lon, lat);
+                for (NTV2SubGrid aSubGrid : subGrid) {
+                    if (aSubGrid.isCoordWithin(lon, lat))
+                        return aSubGrid.getSubGridForCoord(lon, lat);
                 }
                 return this;
             }
Index: src/org/openstreetmap/josm/data/validation/tests/DuplicateRelation.java
===================================================================
--- src/org/openstreetmap/josm/data/validation/tests/DuplicateRelation.java	(revision 6094)
+++ src/org/openstreetmap/josm/data/validation/tests/DuplicateRelation.java	(working copy)
@@ -84,8 +84,8 @@
                 tags = r.getKeys();
                 List<Node> wNodes = r.getNodes();
                 coor = new ArrayList<LatLon>(wNodes.size());
-                for (int i = 0; i < wNodes.size(); i++) {
-                    coor.add(wNodes.get(i).getCoor());
+                for (Node wNode : wNodes) {
+                    coor.add(wNode.getCoor());
                 }
             }
             if (src.isRelation()) {
@@ -109,8 +109,8 @@
          */
         public RelationMembers(List<RelationMember> members) {
             this.members = new ArrayList<RelMember>(members.size());
-            for (int i = 0; i < members.size(); i++) {
-                this.members.add(new RelMember(members.get(i)));
+            for (RelationMember member : members) {
+                this.members.add(new RelMember(member));
             }
         }
 
Index: src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java
===================================================================
--- src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java	(revision 6094)
+++ src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java	(working copy)
@@ -192,8 +192,8 @@
         }
         // Build the list of lat/lon
         List<LatLon> wLat = new ArrayList<LatLon>(wNodesToUse.size());
-        for (int i=0; i<wNodesToUse.size(); i++) {
-            wLat.add(wNodesToUse.get(i).getCoor());
+        for (Node node : wNodesToUse) {
+            wLat.add(node.getCoor());
         }
         // If this way has not direction-dependant keys, make sure the list is ordered the same for all ways (fix #8015)
         if (!w.hasDirectionKeys()) {
Index: src/org/openstreetmap/josm/data/validation/util/Entities.java
===================================================================
--- src/org/openstreetmap/josm/data/validation/util/Entities.java	(revision 6094)
+++ src/org/openstreetmap/josm/data/validation/util/Entities.java	(working copy)
@@ -387,8 +387,8 @@
                         if(mapNameToValue == null)
                         {
                             mapNameToValue = new HashMap<String, String>();
-                            for (int in = 0; in < ARRAY.length; ++in)
-                                mapNameToValue.put(ARRAY[in][0], ARRAY[in][1]);
+                            for (String[] pair : ARRAY)
+                                mapNameToValue.put(pair[0], pair[1]);
                         }
                         String value = mapNameToValue.get(entityContent);
                         entityValue = (value == null ? -1 : Integer.parseInt(value));
Index: src/org/openstreetmap/josm/gui/FileDrop.java
===================================================================
--- src/org/openstreetmap/josm/gui/FileDrop.java	(revision 6094)
+++ src/org/openstreetmap/josm/gui/FileDrop.java	(working copy)
@@ -2,7 +2,9 @@
   (public domain) with only very small additions */
 package org.openstreetmap.josm.gui;
 
+import java.awt.*;
 import java.awt.datatransfer.DataFlavor;
+import java.awt.dnd.DnDConstants;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
@@ -342,18 +344,18 @@
                     // BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added.
                     DataFlavor[] flavors = tr.getTransferDataFlavors();
                     boolean handled = false;
-                    for (int zz = 0; zz < flavors.length; zz++) {
-                        if (flavors[zz].isRepresentationClassReader()) {
+                    for (DataFlavor flavor : flavors) {
+                        if (flavor.isRepresentationClassReader()) {
                             // Say we'll take it.
                             //evt.acceptDrop ( java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE );
-                            evt.acceptDrop(java.awt.dnd.DnDConstants.ACTION_COPY);
+                            evt.acceptDrop(DnDConstants.ACTION_COPY);
                             log(out, "FileDrop: reader accepted.");
 
-                            Reader reader = flavors[zz].getReaderForText(tr);
+                            Reader reader = flavor.getReaderForText(tr);
 
                             BufferedReader br = new BufferedReader(reader);
 
-                            if(listener != null) {
+                            if (listener != null) {
                                 listener.filesDropped(createFileArray(br, out));
                             }
 
@@ -513,8 +515,8 @@
             java.awt.Component[] comps = cont.getComponents();
 
             // Set it's components as listeners also
-            for( int i = 0; i < comps.length; i++ ) {
-                makeDropTarget( out, comps[i], recursive );
+            for (Component comp : comps) {
+                makeDropTarget(out, comp, recursive);
             }
         }   // end if: recursively set components as listener
     }   // end dropListener
@@ -593,9 +595,9 @@
         c.setDropTarget( null );
         if( recursive && ( c instanceof java.awt.Container ) )
         {   java.awt.Component[] comps = ((java.awt.Container)c).getComponents();
-        for( int i = 0; i < comps.length; i++ ) {
-            remove( out, comps[i], recursive );
-        }
+            for (Component comp : comps) {
+                remove(out, comp, recursive);
+            }
         return true;
         }   // end if: recursive
         else return false;
Index: src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
===================================================================
--- src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(revision 6094)
+++ src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(working copy)
@@ -390,9 +390,9 @@
      */
     protected void setContentVisible(boolean visible) {
         Component[] comps = getComponents();
-        for(int i=0; i<comps.length; i++) {
-            if (comps[i] != titleBar && (!visible || comps[i] != buttonsPanel || buttonHiding != ButtonHiddingType.ALWAYS_HIDDEN)) {
-                comps[i].setVisible(visible);
+        for (Component comp : comps) {
+            if (comp != titleBar && (!visible || comp != buttonsPanel || buttonHiding != ButtonHiddingType.ALWAYS_HIDDEN)) {
+                comp.setVisible(visible);
             }
         }
     }
Index: src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java
===================================================================
--- src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java	(revision 6094)
+++ src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java	(working copy)
@@ -48,9 +48,9 @@
 
     protected void registerBoundingBoxBuilder() {
         BoundingBoxBuilder bboxbuilder = new BoundingBoxBuilder();
-        for (int i = 0;i < latlon.length; i++) {
-            latlon[i].addFocusListener(bboxbuilder);
-            latlon[i].addActionListener(bboxbuilder);
+        for (JosmTextField ll : latlon) {
+            ll.addFocusListener(bboxbuilder);
+            ll.addActionListener(bboxbuilder);
         }
     }
 
Index: src/org/openstreetmap/josm/gui/io/ActionFlagsTableCell.java
===================================================================
--- src/org/openstreetmap/josm/gui/io/ActionFlagsTableCell.java	(revision 6094)
+++ src/org/openstreetmap/josm/gui/io/ActionFlagsTableCell.java	(working copy)
@@ -54,8 +54,7 @@
         setLayout(new GridBagLayout());
 
         ActionMap am = getActionMap();
-        for(int i=0; i<checkBoxes.length; i++) {
-            final JCheckBox b = checkBoxes[i];
+        for (final JCheckBox b : checkBoxes) {
             add(b, GBC.eol().fill(GBC.HORIZONTAL));
             b.setPreferredSize(new Dimension(b.getPreferredSize().width, 19));
             b.addActionListener(al);
Index: src/org/openstreetmap/josm/gui/layer/WMSLayer.java
===================================================================
--- src/org/openstreetmap/josm/gui/layer/WMSLayer.java	(revision 6094)
+++ src/org/openstreetmap/josm/gui/layer/WMSLayer.java	(working copy)
@@ -273,10 +273,9 @@
         GeorefImage[][] old = images;
         images = new GeorefImage[dax][day];
         if (old != null) {
-            for (int i=0; i<old.length; i++) {
-                for (int k=0; k<old[i].length; k++) {
-                    GeorefImage o = old[i][k];
-                    images[modulo(o.getXIndex(),dax)][modulo(o.getYIndex(),day)] = old[i][k];
+            for (GeorefImage[] row : old) {
+                for (GeorefImage image : row) {
+                    images[modulo(image.getXIndex(), dax)][modulo(image.getYIndex(), day)] = image;
                 }
             }
         }
Index: src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java
===================================================================
--- src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java	(revision 6094)
+++ src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java	(working copy)
@@ -90,13 +90,13 @@
                 });
             }
             String names = null;
-            for (int i = 0; i < sel.length; i++) {
+            for (File file : sel) {
                 if (names == null) {
                     names = " (";
                 } else {
                     names += ", ";
                 }
-                names += sel[i].getName();
+                names += file.getName();
             }
             if (names != null) {
                 names += ")";
@@ -106,8 +106,8 @@
             MarkerLayer ml = new MarkerLayer(new GpxData(), tr("Audio markers from {0}", layer.getName()) + names, layer.getAssociatedFile(), layer);
             double firstStartTime = sel[0].lastModified() / 1000.0 - AudioUtil.getCalibratedDuration(sel[0]);
             Markers m = new Markers();
-            for (int i = 0; i < sel.length; i++) {
-                importAudio(sel[i], ml, firstStartTime, m);
+            for (File file : sel) {
+                importAudio(file, ml, firstStartTime, m);
             }
             Main.main.addLayer(ml);
             Main.map.repaint();
Index: src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
===================================================================
--- src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java	(revision 6094)
+++ src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java	(working copy)
@@ -134,8 +134,7 @@
             virtualNode.put(tag.getKey(), tag.getValue());
             StyleList styleList = getStyles().generateStyles(virtualNode, 0.5, null, false).a;
             if (styleList != null) {
-                for (Iterator<ElemStyle> it = styleList.iterator(); it.hasNext(); ) {
-                    ElemStyle style = it.next();
+                for (ElemStyle style : styleList) {
                     if (style instanceof NodeElemStyle) {
                         MapImage mapImage = ((NodeElemStyle) style).mapImage;
                         if (mapImage != null) {
Index: src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java
===================================================================
--- src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java	(revision 6094)
+++ src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java	(working copy)
@@ -513,8 +513,9 @@
 
                 Set<String> acceptedEulas = new HashSet<String>();
 
-                outer: for (int i = 0; i < lines.length; i++) {
-                    ImageryInfo info = defaultModel.getRow(lines[i]);
+                outer:
+                for (int line : lines) {
+                    ImageryInfo info = defaultModel.getRow(line);
 
                     // Check if an entry with exactly the same values already
                     // exists
Index: src/org/openstreetmap/josm/io/OsmServerChangesetReader.java
===================================================================
--- src/org/openstreetmap/josm/io/OsmServerChangesetReader.java	(revision 6094)
+++ src/org/openstreetmap/josm/io/OsmServerChangesetReader.java	(working copy)
@@ -131,8 +131,7 @@
             monitor.setTicksCount(ids.size());
             List<Changeset> ret = new ArrayList<Changeset>();
             int i=0;
-            for (Iterator<Integer> it = ids.iterator(); it.hasNext(); ) {
-                int id = it.next();
+            for (int id : ids) {
                 if (id <= 0) {
                     continue;
                 }
@@ -142,7 +141,7 @@
                 InputStream in = getInputStream(sb.toString(), monitor.createSubTaskMonitor(1, true));
                 if (in == null)
                     return null;
-                monitor.indeterminateSubTask(tr("({0}/{1}) Downloading changeset {2} ...", i,ids.size(), id));
+                monitor.indeterminateSubTask(tr("({0}/{1}) Downloading changeset {2} ...", i, ids.size(), id));
                 List<Changeset> changesets = OsmChangesetParser.parse(in, monitor.createSubTaskMonitor(1, true));
                 if (changesets == null || changesets.isEmpty()) {
                     continue;
Index: src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java
===================================================================
--- src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java	(revision 6094)
+++ src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java	(working copy)
@@ -337,8 +337,8 @@
         if (trustedSenders.contains(sender)) {
             if (Main.main.getCurrentDataSet() != null) {
                 Collection<OsmPrimitive> s = Main.main.getCurrentDataSet().getSelected();
-                for (int j = 0; j < keyValue.length; j++) {
-                    Main.main.undoRedo.add(new ChangePropertyCommand(s, keyValue[j][0], keyValue[j][1]));
+                for (String[] row : keyValue) {
+                    Main.main.undoRedo.add(new ChangePropertyCommand(s, row[0], row[1]));
                 }
             }
         } else {
Index: src/org/openstreetmap/josm/tools/FallbackDateParser.java
===================================================================
--- src/org/openstreetmap/josm/tools/FallbackDateParser.java	(revision 6094)
+++ src/org/openstreetmap/josm/tools/FallbackDateParser.java	(working copy)
@@ -42,8 +42,8 @@
     public FallbackDateParser() {
         // Build a list of candidate date parsers.
         dateParsers = new ArrayList<DateFormat>(formats.length);
-        for (int i = 0; i < formats.length; i++) {
-            dateParsers.add(new SimpleDateFormat(formats[i]));
+        for (String format : formats) {
+            dateParsers.add(new SimpleDateFormat(format));
         }
 
         // We haven't selected a date parser yet.
Index: src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- src/org/openstreetmap/josm/tools/Utils.java	(revision 6094)
+++ src/org/openstreetmap/josm/tools/Utils.java	(working copy)
@@ -280,13 +280,12 @@
     public static boolean deleteDirectory(File path) {
         if( path.exists() ) {
             File[] files = path.listFiles();
-            for(int i=0; i<files.length; i++) {
-                if(files[i].isDirectory()) {
-                    deleteDirectory(files[i]);
+            for (File file : files) {
+                if (file.isDirectory()) {
+                    deleteDirectory(file);
+                } else {
+                    file.delete();
                 }
-                else {
-                    files[i].delete();
-                }
             }
         }
         return( path.delete() );
Index: src/org/openstreetmap/josm/tools/WindowGeometry.java
===================================================================
--- src/org/openstreetmap/josm/tools/WindowGeometry.java	(revision 6094)
+++ src/org/openstreetmap/josm/tools/WindowGeometry.java	(working copy)
@@ -295,8 +295,7 @@
         GraphicsEnvironment ge = GraphicsEnvironment
                 .getLocalGraphicsEnvironment();
         GraphicsDevice[] gs = ge.getScreenDevices();
-        for (int j = 0; j < gs.length; j++) {
-            GraphicsDevice gd = gs[j];
+        for (GraphicsDevice gd : gs) {
             if (gd.getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
                 virtualBounds = virtualBounds.union(gd.getDefaultConfiguration().getBounds());
             }
@@ -345,33 +344,29 @@
         GraphicsDevice[] gs = ge.getScreenDevices();
         int intersect = 0;
         Rectangle bounds = null;
-        for (int j = 0; j < gs.length; j++) {
-            GraphicsDevice gd = gs[j];
+        for (GraphicsDevice gd : gs) {
             if (gd.getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
                 Rectangle b = gd.getDefaultConfiguration().getBounds();
-                if (b.height > 0 && b.width/b.height >= 3) /* multiscreen with wrong definition */
-                {
+                if (b.height > 0 && b.width / b.height >= 3) /* multiscreen with wrong definition */ {
                     b.width /= 2;
                     Rectangle is = b.intersection(g);
-                    int s = is.width*is.height;
-                    if(bounds == null || intersect < s) {
+                    int s = is.width * is.height;
+                    if (bounds == null || intersect < s) {
                         intersect = s;
                         bounds = b;
                     }
                     b = new Rectangle(b);
                     b.x += b.width;
                     is = b.intersection(g);
-                    s = is.width*is.height;
-                    if(bounds == null || intersect < s) {
+                    s = is.width * is.height;
+                    if (bounds == null || intersect < s) {
                         intersect = s;
                         bounds = b;
                     }
-                }
-                else
-                {
+                } else {
                     Rectangle is = b.intersection(g);
-                    int s = is.width*is.height;
-                    if(bounds == null || intersect < s) {
+                    int s = is.width * is.height;
+                    if (bounds == null || intersect < s) {
                         intersect = s;
                         bounds = b;
                     }
