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 / October 2004

Tip: Looking for answers? Try searching our database.

ListSelectionEvent ?

Thread view: 
Madhur Ahuja - 02 Oct 2004 07:19 GMT
Hello

I want to display information in a JTextArea whenever a user
selects a row in the JTable. The code which I am using is :

maintable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SEL
ECTION);

 maintable.getSelectionModel().addListSelectionListener(new
ListSelectionListener()
 {
  public void valueChanged(ListSelectionEvent e)
  {
   int row=e.getFirstIndex();
   int row1=e.getLastIndex();

   System.out.println("madhur"+row+" "+row1);

  }

 });

However I am unable to interpret the values of e.getFirstIndex() and
e.getLastIndex.
They sometimes match with the selected row and sometimes not. Since I am
using
single selection model, how can I get just the integer corresponding to the
row selected?

--
Madhur Ahuja [madhur<underscore>ahuja<at>yahoo<dot>com]

Homepage
http://madhur.netfirms.com
Babu Kalakrishnan - 02 Oct 2004 08:52 GMT
> I want to display information in a JTextArea whenever a user
> selects a row in the JTable. The code which I am using is :
[quoted text clipped - 22 lines]
> single selection model, how can I get just the integer corresponding to the
> row selected?

First thing to do is to ignore all events which return true for the
getValueIsAdjusting() call.

For the remaining events, I've found that calling getSelectedRow() on
the table itself is the most reliable thing to do (for SINGLE_SELECTION
and getSelectedRows() for MULTI_SELECTION).

BK


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.