Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-06-16
2
Medium Priority
?
566 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
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 tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

721 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