1

I need to create a number of dialogs that are of the same basic structure that looks like this: My Dialog

There will be a varying number of rows, each with a labeled checkbox and two combo boxes that have integers, the range of which varies. The check box just enables the combo boxes. When the selection in the first combobox is changed, the second one gets initialized and enabled.

Since I have to do over 50 over these I'd like automate the programming. I believe some of the code can be handled with loops, selecting combobox names from preset string arrays. What I can't figure out is how to parameterize things like action listeners.

First question is can this be done at all. If it can, how?

Ed

Ed S
  • 239
  • 5
  • 21
  • `JTable` comes to mind, but, you could also create a single `JPanel` which contains the checkbox, label and comboboxes and simple layout as many as you need – MadProgrammer Nov 30 '17 at 22:35

2 Answers2

2

First create a notional RowModel containing a Boolean value for the checkbox, a String for the label and two instances of ComboBoxModel, one for each of the combos. Handle the combo dependency as shown here. Let your program maintain a List<RowModel> for each distinct dialog. You can manage an arbitrary number of rows in a suitable TableModel and display them is a JTable as shown here.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
0

Actually, I just want to say that MadProgrammer provided an answer that worked for me in his Comment.

Ed S
  • 239
  • 5
  • 21