tags:

views:

54

answers:

1

How could I put a JPanel into a cell of a JTable?
(There would be a column what would contain String objects, and an other column with JPanel objects. )

+1  A: 

http://download.oracle.com/javase/tutorial/uiswing/components/table.html#renderer

Read the part that talks about using Custom Renderers. The ColorRenderer example puts a JLabel in a cell. You could easily change that to use a JLabel instead.

Shahriar
Now, I've successfully added a `JPanel` with a `JButton` to the cell, but only the upper-half of the button is visible, and if I click on the cell, it does nothing. Is it possible to make the button on the panel "clickable"?
János Harsányi
can't you just add an ActionListener to the button? But I guess you will need to pass in the table's row, column info to the listener as well
Shahriar