Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

JTable with different objects (or components) in a column  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,

I have a Vector that feeds my JTable. This table has some columns, but the problem is that these columns have different objects, like strings, booleans, integers, and so on.
My ideia is to insert a checkbox in boolean type cells, and insert a combobox in some cells that I choose. (my table is editable)

I developed something here (posted below), that seems to work parcially.


When I start my app the checkbox don't appear, it only happens after clicking, how can I solve this?
As per you can see in my code, I try to attribute values for the checkbox and to the textfields, but when I click in the cell, they are shown as default, check box as false and textfield empty. Any ideia how to fix it?

All this doens't happen in a Standard JTable, with only one type of object per column.


And how can I somehow insert a component into a cell and let other column cells as ordinary cells, not as JTextFields for exemple ?



Here my TableCellEditor code:



 
Sheriff
Posts: 21421
94
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved this by extending JTable and overriding both "public TableCellRenderer getCellRenderer(int row, int column)" and "public TableCellEditor getCellEditor(int row, int column)".

For instance:
 
Leonardo Buzinskas
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maaaany thanks!!!

Problem Solved with your information!

Below the class that saved me...lol


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!