• Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing Elements in a JTable?

 
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.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!