Index: trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java	(revision 2158)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java	(revision 2159)
@@ -8,4 +8,5 @@
 import java.awt.GridLayout;
 import java.awt.Point;
+import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
@@ -18,5 +19,4 @@
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.logging.Logger;
 
 import javax.swing.AbstractAction;
@@ -28,5 +28,4 @@
 import javax.swing.JLabel;
 import javax.swing.JList;
-import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
@@ -42,6 +41,4 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.MergeLayerAction;
-import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
-import org.openstreetmap.josm.gui.ExtendedDialog;
 import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.MapView;
@@ -57,5 +54,5 @@
 /**
  * This is a toggle dialog which displays the list of layers. Actions allow to
- * change the ordering the layer, to hide/show layers, to activate layers
+ * change the ordering of the layers, to hide/show layers, to activate layers,
  * and to delete layers.
  * 
@@ -317,7 +314,7 @@
                 dialog.setVisible(true);
                 switch(dialog.getUserAction()) {
-                case CANCEL: return false;
-                case PROCEED: return true;
-                default: return false;
+                    case CANCEL: return false;
+                    case PROCEED: return true;
+                    default: return false;
                 }
             }
@@ -1031,9 +1028,11 @@
         protected void processMouseEvent(MouseEvent e) {
             // if the layer list is embedded in a detached dialog, the last row is
-            // is selected if a user clicks in the empty space *below* the last row.
+            // selected if a user clicks in the empty space *below* the last row.
             // This mouse event filter prevents this.
             //
             int idx = locationToIndex(e.getPoint());
-            if (getCellBounds(idx, idx).contains(e.getPoint())) {
+            // sometimes bounds can be null, see #3539
+            Rectangle bounds = getCellBounds(idx,idx);
+            if (bounds != null && bounds.contains(e.getPoint())) {
                 super.processMouseEvent(e);
             }
