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. )
views:
54answers:
1
+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
2010-09-25 21:57:00
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
2010-09-26 11:20:03
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
2010-09-27 19:59:59