Index: trunk/src/org/openstreetmap/josm/gui/io/CredentialDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/CredentialDialog.java	(revision 4109)
+++ trunk/src/org/openstreetmap/josm/gui/io/CredentialDialog.java	(revision 4110)
@@ -15,4 +15,5 @@
 import java.awt.event.FocusEvent;
 import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
@@ -104,5 +105,5 @@
     public void prepareForOsmApiCredentials(String username, String password) {
         setTitle(tr("Enter credentials for OSM API"));
-        getContentPane().add(pnlCredentials = new OsmApiCredentialsPanel(), BorderLayout.CENTER);
+        getContentPane().add(pnlCredentials = new OsmApiCredentialsPanel(this), BorderLayout.CENTER);
         pnlCredentials.init(username, password);
         validate();
@@ -111,5 +112,5 @@
     public void prepareForProxyCredentials(String username, String password) {
         setTitle(tr("Enter credentials for HTTP proxy"));
-        getContentPane().add(pnlCredentials = new HttpProxyCredentialsPanel(), BorderLayout.CENTER);
+        getContentPane().add(pnlCredentials = new HttpProxyCredentialsPanel(this), BorderLayout.CENTER);
         pnlCredentials.init(username, password);
         validate();
@@ -137,4 +138,5 @@
         protected JMultilineLabel lblHeading;
         protected JMultilineLabel lblWarning;
+        protected CredentialDialog owner; // owner Dependency Injection to use Key listeners for username and password text fields
 
         protected void build() {
@@ -143,4 +145,6 @@
             tfUserName.addFocusListener(new SelectAllOnFocusHandler());
             tfPassword.addFocusListener(new SelectAllOnFocusHandler());
+            tfUserName.addKeyListener(new TFKeyListener(owner, tfUserName, tfPassword));
+            tfPassword.addKeyListener(new TFKeyListener(owner, tfPassword, tfUserName));
             cbSaveCredentials =  new JCheckBox(tr("Save user and password (unencrypted)"));
 
@@ -202,5 +206,6 @@
         }
 
-        public CredentialPanel() {
+        public CredentialPanel(CredentialDialog owner) {
+            this.owner = owner;
         }
 
@@ -243,5 +248,6 @@
         }
 
-        public OsmApiCredentialsPanel() {
+        public OsmApiCredentialsPanel(CredentialDialog owner) {
+            super(owner);
             build();
         }
@@ -260,5 +266,6 @@
         }
 
-        public HttpProxyCredentialsPanel() {
+        public HttpProxyCredentialsPanel(CredentialDialog owner) {
+            super(owner);
             build();
         }
@@ -275,4 +282,46 @@
     }
 
+    /**
+     * Listener for username and password text fields key events.
+     * When user presses Enter:
+     *   If current text field is empty (or just contains a sequence of spaces), nothing happens (or all spaces become selected).
+     *   If current text field is not empty, but the next one is (or just contains a sequence of spaces), focuses the next text field.
+     *   If both text fields contain characters, submits the form by calling owner's {@link OKAction}.
+     */
+    static private class TFKeyListener implements KeyListener{
+        protected CredentialDialog owner; // owner Dependency Injection to call OKAction
+        protected JTextField currentTF;
+        protected JTextField nextTF;
+
+        public TFKeyListener (CredentialDialog owner, JTextField currentTF, JTextField nextTF)
+        {
+            this.owner = owner;
+            this.currentTF = currentTF;
+            this.nextTF = nextTF;
+        }
+
+        public void keyPressed(KeyEvent e) {
+            if(e.getKeyChar() == KeyEvent.VK_ENTER) {
+                if (currentTF.getText().trim().isEmpty()) {
+                    currentTF.selectAll();
+                    return;
+                } else if (nextTF.getText().trim().isEmpty()) {
+                    nextTF.requestFocusInWindow();
+                    nextTF.selectAll();
+                    return;
+                } else {
+                    OKAction okAction = owner.new OKAction();
+                    okAction.actionPerformed(null);
+                }
+            }
+        }
+
+        public void keyReleased ( KeyEvent e ){
+        }
+
+        public void keyTyped ( KeyEvent e ){
+        }
+    }
+
     class OKAction extends AbstractAction {
         public OKAction() {
