Java JTextField Select focusAndSelectTextInTextField(JTextField textField)

Here you can find the source of focusAndSelectTextInTextField(JTextField textField)

Description

focus And Select Text In Text Field

License

Open Source License

Declaration

public static void focusAndSelectTextInTextField(JTextField textField) 

Method Source Code


//package com.java2s;
import javax.swing.JTextField;

public class Main {
    public static void focusAndSelectTextInTextField(JTextField textField) {
        int length = textField.getText().length();

        textField.setSelectionStart(0);/* w ww  .  j a v a  2s  . c o  m*/
        textField.setSelectionEnd(length);

        textField.requestFocus();
    }
}

Related

  1. addSelectAllListener(final JTextField field)
  2. addSelectOnFocus(JTextField one)
  3. buttonFolderSelect(final JTextField text)
  4. createSelected(final JTextField textField, final JButton... btns)
  5. newFileChooser(String dialogTitle, int fileSelectionMode, JTextField textField, String globalLocation)
  6. recipientHintSelected(String hintString, JTextField toList, boolean shiftKeyPressed)
  7. selectAllOnFocus(final JTextField jtf, final String recoverText, final Color forTip, final Color forContent)
  8. selectByTyping(javax.swing.JTree tree, javax.swing.JTextField textfield)