Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2008

Tip: Looking for answers? Try searching our database.

JList: Scroll to Selected Item

Thread view: 
Hal Vaughan - 26 Jan 2008 21:41 GMT
I'm using Java 1.4.2 and I've tried searching for this and can't find it,
but I'm sure I saw a method for a JList to scroll to the selected item.

There are times a JList (in a JScrollPane) is reloaded.  On some platforms,
apparently, when I reload it, even though I make sure the same item stays
selected, users report that the list then resets to show the top of the
list only.

Maybe I'm mixing things up, but I was sure I saw something like
scrollToSelected() for a JList or JScrollPane, but I can't find it in the
API index and couldn't find it in a search.  Is it under a different
wording or is there another method that scrolls a JList to show the
selected item?

Thanks!

Hal
Knute Johnson - 26 Jan 2008 23:31 GMT
> I'm using Java 1.4.2 and I've tried searching for this and can't find it,
> but I'm sure I saw a method for a JList to scroll to the selected item.
[quoted text clipped - 13 lines]
>
> Hal

See JList.ensureIndexIsVisible() and JList.setSelectedValue()

Signature

Knute Johnson
email s/nospam/knute/

     ------->>>>>>http://www.NewsDem

Hal Vaughan - 27 Jan 2008 01:32 GMT
>> I'm using Java 1.4.2 and I've tried searching for this and can't find it,
>> but I'm sure I saw a method for a JList to scroll to the selected item.
[quoted text clipped - 15 lines]
>
> See JList.ensureIndexIsVisible() and JList.setSelectedValue()

Great!  I knew about setSelectedValue(), but the ensureIndexIsVisible() is
exactly what I was looking for!  I guess it's a case of tunnel vision where
I was so stuck on what I thought I saw I missed what I needed.

Thanks!

Hal


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.