void () { Container ancestor = SwingUtilities.getAncestorOfClass(JComboBox.class, this); if (ancestor == null || !ancestor.isVisible()) return; JComboBox comboBox = (JComboBox)ancestor; if (!comboBox.isPopupVisible()) return; ComboPopup popup = getComboboxPopup(comboBox); if (popup == null) return; String s = myField.getText(); ListModel listmodel = comboBox.getModel(); int i = listmodel.getSize(); if (s.length() > 0) { for (int j = 0; j < i; j++) { Object obj = listmodel.getElementAt(j); if (obj == null) continue; String s1 = obj.toString(); if (s1 != null && s1.startsWith(s)) { popup.getList().setSelectedIndex(j); return; } } } popup.getList().clearSelection(); }