]> source.dussan.org Git - tigervnc.git/commitdiff
comboBoxEdited events are fired if the content of the JComboBox is edited and then...
authorBrian Hinz <bphinz@users.sourceforge.net>
Fri, 22 Feb 2013 19:47:13 +0000 (19:47 +0000)
committerBrian Hinz <bphinz@users.sourceforge.net>
Fri, 22 Feb 2013 19:47:13 +0000 (19:47 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@5050 3789f03b-4d11-0410-bbf8-ca57d06f2519

java/com/tigervnc/vncviewer/ServerDialog.java

index a13458501886508885f9b665a1a8e957a92d5d9a..a1a05602dcdae51e56045567185ae9309b46857b 100644 (file)
@@ -29,8 +29,7 @@ import java.util.*;
 import com.tigervnc.rfb.*;
 
 class ServerDialog extends Dialog implements
-                           ActionListener,
-                           ItemListener
+                           ActionListener
 {
 
   @SuppressWarnings({"unchecked","rawtypes"})
@@ -77,6 +76,17 @@ class ServerDialog extends Dialog implements
 
     server.setEditable(true);
     editor = server.getEditor();
+    editor.getEditorComponent().addKeyListener(new KeyListener() {
+      public void keyTyped(KeyEvent e) {}
+      public void keyReleased(KeyEvent e) {}
+      public void keyPressed(KeyEvent e) {
+        if (e.getKeyCode() == KeyEvent.VK_ENTER) {
+          server.insertItemAt(editor.getItem(), 0);
+          server.setSelectedIndex(0);
+          commit();
+        }
+      }
+    });
 
     JPanel topPanel = new JPanel(new GridBagLayout());
 
@@ -117,16 +127,11 @@ class ServerDialog extends Dialog implements
     pack();
   }
 
-  public void itemStateChanged(ItemEvent e) {
-    return;
-  }
-
   @SuppressWarnings({"unchecked","rawtypes"})
   public void actionPerformed(ActionEvent e) {
     Object s = e.getSource();
     if (s instanceof JButton && (JButton)s == okButton) {
       commit();
-      endDialog();
     } else if (s instanceof JButton && (JButton)s == cancelButton) {
       if (VncViewer.nViewers == 1)
         cc.viewer.exit(1);
@@ -140,8 +145,6 @@ class ServerDialog extends Dialog implements
       if (e.getActionCommand().equals("comboBoxEdited")) {
         server.insertItemAt(editor.getItem(), 0);
         server.setSelectedIndex(0);
-        commit();
-        endDialog();
       }
     }
   }
@@ -172,12 +175,9 @@ class ServerDialog extends Dialog implements
     }
     UserPreferences.set("ServerDialog", "history", sb.toString());
     UserPreferences.save("ServerDialog");
+    endDialog();
   }
   
-  public void endDialog() {
-    super.endDialog();
-  }
-
   CConn cc;
   @SuppressWarnings("rawtypes")
   JComboBox server;