• Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing Elements in a JTable?  RSS feed

 
Meyer Florian
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey there!
Does anyone know how to put Swing Elements (JLabel) into a Cell of a JTable?
The getValueAt(int row, int col) method returns an Object and the JTable displays the result of the toString() method of the element and not the element itself.
Thanks i.a.
Praiser
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.
The table model should contain only data. Swing elements could be used to render the cells of the table by extending from them and implementing TableCellRenderer.
Here is an example fron the Java Tutorial.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!