Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-06-16
2
Medium Priority
?
572 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

876 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