Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java	(revision 31807)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java	(revision 31808)
@@ -5,9 +5,14 @@
 
 import java.awt.FlowLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
 import java.awt.event.ActionEvent;
 import java.io.IOException;
 import java.net.URL;
 
+import javax.json.Json;
 import javax.swing.AbstractAction;
+import javax.swing.BorderFactory;
+import javax.swing.Box;
 import javax.swing.JButton;
 import javax.swing.JCheckBox;
@@ -15,4 +20,6 @@
 import javax.swing.JLabel;
 import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.SwingUtilities;
 
 import org.openstreetmap.josm.Main;
@@ -22,7 +29,10 @@
 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
 import org.openstreetmap.josm.plugins.mapillary.io.download.MapillaryDownloader;
+import org.openstreetmap.josm.plugins.mapillary.oauth.MapillaryLoginListener;
 import org.openstreetmap.josm.plugins.mapillary.oauth.MapillaryUser;
 import org.openstreetmap.josm.plugins.mapillary.oauth.OAuthPortListener;
 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils;
+import org.openstreetmap.josm.tools.GBC;
+import org.openstreetmap.josm.tools.I18n;
 
 /**
@@ -32,5 +42,5 @@
  *
  */
-public class MapillaryPreferenceSetting implements SubPreferenceSetting {
+public class MapillaryPreferenceSetting implements SubPreferenceSetting, MapillaryLoginListener {
 
   private JCheckBox reverseButtons = new JCheckBox(
@@ -47,4 +57,9 @@
       tr("Move to picture''s location with next/previous buttons"));
   private JButton login;
+
+  private JButton loginButton = new JButton(new LoginAction(this));
+  private JButton logoutButton = new JButton(new LogoutAction());
+  private JLabel loginLabel = new JLabel();
+  private JPanel loginPanel = new JPanel();
 
   @Override
@@ -78,17 +93,50 @@
     panel.add(this.format24);
     panel.add(this.moveTo);
-    this.login = new JButton(new LoginAction());
-    if (MapillaryUser.getUsername() == null)
-      this.login.setText("Login");
-    else
-      this.login.setText("Logged as: " + MapillaryUser.getUsername()
-          + ". Click to relogin.");
-    panel.add(this.login);
-    if (MapillaryUser.getUsername() != null) {
-      JButton logout = new JButton(new LogoutAction());
-      logout.setText("Logout");
-      panel.add(logout);
-    }
+
+    loginPanel.setLayout(new FlowLayout(FlowLayout.LEADING));
+    loginPanel.add(loginButton, 0);
+    loginPanel.add(loginLabel, 1);
+    onLogout();
+    panel.add(loginPanel, GBC.eol());
+    panel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
+
     gui.getDisplayPreference().addSubTab(this, "Mapillary", panel);
+
+    new Thread(new Runnable() {
+      @Override
+      public void run() {
+        String username = MapillaryUser.getUsername();
+        if (username != null) {
+          SwingUtilities.invokeLater(new Runnable() {
+            @Override
+            public void run() {
+              onLogin(MapillaryUser.getUsername());
+            }
+          });
+        }
+      }
+    }).start();
+  }
+
+  /**
+   * Should be called whenever the user logs into a mapillary account.
+   * This updates the GUI to reflect the login status.
+   * @param username the username that the user is now logged in with
+   */
+  public void onLogin(final String username) {
+    loginPanel.add(logoutButton, 1);
+    loginLabel.setText(I18n.tr("You are logged in as ''{0}''.", username));
+    loginButton.setText(I18n.tr("Re-Login"));
+    logoutButton.setText(I18n.tr("Logout"));
+  }
+
+  /**
+   * Should be called whenever the user logs out of a mapillary account.
+   * This updates the GUI to reflect the login status.
+   */
+  public void onLogout() {
+    loginPanel.remove(logoutButton);
+    loginLabel.setText(I18n.tr("You are currently not logged in."));
+    loginButton.setText(I18n.tr("Login"));
   }
 
@@ -126,12 +174,16 @@
    */
   public class LoginAction extends AbstractAction {
-
     private static final long serialVersionUID = -3908477563072057344L;
+    final transient MapillaryLoginListener callback;
+
+    public LoginAction(MapillaryLoginListener loginCallback) {
+      this.callback = loginCallback;
+    }
 
     @Override
     public void actionPerformed(ActionEvent arg0) {
-      OAuthPortListener portListener = new OAuthPortListener();
+      OAuthPortListener portListener = new OAuthPortListener(callback);
       portListener.start();
-      String url = "http://www.mapillary.com/connect?redirect_uri=http:%2F%2Flocalhost:8763%2F&client_id="+MapillaryPlugin.CLIENT_ID+"&response_type=token&scope=user:read%20public:upload%20public:write";
+      String url = "http://www.mapillary.com/connect?redirect_uri=http:%2F%2Flocalhost:"+OAuthPortListener.PORT+"%2F&client_id="+MapillaryPlugin.CLIENT_ID+"&response_type=token&scope=user:read%20public:upload%20public:write";
       try {
         MapillaryUtils.browse(new URL(url));
@@ -156,5 +208,5 @@
       MapillaryUser.reset();
       Main.pref.put("mapillary.access-token", null);
-      MapillaryPreferenceSetting.this.login.setText("Login");
+      onLogout();
     }
   }
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/MapillaryLoginListener.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/MapillaryLoginListener.java	(revision 31808)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/MapillaryLoginListener.java	(revision 31808)
@@ -0,0 +1,6 @@
+package org.openstreetmap.josm.plugins.mapillary.oauth;
+
+public interface MapillaryLoginListener {
+  public void onLogin(final String username);
+  public void onLogout();
+}
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthPortListener.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthPortListener.java	(revision 31807)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthPortListener.java	(revision 31808)
@@ -29,5 +29,9 @@
       I18n.tr("Login successful, return to JOSM.")
   );
+  private MapillaryLoginListener callback;
 
+  public OAuthPortListener(MapillaryLoginListener loginCallback) {
+    this.callback = loginCallback;
+  }
 
   @Override
@@ -70,5 +74,9 @@
       if (Main.main != null) {
         Main.pref.put("mapillary.access-token", accessToken);
-        Main.info("The username is: " + MapillaryUser.getUsername());
+        String username = MapillaryUser.getUsername();
+        Main.info("The username is: " + username);
+        if (callback != null) {
+          callback.onLogin(username);
+        }
       }
     } catch (BindException e) {
Index: applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthPortListenerTest.java
===================================================================
--- applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthPortListenerTest.java	(revision 31807)
+++ applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthPortListenerTest.java	(revision 31808)
@@ -25,5 +25,5 @@
   @Test
   public void responseTest() {
-    OAuthPortListener t = new OAuthPortListener();
+    OAuthPortListener t = new OAuthPortListener(null);
     t.start();
     try {
