Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • 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

Using Mutilple Cell Editor on single column of JTable  RSS feed

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

Can any body tell me how to specify multiple cell editor on a single column of a JTable.
i.e I want to use JTextField to edit cell indexed at(1,2)...JCombobox to edit cell indexed at(2,2)...JLabel to edit cell at(3,2)...what should i do to Code it???
 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just did this (I think my method is kind of a hack, but it works).
I created another column in the table that holds the celleditor (drop down box or JText field) and I overrode the getCellEditor method to return the one that is in the adjacent column. Of course you want to remove this column from the table before displaying it.

If you know before hand what cells require what types of editor, you could also just do a switch/if statement to return the right editor.

-Tad
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!