Here you can find the source of focusSelect(final JTextComponent tf)
public static void focusSelect(final JTextComponent tf)
//package com.java2s; //License from project: Apache License import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import javax.swing.text.JTextComponent; public class Main { public static void focusSelect(final JTextComponent tf) { tf.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { tf.selectAll();/* w w w.ja va 2s .co m*/ } }); } }