Skip to main content

How to Initialize ContainerList with selectedItem?

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
ajochems
Offline
Joined: 2010-08-23

Hi,

I have a List object which is filled with rows from a sqlite database. One of the list items is made the selected item when initializing and the List is configured with List.FIXED_LEAD. The ContainerList is then created based on the getModel of the List. I would expect the ContainerList to take over the selection of the ListModel of the List but it is completly ignoring it. How can i initialize the ContainerList with a selected item at the top of the List?

This is the code i use to create the ContainerList:

lstCountries.setScrollToSelected(true);

lstCountries.setFixedSelection(List.FIXED_LEAD);

ContainerList cntCountriesList = new ContainerList(lstCountries.getModel());

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07

The container list should "jump" to the selected entry when the model changes or has a none-zero selected index.

I'm not exactly sure I understand the problem description, can you illustrate it with a sample use?