I'm using a jTabbedPane to display data. On every tab I have several panels with JTextFields. I would like to know on wich index of the tabpane a textfield is located. So when a textfield is empty I can use tabpane.setSelectedIndex( i ) to set te focus to that tab.
Enyone any tips?
this might be not helpful, but why don't you add an action listener to your textfields and in the actionPerformed function you check the text fields which gettext.equals("") and do what you have to do there.
hope this is useful.
Thank for your input. But this is not what I want, I want to perform a check on an array of fields at moment a user want's to save a record. With an actionhandler to every textfield I would have to check at every field again.
But thank anyway.
I'm guessing that just setting focus on the text field doesn't cause the tab selection to change.
So here's a brute force way to do it:
a) find the parent container of the text field
b) use the tabbedPane.getComponentAt(..) method to compare the above component. When they are equal you now which tab contains the text field.