List of usage examples for javax.swing.plaf ComboBoxUI isPopupVisible
public abstract boolean isPopupVisible(JComboBox<?> c);
From source file:Main.java
public void actionPerformed(ActionEvent e) { JComboBox jcb = (JComboBox) e.getSource(); System.out.println("down action"); ComboBoxUI ui = jcb.getUI(); if (ui.isPopupVisible(jcb)) { int i = jcb.getSelectedIndex(); if (i < jcb.getModel().getSize() - 1) { jcb.setSelectedIndex(i + 1); jcb.repaint();/*from www . j ava 2 s. c o m*/ } } else { int nItems = jcb.getItemCount(); ComboBoxEditor cbe = jcb.getEditor(); String st; // Search text st = ((String) cbe.getItem()).toUpperCase(); for (int i = 0; i < nItems; i++) { String item = ((String) jcb.getItemAt(i)).toUpperCase(); if (item.startsWith(st)) { jcb.setSelectedIndex(i); break; } } ui.setPopupVisible(jcb, true); } }