private static JList getPopupList( JComboBox combo ) { Accessible a = combo.getUI().getAccessibleChild(combo, 0); if( a instanceof ComboPopup ) { return ((ComboPopup) a).getList(); } return null; } }
Accessible a = fontsBox.getUI().getAccessibleChild(fontsBox, 0); if (a instanceof javax.swing.plaf.basic.ComboPopup) { JList list = ((javax.swing.plaf.basic.ComboPopup)a).getList(); Rectangle rect = list.getVisibleRect(); int first = list.locationToIndex(rect.getLocation()); // similar for last, at the lower edge of the visible rect, left as exercise <g> // Edit: as of @Boro's comment, last is easier calculated with maxRowCount int last = first + fontsBox.getMaximumRowCount() - 1; ....
/** * @param sb The combo box we are testing * @return The JList component used to display the combobox */ public JComponent findPopupFromUI(JComboBox sb) { Accessible a = sb.getUI().getAccessibleChild(sb, 0); if (a != null && a instanceof javax.swing.plaf.basic.ComboPopup) { // get the popup list JList list = ((javax.swing.plaf.basic.ComboPopup)a).getList(); return list; } return (JList)findPopupComponent(sb); }
/** * Get the list used by the combo box popup. * * @return {@link JList} for popup; {@code null} if we couldn't find it. */ @Nullable protected JList getPopupList() { JList result = null; final ComboBoxUI comboBoxUI = getUI(); final int childrenCount = comboBoxUI.getAccessibleChildrenCount( this ); for ( int i = 0; i < childrenCount; i++ ) { final Accessible child = comboBoxUI.getAccessibleChild( this, i ); if ( child instanceof ComboPopup ) { result = ( (ComboPopup)child ).getList(); break; } } return result; } }
public void actionPerformed(ActionEvent e) { JComboBox comboBox= (JComboBox) e.getSource(); if (comboBox.isEnabled()) { ComboBoxUI ui= (ComboBoxUI) comboBox.getUI(); if (ui.isMyTableCellEditor()) { // Forces the selection of the list item if the // combo box is in a JTable. comboBox.setSelectedIndex(ui.popup.getList().getSelectedIndex()); } else { comboBox.setPopupVisible(!comboBox.isPopupVisible()); } } } }
Accessible a = box.getUI().getAccessibleChild(box, 0); if (a instanceof javax.swing.plaf.basic.ComboPopup) { JList popupList = ((javax.swing.plaf.basic.ComboPopup) a).getList();
public Object getPopupPrototypeDisplayValue(JComboBox jc) { int maxWidth = -1; Object prototype = null; JList list = ((SubstanceComboBoxUI) jc.getUI()).getPopup().getList(); for (int i = 0; i < jc.getModel().getSize(); i++) { Object elem = jc.getModel().getElementAt(i); Component renderer = jc.getRenderer().getListCellRendererComponent( list, elem, i, false, false); if (renderer != null) { int rWidth = renderer.getPreferredSize().width; if (rWidth > maxWidth) { maxWidth = rWidth; prototype = elem; } } } return prototype; } }
protected static JList getPopupListFor(JComboBox comboBox) { int count = comboBox.getUI().getAccessibleChildrenCount(comboBox); for (int i = 0; i < count; i++) { Accessible a = comboBox.getUI().getAccessibleChild(comboBox, i); if (a instanceof ComboPopup) { return ((ComboPopup) a).getList(); } } return null; }
protected static JList getPopupListFor(JComboBox comboBox) { int count = comboBox.getUI().getAccessibleChildrenCount(comboBox); for (int i = 0; i < count; i++) { Accessible a = comboBox.getUI().getAccessibleChild(comboBox, i); if (a instanceof ComboPopup) { return ((ComboPopup) a).getList(); } } return null; }
protected static JList getPopupListFor(JComboBox comboBox) { int count = comboBox.getUI().getAccessibleChildrenCount(comboBox); for (int i = 0; i < count; i++) { Accessible a = comboBox.getUI().getAccessibleChild(comboBox, i); if (a instanceof ComboPopup) { return ((ComboPopup) a).getList(); } } return null; }
Component comp = renderer.getListCellRendererComponent(popup.getList(), 1, 0, false, false); int pref = comp.getPreferredSize().height; return pref;
protected static JList getPopupListFor(JComboBox comboBox) { int count = comboBox.getUI().getAccessibleChildrenCount(comboBox); for (int i = 0; i < count; i++) { Accessible a = comboBox.getUI().getAccessibleChild(comboBox, i); if (a instanceof ComboPopup) { return ((ComboPopup) a).getList(); } } return null; }
@Override public Object getPopupPrototypeDisplayValue(JComboBox jc) { int maxWidth = -1; Object prototype = null; JList list = ((SubstanceComboBoxUI) jc.getUI()).getPopup().getList(); for (int i = 0; i < jc.getModel().getSize(); i++) { Object elem = jc.getModel().getElementAt(i); Component renderer = jc.getRenderer().getListCellRendererComponent( list, elem, i, false, false); if (renderer != null) { int rWidth = renderer.getPreferredSize().width; if (rWidth > maxWidth) { maxWidth = rWidth; prototype = elem; } } } return prototype; } }
JList list = ((ComboPopup) a).getList(); int lastIndex = list.getModel().getSize() - 1;
JList list = ((ComboPopup) a).getList(); int lastIndex = list.getModel().getSize() - 1;
JList list = ((ComboPopup) a).getList(); int lastIndex = list.getModel().getSize() - 1;
protected static void repaintComboBox(JComboBox<?> combo, int row) { if (combo.getSelectedIndex() == row) { combo.repaint(); } Accessible a = combo.getAccessibleContext().getAccessibleChild(0); if (a instanceof ComboPopup) { JList<?> list = ((ComboPopup) a).getList(); if (list.isShowing()) { list.repaint(list.getCellBounds(row, row)); } } }
return popup.getList();
this.popup.getList().removeMouseListener(popupMouseHandler);
installDefaults(); popup= createPopup(); listBox= popup.getList();