开发者

Grab and drag JComboBox scroll

开发者 https://www.devze.com 2023-02-05 10:48 出处:网络
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 scr

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

精彩评论

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