• 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

Jtable combo box issue

 
Ranch Hand
Posts: 32
MySQL Database Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm having a new table with a jcombobox in that. After selecting the first row value from the combox(first row returns selected value properly), if we select the second row value from the combobox it is retruning empty value. How to solve this issue??

Adding the following code in the constructor.


Here are my doubts:
Am I addiing only one jcombobox to the entire table instead of adding a new combobox for each row in the table??
If yes how to add new jcombobox for each table.

Please help me to solve this issue.

Thanks and Regards,
Kiran Kumar K.V
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Swing tutorial on "How to Use Tables" has a working example.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

kopparapu v kiran kumar wrote:Am I addiing only one jcombobox to the entire table instead of adding a new combobox for each row in the table??


Yes.

If yes how to add new jcombobox for each table.


You don't need to use a new JComboBox for each table, you just need to replace the JComboBox contents for each cell. You have two choices that I can think of:
1) override JTable's prepareEditor method:

2) subclass DefaultTableCellEditor and do something similar in its getTableCellEditorComponent method.
 
kopparapu v kiran kumar
Ranch Hand
Posts: 32
MySQL Database Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any example with the DefaultCellEditor would be appreciated.
 
Rob Camick
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again, the tutorial has a working example!
 
kopparapu v kiran kumar
Ranch Hand
Posts: 32
MySQL Database Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Rob,


Have you tested that example they have given?? It doesn't suits my requirement.... Try to understand the requirement first.


Thanks and Regards
Kiran
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The tutorial shows how to use a combo box as an editor. My code shows how to fill the combo box. How does that not meet your requirements?
 
kopparapu v kiran kumar
Ranch Hand
Posts: 32
MySQL Database Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Rob Prime,

Sorry. Your name and Rob Camik firname is same(Rob). I thought to convey my message to Rob Camik. Sorry for the overlook.

Thanks and Regards,
Kiran Kumar.
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

kopparapu v kiran kumar wrote:I thought to convey my message to Rob Camick.


I got that, but does that mean I am not allowed to reply?
 
kopparapu v kiran kumar
Ranch Hand
Posts: 32
MySQL Database Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
NO!!
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I really hope you're kidding...
reply
    Bookmark Topic Watch Topic
  • New Topic