Solved

How to get the object bound  to the currently selected row of a JTable ?

Posted on 2008-06-16
2
544 Views
Last Modified: 2013-12-14
Hello,

I'm working on a J2SE desktop application (client/server) where I'm using beans binding to display the result of a query in a JTable.
How do I gain access to the bound object that corresponds to the currently selected row of the JTable?
I'm a new JAVA programmer and I'm using Java 5.0 + Netbeans IDE 6.1.
0
Comment
Question by:optima-sc
2 Comments
 
LVL 92

Expert Comment

by:objects
ID: 21798490
0
 

Accepted Solution

by:
optima-sc earned 0 total points
ID: 21801859
Well, I guess I did not formulate my question correctly:
I have a list of business objects displayed in JTable via beans binding (so that the list and the jTable are kept in sync at all times). I need to get a reference to the underlying business object (in the business object list) corresponding to the row selected in the JTable.
I had already figured that the Table property would be getSelectedRow, but I needed to be able to link that row to the source business object.
It turns out that the solution is quite simple in fact:
     int index = displayTable.getSelectedRow();
     mydesktopapplication.BusinessObject o = sourceList.get(index);
Thank you for your time, anyway!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now