• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to add more than one component to a cell in JTable

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I want to add three components (three comboBoxes for date) to a cell in a JTable. Can somebody help me with any such example.
Thanks
Pomchi
 
Author
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add three components to a container. Add container.
------------------
John Zukowski Author of "Definitive Guide to Swing for Java 2" and "Java Collections"
 
Pomchi Bedi
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi John,
Thanks for the prompt reply.
This is exactly what I tried writing my own renderer and editor.It works fine and I am able to select values from each of the combobox as well,but the moment I move to the next cell in the same column the value that I had selected in the first cell is gone.The value that I select is not getting set in the cells.
I tried doing various things but nothing seems to work.
It is very important for me so any sample code or any suggestion is highly appreciated.
Thanks
Pomchi

 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Renderes only display data. In order to edit the data you need to user CellEditor as well.
 
Pomchi Bedi
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply Aleksey....I have used the cell editor because of this editor I am able to select the values from all comboBoxes in one cell but the values are not staying.
In my renderer I have created a panel in which I have added three ComboBoxes and in getCellRendererComponent I am returning this panel.In cell editor I have created an instance of my renderer and in getCellEditorComponent I just say return renderer.I am not doing anything else in the editor or renderer.
I guess I need to do something more in the cell editor but I don't know what.
Please suggest what is going wrong here.(I have really tried a lot of things but nothing is working so any code sample for rendering and editing a single component will also help.)
Thanks
Pomchi
reply
    Bookmark Topic Watch Topic
  • New Topic