How to select text in JTextField while tabbing

java, swing

Solution

This exact question has been asked and answered, check it out here.

Short version: Add a focus listener to your text components and select all on focus, using SwingUtilities.invokeLater to ensure all pending AWT events have been processed.

Problem

I have a `JDialog` with a series of `JTextField`s on it I would like the text each to be selected when I tab to it.

Original source

Related problems