Java Swing Focus createWizardFocusAdapter()

Here you can find the source of createWizardFocusAdapter()

Description

create Wizard Focus Adapter

License

Open Source License

Declaration

public static FocusAdapter createWizardFocusAdapter() 

Method Source Code

//package com.java2s;
//it under the terms of the GNU Affero General Public License as published by

import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;

import javax.swing.text.JTextComponent;

public class Main {
    public static FocusAdapter createWizardFocusAdapter() {
        return new FocusAdapter() {

            @Override//w  ww  .j a  v  a  2s  . c o  m
            public void focusGained(FocusEvent e) {
                if (e.getSource() instanceof JTextComponent) {
                    JTextComponent tf = (JTextComponent) e.getSource();
                    tf.setSelectionStart(0);
                    tf.setSelectionEnd(tf.getText().length());
                }
            }

        };
    }
}

Related

  1. checkComponentsFocusable(final Component _rootComponent)
  2. clearAWTFocus(Robot robot)
  3. compositeRequestFocus(Component component)
  4. containerContainsFocus(Container cont)
  5. containerContainsFocus(Container cont)
  6. focusComponent(Component comp)
  7. focusComponentOrChild(Component c)
  8. focusComponentOrChild(Component c, boolean deepest)
  9. focusFirstFocusableChild(Container c)