545 @SuppressWarnings("serial") // JDK-implementation class |
545 @SuppressWarnings("serial") // JDK-implementation class |
546 final class XAWTTextField extends JPasswordField |
546 final class XAWTTextField extends JPasswordField |
547 implements ActionListener, DocumentListener { |
547 implements ActionListener, DocumentListener { |
548 |
548 |
549 private boolean isFocused = false; |
549 private boolean isFocused = false; |
550 private final XComponentPeer peer; |
550 private final XComponentPeer xwin; |
551 |
551 |
552 XAWTTextField(String text, XComponentPeer peer, Container parent) { |
552 XAWTTextField(String text, XComponentPeer xwin, Container parent) { |
553 super(text); |
553 super(text); |
554 this.peer = peer; |
554 this.xwin = xwin; |
555 setDoubleBuffered(true); |
555 setDoubleBuffered(true); |
556 setFocusable(false); |
556 setFocusable(false); |
557 AWTAccessor.getComponentAccessor().setParent(this,parent); |
557 AWTAccessor.getComponentAccessor().setParent(this,parent); |
558 setBackground(peer.getPeerBackground()); |
558 setBackground(xwin.getPeerBackground()); |
559 setForeground(peer.getPeerForeground()); |
559 setForeground(xwin.getPeerForeground()); |
560 setFont(peer.getPeerFont()); |
560 setFont(xwin.getPeerFont()); |
561 setCaretPosition(0); |
561 setCaretPosition(0); |
562 addActionListener(this); |
562 addActionListener(this); |
563 addNotify(); |
563 addNotify(); |
564 |
|
565 } |
564 } |
566 |
565 |
567 @Override |
566 @Override |
568 @SuppressWarnings("deprecation") |
567 @SuppressWarnings("deprecation") |
569 public void actionPerformed( ActionEvent actionEvent ) { |
568 public void actionPerformed( ActionEvent actionEvent ) { |
570 peer.postEvent(new ActionEvent(peer.target, |
569 xwin.postEvent( |
571 ActionEvent.ACTION_PERFORMED, |
570 new ActionEvent(xwin.target, ActionEvent.ACTION_PERFORMED, |
572 getText(), |
571 getText(), actionEvent.getWhen(), |
573 actionEvent.getWhen(), |
572 actionEvent.getModifiers())); |
574 actionEvent.getModifiers())); |
|
575 |
573 |
576 } |
574 } |
577 |
575 |
578 @Override |
576 @Override |
579 public void insertUpdate(DocumentEvent e) { |
577 public void insertUpdate(DocumentEvent e) { |
580 if (peer != null) { |
578 if (xwin != null) { |
581 peer.postEvent(new TextEvent(peer.target, |
579 xwin.postEvent(new TextEvent(xwin.target, |
582 TextEvent.TEXT_VALUE_CHANGED)); |
580 TextEvent.TEXT_VALUE_CHANGED)); |
583 } |
581 } |
584 } |
582 } |
585 |
583 |
586 @Override |
584 @Override |
587 public void removeUpdate(DocumentEvent e) { |
585 public void removeUpdate(DocumentEvent e) { |
588 if (peer != null) { |
586 if (xwin != null) { |
589 peer.postEvent(new TextEvent(peer.target, |
587 xwin.postEvent(new TextEvent(xwin.target, |
590 TextEvent.TEXT_VALUE_CHANGED)); |
588 TextEvent.TEXT_VALUE_CHANGED)); |
591 } |
589 } |
592 } |
590 } |
593 |
591 |
594 @Override |
592 @Override |
595 public void changedUpdate(DocumentEvent e) { |
593 public void changedUpdate(DocumentEvent e) { |
596 if (peer != null) { |
594 if (xwin != null) { |
597 peer.postEvent(new TextEvent(peer.target, |
595 xwin.postEvent(new TextEvent(xwin.target, |
598 TextEvent.TEXT_VALUE_CHANGED)); |
596 TextEvent.TEXT_VALUE_CHANGED)); |
599 } |
597 } |
600 } |
|
601 |
|
602 @Override |
|
603 @SuppressWarnings("deprecation") |
|
604 public ComponentPeer getPeer() { |
|
605 return (ComponentPeer) peer; |
|
606 } |
598 } |
607 |
599 |
608 public void repaintNow() { |
600 public void repaintNow() { |
609 paintImmediately(getBounds()); |
601 paintImmediately(getBounds()); |
610 } |
602 } |
611 |
603 |
612 @Override |
604 @Override |
613 public Graphics getGraphics() { |
605 public Graphics getGraphics() { |
614 return peer.getGraphics(); |
606 return xwin.getGraphics(); |
615 } |
607 } |
616 |
608 |
617 @Override |
609 @Override |
618 public void updateUI() { |
610 public void updateUI() { |
619 ComponentUI ui = new AWTTextFieldUI(); |
611 ComponentUI ui = new AWTTextFieldUI(); |