Index: trunk/src/org/openstreetmap/josm/Main.java
===================================================================
--- trunk/src/org/openstreetmap/josm/Main.java	(revision 12124)
+++ trunk/src/org/openstreetmap/josm/Main.java	(revision 12125)
@@ -65,5 +65,4 @@
 import org.openstreetmap.josm.data.projection.ProjectionChangeListener;
 import org.openstreetmap.josm.data.validation.OsmValidator;
-import org.openstreetmap.josm.gui.MainFrame;
 import org.openstreetmap.josm.gui.MainMenu;
 import org.openstreetmap.josm.gui.MainPanel;
@@ -198,4 +197,10 @@
 
     /**
+     * The main panel.
+     * @since 12125
+     */
+    public MainPanel panel;
+
+    /**
      * The file watcher service.
      */
@@ -213,10 +218,4 @@
     @Deprecated
     public static int logLevel = 3;
-
-    /**
-     * The real main panel. This field may be removed any time and made private to {@link MainFrame}
-     * @see #panel
-     */
-    protected static final MainPanel mainPanel = new MainPanel(getLayerManager());
 
     /**
@@ -491,5 +490,4 @@
     protected Main() {
         setInstance(this);
-        mainPanel.addMapFrameListener((o, n) -> redoUndoListener.commandChanged(0, 0));
     }
 
@@ -579,5 +577,5 @@
     /**
      * Called once at startup to initialize the main window content.
-     * Should set {@link #menu}
+     * Should set {@link #menu} and {@link #panel}
      */
     protected abstract void initializeMainWindow();
@@ -716,9 +714,7 @@
 
     /**
-     * Global panel.
-     */
-    public static final JPanel panel = mainPanel;
-
-    private final CommandQueueListener redoUndoListener = (queueSize, redoSize) -> {
+     * Listener that sets the enabled state of undo/redo menu entries.
+     */
+    protected final CommandQueueListener redoUndoListener = (queueSize, redoSize) -> {
             menu.undo.setEnabled(queueSize > 0);
             menu.redo.setEnabled(redoSize > 0);
@@ -770,5 +766,4 @@
         toolbar = new ToolbarPreferences();
         contentPanePrivate.updateUI();
-        panel.updateUI();
 
         UIManager.put("OptionPane.okIcon", ImageProvider.get("ok"));
@@ -1158,5 +1153,5 @@
      */
     public static boolean addAndFireMapFrameListener(MapFrameListener listener) {
-        return mainPanel.addAndFireMapFrameListener(listener);
+        return main.panel.addAndFireMapFrameListener(listener);
     }
 
@@ -1169,5 +1164,5 @@
      */
     public static boolean addMapFrameListener(MapFrameListener listener) {
-        return mainPanel.addMapFrameListener(listener);
+        return main.panel.addMapFrameListener(listener);
     }
 
@@ -1179,5 +1174,5 @@
      */
     public static boolean removeMapFrameListener(MapFrameListener listener) {
-        return mainPanel.removeMapFrameListener(listener);
+        return main.panel.removeMapFrameListener(listener);
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java	(revision 12124)
+++ trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java	(revision 12125)
@@ -198,5 +198,5 @@
         JMenu subMenu = Main.main.menu.imagerySubMenu;
         int heightUnrolled = 30*(getItemCount()+subMenu.getItemCount());
-        if (heightUnrolled < Main.panel.getHeight()) {
+        if (heightUnrolled < Main.main.panel.getHeight()) {
             // add all items of submenu if they will fit on screen
             int n = subMenu.getItemCount();
Index: trunk/src/org/openstreetmap/josm/gui/MainApplication.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 12124)
+++ trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 12125)
@@ -88,5 +88,5 @@
     private static final List<String> COMMAND_LINE_ARGS = new ArrayList<>();
 
-    private MainFrame mainFrame;
+    private final MainFrame mainFrame;
 
     /**
@@ -109,13 +109,16 @@
     @Override
     protected void initializeMainWindow() {
-        mainPanel.reAddListeners();
         if (mainFrame != null) {
+            mainFrame.preInitialize();
+            panel = mainFrame.getPanel();
             mainFrame.initialize();
-
             menu = mainFrame.getMenu();
         } else {
             // required for running some tests.
+            panel = new MainPanel(Main.getLayerManager());
             menu = new MainMenu();
         }
+        panel.addMapFrameListener((o, n) -> redoUndoListener.commandChanged(0, 0));
+        panel.reAddListeners();
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/MainFrame.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MainFrame.java	(revision 12124)
+++ trunk/src/org/openstreetmap/josm/gui/MainFrame.java	(revision 12125)
@@ -49,4 +49,5 @@
     protected transient WindowGeometry geometry;
     protected int windowState = JFrame.NORMAL;
+    private MainPanel panel;
     private MainMenu menu;
 
@@ -71,5 +72,14 @@
 
     /**
+     * Performs pre-initialization required before the call to {@link #initialize()}.
+     * @since 12125
+     */
+    public void preInitialize() {
+        panel = new MainPanel(Main.getLayerManager());
+    }
+
+    /**
      * Initializes the content of the window and get the current status panel.
+     * {@link #preInitialize()} must have been previously called.
      */
     public void initialize() {
@@ -98,5 +108,5 @@
         refreshTitle();
 
-        getContentPane().add(Main.panel, BorderLayout.CENTER);
+        getContentPane().add(panel, BorderLayout.CENTER);
         menu.initialize();
     }
@@ -115,4 +125,6 @@
      * Gets the main menu used for this window.
      * @return The main menu.
+     * @throws IllegalStateException if the main frame has not been initialized yet
+     * @see #initialize
      */
     public MainMenu getMenu() {
@@ -121,4 +133,18 @@
         }
         return menu;
+    }
+
+    /**
+     * Gets the main panel.
+     * @return The main panel.
+     * @throws IllegalStateException if the main frame has not been initialized yet
+     * @see #initialize
+     * @since 12125
+     */
+    public MainPanel getPanel() {
+        if (panel == null) {
+            throw new IllegalStateException("Not initialized.");
+        }
+        return panel;
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandler.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandler.java	(revision 12124)
+++ trunk/src/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandler.java	(revision 12125)
@@ -71,5 +71,5 @@
      */
     public void pasteOn(OsmDataLayer editLayer, EastNorth mPosition, Transferable transferable) {
-        importData(new TransferSupport(Main.panel, transferable), editLayer, mPosition);
+        importData(new TransferSupport(Main.main.panel, transferable), editLayer, mPosition);
     }
 
@@ -80,5 +80,5 @@
     public void pasteTags(Collection<? extends OsmPrimitive> primitives) {
         Transferable transferable = ClipboardUtils.getClipboardContent();
-        importTags(new TransferSupport(Main.panel, transferable), primitives);
+        importTags(new TransferSupport(Main.main.panel, transferable), primitives);
     }
 
