jdk/src/macosx/classes/sun/lwawt/LWTextFieldPeer.java
changeset 12399 6221283c619f
parent 12047 320a714614e9
child 12531 42a9335fd8b3
child 12813 c10ab96dcf41
equal deleted inserted replaced
12398:8e4c529b8184 12399:6221283c619f
    29 import java.awt.Dimension;
    29 import java.awt.Dimension;
    30 import java.awt.Point;
    30 import java.awt.Point;
    31 import java.awt.TextField;
    31 import java.awt.TextField;
    32 import java.awt.event.ActionEvent;
    32 import java.awt.event.ActionEvent;
    33 import java.awt.event.ActionListener;
    33 import java.awt.event.ActionListener;
       
    34 import java.awt.event.FocusEvent;
    34 import java.awt.peer.TextFieldPeer;
    35 import java.awt.peer.TextFieldPeer;
    35 
    36 
    36 import javax.swing.JPasswordField;
    37 import javax.swing.JPasswordField;
    37 import javax.swing.text.JTextComponent;
    38 import javax.swing.text.JTextComponent;
    38 
    39 
    95     public void actionPerformed(final ActionEvent e) {
    96     public void actionPerformed(final ActionEvent e) {
    96         postEvent(new ActionEvent(getTarget(), ActionEvent.ACTION_PERFORMED,
    97         postEvent(new ActionEvent(getTarget(), ActionEvent.ACTION_PERFORMED,
    97                                   getText(), e.getWhen(), e.getModifiers()));
    98                                   getText(), e.getWhen(), e.getModifiers()));
    98     }
    99     }
    99 
   100 
       
   101     /**
       
   102      * Restoring native behavior. We should sets the selection range to zero,
       
   103      * when component lost its focus.
       
   104      *
       
   105      * @param e the focus event
       
   106      */
       
   107     @Override
       
   108     protected void handleJavaFocusEvent(final FocusEvent e) {
       
   109         if (e.getID() == FocusEvent.FOCUS_LOST) {
       
   110             // In order to de-select the selection
       
   111             setCaretPosition(0);
       
   112         }
       
   113         super.handleJavaFocusEvent(e);
       
   114     }
       
   115 
   100     private final class JTextAreaDelegate extends JPasswordField {
   116     private final class JTextAreaDelegate extends JPasswordField {
   101 
   117 
   102         // Empty non private constructor was added because access to this
   118         // Empty non private constructor was added because access to this
   103         // class shouldn't be emulated by a synthetic accessor method.
   119         // class shouldn't be emulated by a synthetic accessor method.
   104         JTextAreaDelegate() {
   120         JTextAreaDelegate() {