How about you use arrays of text fields, with the indexes being equal to the tab indexes? Or List<JTextField>? You can then use the tab index to directly retrieve the text fields.
Also, another oddity:
That's a lot of code repretition. In fact, the colors are the only real difference. So why not move the other two lines out of the switch statement?
You could also move the entire color code out of the if-statement if you use two arrays:
In fact, you could turn those two arrays into private static final fields.
Joined: May 01, 2009
Thanks for the advice, I followed your advice and streamlined the method.
How do I now access a Textfield in a panel of a JTabbedPane so I can add or remove String information ?
I have tried typing in "jtp.setSelectedIndex(tabindex);", trying to see if I can access it similar to a Arraylist.
But the IDE does not let me.