This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Loading JTables with javabeans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Loading JTables with javabeans" Watch "Loading JTables with javabeans" New topic

Loading JTables with javabeans

Barry Brashear
Ranch Hand

Joined: Jun 05, 2001
Posts: 303
Has anyone ever heard of a way of building a JTable using javabeans where the javabean not only the data but the way the data is displayed?

I'm looking for a generic table building model.

David Mace
Ranch Hand

Joined: May 26, 2004
Posts: 35
I'm not sure what you mean by the bean not only contains the data, but the way it is to be displayed, but I'll take a guess at your meaning. If you mean that, for instance, you have a boolean value and instead of a JLabel simply stating either true/false versus having a checkbox, then here's the solution.

You'll first want to implement a custom table model....start by extending AbstractTableModel. In order to set a column to display using something other than the default JLabel, you'll need to create a custom renderer for that column. I'll leave you with that info and you should be able to google the remaining piece of the puzzle for your answer. It's really simple to do.


Dad always thought laughter was the best medicine, which I guess is why several of us died of tuberculosis. -Jack Handy
I agree. Here's the link:
subject: Loading JTables with javabeans
Similar Threads
Custom Tags v/s Java Beans
Simple question
Can we consider JSF & JPA as framework ?
New project - JavaBeans Vs. EJB
Looking for a database to Java code generator