List of usage examples for javax.swing JComboBox getUI
public ComboBoxUI getUI()
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();//w w w . j a va 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); } }