Index: trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java	(revision 9825)
+++ trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java	(revision 9826)
@@ -671,5 +671,5 @@
 
     protected int estimateTileCacheSize() {
-        Dimension screenSize = GuiHelper.getScreenSize();
+        Dimension screenSize = GuiHelper.getMaxiumScreenSize();
         int height = screenSize.height;
         int width = screenSize.width;
Index: trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java	(revision 9825)
+++ trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java	(revision 9826)
@@ -10,5 +10,7 @@
 import java.awt.Dialog;
 import java.awt.Dimension;
+import java.awt.DisplayMode;
 import java.awt.Font;
+import java.awt.GraphicsDevice;
 import java.awt.GraphicsEnvironment;
 import java.awt.GridBagLayout;
@@ -424,4 +426,31 @@
 
     /**
+     * Gets the size of the screen. On systems with multiple displays,
+     * contrary to {@link #getScreenSize()}, the biggest display is used.
+     * This method returns always 800x600 in headless mode (useful for unit tests).
+     * @return the size of maximum screen, in pixels, or 800x600
+     * @see Toolkit#getScreenSize
+     * @since 9576
+     */
+
+    public static Dimension getMaxiumScreenSize() {
+        if (GraphicsEnvironment.isHeadless()) {
+            return new Dimension(800, 600);
+        }
+
+        int height = 0;
+        int width = 0;
+        for (GraphicsDevice gd: GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
+            DisplayMode dm = gd.getDisplayMode();
+            height = Math.max(height, dm.getHeight());
+            width = Math.max(width, dm.getWidth());
+        }
+        if (height == 0 || width == 0) {
+            return new Dimension(800, 600);
+        }
+        return new Dimension(width, height);
+    }
+
+    /**
      * Gets the singleton instance of the system selection as a <code>Clipboard</code> object.
      * This allows an application to read and modify the current, system-wide selection.
