基本上,您正在寻找list.locationToIndex(如果我对您的理解正确),类似
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; ....顺便说一句,另一个没有传递到列表中的属性:应该会
list.getVisibleRowCount() == combo.getMaximumRowCount()
要回答这个问题:头和尾之间(包括首尾)之间的所有项目都是可见的,头和尾以上的所有项目都不可见;-)



