[JTabbedPane] get the tab index of a textfield

Hello,

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?

Greetings

Hans

[337 byte] By [HansJouwea] at [2007-10-1 1:43:29]
# 1
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.
ibicema at 2007-7-8 8:06:13 > top of Java-index,Security,Event Handling...
# 2
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.
HansJouwea at 2007-7-8 8:06:13 > top of Java-index,Security,Event Handling...
# 3

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.

camickra at 2007-7-8 8:06:13 > top of Java-index,Security,Event Handling...