Java JList прокручивает к выбранному пункту

Нет никакого неявного броска, потому что перечисление не должно использовать интервал в качестве базового типа. Если Ваше перечисление использовало uint в качестве базового типа, например, нет никакого неявного броска от uint до интервала

20
задан Jonathan Drapeau 29 July 2014 в 15:36
поделиться

3 ответа

This should do it:

dataList.ensureIndexIsVisible(dataList.getSelectedIndex());
52
ответ дан 29 November 2019 в 22:38
поделиться

Or, if multi-selection is enabled :

dataList.scrollRectToVisible(
        dataList.getCellBounds(
            dataList.getMinSelectionIndex(), 
            dataList.getMaxSelectionIndex()
        )
);
11
ответ дан 29 November 2019 в 22:38
поделиться

You can use the ensureIndexIsVisible method

http://java.sun.com/javase/6/docs/api/javax/swing/JList.html#ensureIndexIsVisible(int)

Scrolls the list within an enclosing viewport to make the specified cell completely visible. This calls scrollRectToVisible with the bounds of the specified cell. For this method to work, the JList must be within a JViewport.

10
ответ дан 29 November 2019 в 22:38
поделиться
Другие вопросы по тегам:

Похожие вопросы: