• 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

What event handler to use?

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings all
My application has a table with one of the columns use ComboBox as renderer, I hope that the data list of the ComboBox with dynamically updated based on the selections on the other rows. Which event handler should I add?
Regards
Anthony
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm no sure I fully understand your problem.
You have a JTable.
One of the columns has a JComboBox as an editor.
The choices available in the JComboBox depend on the data in the other columns.
Is that right ?
It would help if you could post some code.
Are you sure you want to use a JTable for this ? Why are you using a JTable ?
D.
 
Anthony Yip
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am still working on it, therefore, no code is available now.
Be detailed:
I have a list of objects. User can pick any number of them, maybe 1 or maybe all, to form a combination of them. After picking them, they will set some attributes on each of them.
Since I don't know how many objects user will pick each time. The most convenient way I can think of is using a table. When user need to pick up an additional object, I just add a new row for them.
The first column of the table will be a ComboBox to list those objects for user to choose from. Since user is not supposed to pick the same object twice for each combination, I have to update the ComboBox's model in order to avoid user to pick those objects already selected in other columns. That's why I want to know what listener and handler I should use so that I could update the ComboBox.
Hope you will understand my problem a bit more. Thanks alots.
Regards
Anthony
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure a JTable is the way to go. Just because you need to model multiple instances of an editor does not mean tha you should use a JTable.
Alternatively, write an ObjectEditor class (what Objects are they by the way, it makes the conversation easier... ). An ObjectEditor instance will allow the user to set some attributes on an object.
Then all you have to do is create as many ObjectEditors as the user chooses objects. When the user needs to pick up an additional object, you just create a new ObjectEditor instance. This is just as easy as adding an extra row to a JTable.
Does that help ?
D.
 
reply
    Bookmark Topic Watch Topic
  • New Topic