开发者

Grab and drag JComboBox scroll

I would like to make JComboBoxes scrollable by dra开发者_开发问答gging their contents. It makes sense for a touch-screen app. I think I could manage to do it if there was a way to programmatically scroll a JComboBox. Is there?


I'm not sure I understand the question since the popup of the combo box is scrollable by default.

However, in general, to scroll a component added to a scrollpane you would use the scrollRectToVisible(...) method on that component.

The combo box popup uses a JList to hold each item. You can access the JList using:

Object child = comboBox.getAccessibleContext().getAccessibleChild(0);
BasicComboPopup popup = (BasicComboPopup)child;
JList list = popup.getList();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜