< prev index next >

src/java.desktop/unix/classes/sun/awt/X11/XTextFieldPeer.java

Print this page




  37 import javax.swing.plaf.ComponentUI;
  38 import javax.swing.InputMap;
  39 import javax.swing.JPasswordField;
  40 import javax.swing.SwingUtilities;
  41 import javax.swing.TransferHandler;
  42 
  43 import java.awt.event.MouseEvent;
  44 import java.awt.event.FocusEvent;
  45 import java.awt.event.KeyEvent;
  46 
  47 import javax.swing.plaf.UIResource;
  48 import javax.swing.UIDefaults;
  49 import javax.swing.JTextField;
  50 import javax.swing.JComponent;
  51 import javax.swing.border.Border;
  52 import com.sun.java.swing.plaf.motif.*;
  53 import java.awt.im.InputMethodRequests;
  54 
  55 import sun.util.logging.PlatformLogger;
  56 
  57 import sun.awt.CausedFocusEvent;
  58 import sun.awt.AWTAccessor;
  59 
  60 final class XTextFieldPeer extends XComponentPeer implements TextFieldPeer {
  61     private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XTextField");
  62 
  63     private String text;
  64     private final XAWTTextField xtext;
  65     private final boolean firstChangeSkipped;
  66 
  67     XTextFieldPeer(TextField target) {
  68         super(target);
  69         text = target.getText();
  70         xtext = new XAWTTextField(text,this, target.getParent());
  71         xtext.getDocument().addDocumentListener(xtext);
  72         xtext.setCursor(target.getCursor());
  73         XToolkit.specialPeerMap.put(xtext,this);
  74 
  75         initTextField();
  76         setText(target.getText());
  77         if (target.echoCharIsSet()) {


 601             }
 602         }
 603 
 604         public void repaintNow() {
 605             paintImmediately(getBounds());
 606         }
 607 
 608         @Override
 609         public Graphics getGraphics() {
 610             return xwin.getGraphics();
 611         }
 612 
 613         @Override
 614         public void updateUI() {
 615             ComponentUI ui = new AWTTextFieldUI();
 616             setUI(ui);
 617         }
 618 
 619         void forwardFocusGained( FocusEvent e) {
 620             isFocused = true;
 621             FocusEvent fe = CausedFocusEvent.retarget(e, this);

 622             super.processFocusEvent(fe);
 623         }
 624 
 625         void forwardFocusLost( FocusEvent e) {
 626             isFocused = false;
 627             FocusEvent fe = CausedFocusEvent.retarget(e, this);

 628             super.processFocusEvent(fe);
 629 
 630         }
 631 
 632         @Override
 633         public boolean hasFocus() {
 634             return isFocused;
 635         }
 636 
 637         public void processInputMethodEventImpl(InputMethodEvent e) {
 638             processInputMethodEvent(e);
 639         }
 640 
 641         public void processMouseEventImpl(MouseEvent e) {
 642             processMouseEvent(e);
 643         }
 644 
 645         public void processMouseMotionEventImpl(MouseEvent e) {
 646             processMouseMotionEvent(e);
 647         }




  37 import javax.swing.plaf.ComponentUI;
  38 import javax.swing.InputMap;
  39 import javax.swing.JPasswordField;
  40 import javax.swing.SwingUtilities;
  41 import javax.swing.TransferHandler;
  42 
  43 import java.awt.event.MouseEvent;
  44 import java.awt.event.FocusEvent;
  45 import java.awt.event.KeyEvent;
  46 
  47 import javax.swing.plaf.UIResource;
  48 import javax.swing.UIDefaults;
  49 import javax.swing.JTextField;
  50 import javax.swing.JComponent;
  51 import javax.swing.border.Border;
  52 import com.sun.java.swing.plaf.motif.*;
  53 import java.awt.im.InputMethodRequests;
  54 
  55 import sun.util.logging.PlatformLogger;
  56 

  57 import sun.awt.AWTAccessor;
  58 
  59 final class XTextFieldPeer extends XComponentPeer implements TextFieldPeer {
  60     private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XTextField");
  61 
  62     private String text;
  63     private final XAWTTextField xtext;
  64     private final boolean firstChangeSkipped;
  65 
  66     XTextFieldPeer(TextField target) {
  67         super(target);
  68         text = target.getText();
  69         xtext = new XAWTTextField(text,this, target.getParent());
  70         xtext.getDocument().addDocumentListener(xtext);
  71         xtext.setCursor(target.getCursor());
  72         XToolkit.specialPeerMap.put(xtext,this);
  73 
  74         initTextField();
  75         setText(target.getText());
  76         if (target.echoCharIsSet()) {


 600             }
 601         }
 602 
 603         public void repaintNow() {
 604             paintImmediately(getBounds());
 605         }
 606 
 607         @Override
 608         public Graphics getGraphics() {
 609             return xwin.getGraphics();
 610         }
 611 
 612         @Override
 613         public void updateUI() {
 614             ComponentUI ui = new AWTTextFieldUI();
 615             setUI(ui);
 616         }
 617 
 618         void forwardFocusGained( FocusEvent e) {
 619             isFocused = true;
 620             FocusEvent fe = new FocusEvent(this, e.getID(), e.isTemporary(),
 621                     e.getOppositeComponent(), e.getCause());
 622             super.processFocusEvent(fe);
 623         }
 624 
 625         void forwardFocusLost( FocusEvent e) {
 626             isFocused = false;
 627             FocusEvent fe = new FocusEvent(this, e.getID(), e.isTemporary(),
 628                     e.getOppositeComponent(), e.getCause());
 629             super.processFocusEvent(fe);
 630 
 631         }
 632 
 633         @Override
 634         public boolean hasFocus() {
 635             return isFocused;
 636         }
 637 
 638         public void processInputMethodEventImpl(InputMethodEvent e) {
 639             processInputMethodEvent(e);
 640         }
 641 
 642         public void processMouseEventImpl(MouseEvent e) {
 643             processMouseEvent(e);
 644         }
 645 
 646         public void processMouseMotionEventImpl(MouseEvent e) {
 647             processMouseMotionEvent(e);
 648         }


< prev index next >