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
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.
Joined: Aug 24, 2003
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
Joined: Dec 12, 2002
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.