0

I am trying to have multiple combo boxes to select items from a shared list.

Ideally, the selecting Option 1 from combo box 1, would remove option 1 from the other combo box models, and the combo box 1 would now have an "empty" option at the top of the model list, and if that is then selected, the original item selected will now be added to the shared list again.

The list will be at least 10 items and can go up to almost 50-60.

I created a panel class to contain a "slave" which can consist of 1 or a 3 phase entry - 1 -> 1 combo box enabled, 3 -> 3 enabled. MeterPanel

Now I put 8 of these MeterPanels together to create a full Meter. Full Meter

My FullMeterPanel class looks something like this.

With options

I don't know how to track which items have been selected, how to keep all the other combo boxes models updated, and how to add a 'deselect' feature to re add previously selected items back to models.

I was using this answer to help create a model to be used for all the combo boxes, but I don't think the way I've implemented it will work.

So my FullMeterPanel creates an ArrayList<MeterPanel> - 8 of them to be exact, then adds them to a panel. For each meter panel I give it a DefaultListModel and every time an item is selected, I send the index back to the parent FullMeterPanel and re update the models of the MeterPanel. Currently I only add the "USED" to the string being used.

Any ideas on what I can change/implement to get this working? I think I'm going to redesign this panel as the current implementation doest seem efficient.

Community
  • 1
  • 1
Eric G
  • 928
  • 1
  • 9
  • 29

0 Answers0