Tabbing through TextFields

Is there a way so that tabbing through TextFields will leave the current contents highlighted by default?

For example:

X [ 12 ]

Y [ 34 ]

Where X and Y are labels and []'s are textfields. Say I tab to the field in front of X, I would like to have 12 completely highlighted so that I just type something to overwrite the contents.

Right now I have to type Ctrl-A to make the contents highlighted, then I can type something to overwrite the field, I just want to make so that the content is highlighted by default when I tab to that particular field.

Thanks,

-frankie

[615 byte] By [Frankie_Liua] at [2007-10-2 4:47:16]
# 1

Try using a FocusListener:

final JTextField text = new JTextField();

text.addFocusListener(new FocusAdapter() {

public void focusGained(FocusEvent e) {

text.selectAll();

}

});

happy_hippoa at 2007-7-16 0:52:03 > top of Java-index,Desktop,Core GUI APIs...