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 / May 2005

Tip: Looking for answers? Try searching our database.

How to programmatically select a list in JList?

Thread view: 
cybernerdsx2@yahoo.com - 13 May 2005 05:48 GMT
Hi,

I am using JList component and I add a vector of data by calling
list.setDataList( vec );

Then I fire up the dialog with the JList component in it, I would like
to hard-code it to highlight the very first data on the list, how can I
go about doing that?
Michael Rauscher - 13 May 2005 07:00 GMT
cybernerdsx2@yahoo.com schrieb:
> Hi,
>
[quoted text clipped - 4 lines]
> to hard-code it to highlight the very first data on the list, how can I
> go about doing that?

From the JList documentation:

<api>
public void setSelectedIndex(int index)

    Selects a single cell.
</api>

Bye
Michael
Thomas Weidenfeller - 13 May 2005 08:00 GMT
> Then I fire up the dialog with the JList component in it, I would like
> to hard-code it to highlight the very first data on the list, how can I
> go about doing that?

Read the fine manual at

http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JList.html#setSelectedIndex(int)

/Thomas

Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq

LDB - 15 May 2005 03:12 GMT
You can use

    list.setSelectedIndex(0);

LDB

> Hi,
>
[quoted text clipped - 4 lines]
> to hard-code it to highlight the very first data on the list, how can I
> go about doing that?


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.