Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Types of data in a JTable cell  RSS feed

 
Barry Brashear
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone tell the types of data that can be placed and shown in a JTable
column? Can an Object be placed in a column or does it have to be something
like a String or JTextField?

Thanks.
 
Lionel Badiou
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Barry,

You may display any object in a JTable provided you create a custom renderer

Best regards,
 
Barry Brashear
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What types of data will it display using the default?
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Boolean - is displayed as checkbox
Number (and subclasses) are displayed right aligned (I think).
I think you can display either util.List or arrays as JCombos.

Don't forget to override getColumnClass() to instruct the table to use the right renderes/editors.

hth. D.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!