mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
05.56.2007 85e7dcfea5044ee3effcac9564cf15b936c2e018
opends/src/quicksetup/org/opends/quicksetup/ui/UIFactory.java
@@ -34,6 +34,8 @@
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.HashMap;
@@ -834,6 +836,7 @@
  {
    JTextField f = new JTextField();
    updateTextFieldComponent(f, text, tooltip, size, style);
    f.addFocusListener(new TextFieldFocusListener(f));
    return f;
  }
@@ -852,6 +855,7 @@
  {
    JPasswordField f = new JPasswordField();
    updateTextFieldComponent(f, text, tooltip, size, style);
    f.addFocusListener(new TextFieldFocusListener(f));
    return f;
  }
@@ -1775,3 +1779,44 @@
    }
  }
}
/**
 * A class used to be able to select the contents of the text field when
 * it gets the focus.
 *
 */
class TextFieldFocusListener implements FocusListener
{
  private JTextField tf;
  /**
   * The constructor for this listener.
   * @param tf the text field associated with this listener.
   */
  TextFieldFocusListener(JTextField tf)
  {
    this.tf = tf;
  }
  /**
   * {@inheritDoc}
   */
  public void focusGained(FocusEvent e)
  {
    if ((tf.getText() == null) || "".equals(tf.getText()))
    {
      tf.setText(" ");
      tf.selectAll();
      tf.setText("");
    }
    else
    {
      tf.selectAll();
    }
  }
  /**
   * {@inheritDoc}
   */
  public void focusLost(FocusEvent e)
  {
  }
}