Solved

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

Posted on 2008-06-16
2
555 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 214
arguments to jar 5 35
How to configure empty element in XML Document parser? 15 36
junit as external jar or library 7 24
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
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…
The viewer will learn how to implement Singleton Design Pattern in Java.
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.

820 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