sivabudh
sivabudh

Reputation: 32635

Java Swing: what class can be used to implement this?

What Swing class can I use to implement something like this?

Add To List http://img22.imageshack.us/img22/3260/swingwidget.jpg

EDIT: Hmm..for some reason I cannot add the image here. Well, here's the link:

Basically, I need a list table, where each column can be of different type of gui (i.e. plain text, check box, or drop-down menu).

EDIT I have re-publish the image for you ;)

Upvotes: 2

Views: 373

Answers (3)

krystan honour
krystan honour

Reputation: 6793

JTable will do this for you, you're going to need to understand the MVC pattern pretty well to acheive this as you will need a custom model and renderer, but once you get the hang of it its not too hard.

David gearys book "Graphic Java Vol.2" has an excellent section on JTable, whilst this book is now fairly old I still personally think thats the best explanation of JTable I've seen.

Upvotes: 1

OscarRyz
OscarRyz

Reputation: 199225

Definitely JTable.

JTable allow you to define what render will have each column. That way you can add checkboxes, combos, textfields etc. to it.

Here's an screenshot:

alt text http://img43.imageshack.us/img43/9430/jtable.png

You can read more about it here: How to use Tables

Upvotes: 3

rob
rob

Reputation: 6247

You would use a JTable to implement it. Your data will be stored in a TableModel. The DefaultTableCellRenderer and DefaultTableCellEditor should do what you need, but you can also customize the rendering/behavior if necessary.

More info on renderers/editors: http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#editrender

Upvotes: 9

Related Questions