I would work on this aspect of the program in isolation, in its own small program that does nothing but swapping components based on the selection of a combo box. Take out all other bits of code...
Type: Posts; User: curmudgeon
I would work on this aspect of the program in isolation, in its own small program that does nothing but swapping components based on the selection of a combo box. Take out all other bits of code...
You could create an array of JPanel and place each JLabel / JComboBox pair in the JPanel, and add and remove combo boxes from the panel based on array index, or use CardLayout to swap the components.
Also, when you see a lot of redundant code, you will want to get rid of it and simplify your code by creating methods. For instance you could create a method say called void setUpComboBox(JComboBox...
A while loop in this location is a dangerous thing and unnecessary. Why are you choosing to use this construct? Wouldn't if and if-else blocks be more appropriate for this?