/** @see java.awt.peer.TextComponentPeer */
 @Override
 public void select(int s, int e) {
   xtext.select(s, e);
   // Fixed 5100806
   // We must take care that Swing components repainted correctly
   xtext.repaint();
 }
 /** Deselects the highlighted text. */
 public void deselect() {
   int selStart = xtext.getSelectionStart();
   int selEnd = xtext.getSelectionEnd();
   if (selStart != selEnd) {
     xtext.select(selStart, selStart);
   }
 }
 @Override
 public void setBounds(int x, int y, int width, int height, int op) {
   super.setBounds(x, y, width, height, op);
   if (xtext != null) {
     /*
      * Fixed 6277332, 6198290:
      * the coordinates is coming (to peer): relatively to closest HW parent
      * the coordinates is setting (to textField): relatively to closest ANY parent
      * the parent of peer is target.getParent()
      * the parent of textField is the same
      * see 6277332, 6198290 for more information
      */
     int childX = x;
     int childY = y;
     Component parent = target.getParent();
     // we up to heavyweight parent in order to be sure
     // that the coordinates of the text pane is relatively to closest parent
     while (parent.isLightweight()) {
       childX -= parent.getX();
       childY -= parent.getY();
       parent = parent.getParent();
     }
     xtext.setBounds(childX, childY, width, height);
     xtext.validate();
   }
 }
 @Override
 public Dimension getMinimumSize(int cols) {
   Font f = xtext.getFont();
   FontMetrics fm = xtext.getFontMetrics(f);
   return new Dimension(
       fm.charWidth('0') * cols + 10, fm.getMaxDescent() + fm.getMaxAscent() + PADDING);
 }
  XTextFieldPeer(TextField target) {
    super(target);
    text = target.getText();
    xtext = new XAWTTextField(text, this, target.getParent());
    xtext.getDocument().addDocumentListener(xtext);
    xtext.setCursor(target.getCursor());
    XToolkit.specialPeerMap.put(xtext, this);

    initTextField();
    setText(target.getText());
    if (target.echoCharIsSet()) {
      setEchoChar(target.getEchoChar());
    } else setEchoChar((char) 0);

    int start = target.getSelectionStart();
    int end = target.getSelectionEnd();
    // Fix for 5100200
    // Restoring Motif behaviour
    // Since the end position of the selected text can be greater than the length of the text,
    // so we should set caret to max position of the text
    setCaretPosition(Math.min(end, text.length()));
    if (end > start) {
      // Should be called after setText() and setCaretPosition()
      select(start, end);
    }

    setEditable(target.isEditable());

    // After this line we should not change the component's text
    firstChangeSkipped = true;
    AWTAccessor.getComponentAccessor().setPeer(xtext, this);
  }
 /** @see java.awt.peer.TextComponentPeer */
 @Override
 public void setEditable(boolean editable) {
   if (xtext != null) {
     xtext.setEditable(editable);
     xtext.repaint();
   }
 }
 /** @see java.awt.peer.ComponentPeer */
 @Override
 public void setEnabled(boolean enabled) {
   super.setEnabled(enabled);
   if (xtext != null) {
     xtext.setEnabled(enabled);
     xtext.repaint();
   }
 }
 /** @see java.awt.peer.TextFieldPeer */
 @Override
 public void setEchoChar(char c) {
   if (xtext != null) {
     xtext.setEchoChar(c);
     xtext.putClientProperty(
         "JPasswordField.cutCopyAllowed", xtext.echoCharIsSet() ? Boolean.FALSE : Boolean.TRUE);
   }
 }
 @Override
 public void setFont(Font f) {
   synchronized (getStateLock()) {
     font = f;
     if (xtext != null && xtext.getFont() != f) {
       xtext.setFont(font);
     }
   }
   xtext.validate();
 }
Exemple #10
0
 @Override
 public void handleJavaMouseEvent(MouseEvent mouseEvent) {
   super.handleJavaMouseEvent(mouseEvent);
   if (xtext != null) {
     mouseEvent.setSource(xtext);
     int id = mouseEvent.getID();
     if (id == MouseEvent.MOUSE_DRAGGED || id == MouseEvent.MOUSE_MOVED)
       xtext.processMouseMotionEventImpl(mouseEvent);
     else xtext.processMouseEventImpl(mouseEvent);
   }
 }
Exemple #11
0
 @Override
 public void setForeground(Color c) {
   foreground = c;
   if (xtext != null) {
     if (xtext.getForeground() != c) {
       xtext.setForeground(foreground);
     }
     xtext.setSelectionColor(foreground);
     xtext.setCaretColor(foreground);
   }
   repaintText();
 }
Exemple #12
0
 @Override
 public void setBackground(Color c) {
   if (log.isLoggable(PlatformLogger.Level.FINE)) {
     log.fine("target=" + target + ", old=" + background + ", new=" + c);
   }
   background = c;
   if (xtext != null) {
     if (xtext.getBackground() != c) {
       xtext.setBackground(c);
     }
     xtext.setSelectedTextColor(c);
   }
   repaintText();
 }
Exemple #13
0
 private void setXAWTTextField(String txt) {
   text = txt;
   if (xtext != null) {
     // JTextField.setText() posts two different events (remove & insert).
     // Since we make no differences between text events,
     // the document listener has to be disabled while
     // JTextField.setText() is called.
     xtext.getDocument().removeDocumentListener(xtext);
     xtext.setText(txt);
     if (firstChangeSkipped) {
       postEvent(new TextEvent(target, TextEvent.TEXT_VALUE_CHANGED));
     }
     xtext.getDocument().addDocumentListener(xtext);
     xtext.setCaretPosition(0);
   }
 }
Exemple #14
0
 @Override
 public void dispose() {
   XToolkit.specialPeerMap.remove(xtext);
   // visible caret has a timer thread which must be stopped
   xtext.getCaret().setVisible(false);
   super.dispose();
 }
Exemple #15
0
 /**
  * to be implemented.
  *
  * @see java.awt.peer.TextComponentPeer
  */
 @Override
 public int getCaretPosition() {
   return xtext.getCaretPosition();
 }
Exemple #16
0
 @Override
 void handleJavaInputMethodEvent(InputMethodEvent e) {
   if (xtext != null) xtext.processInputMethodEventImpl(e);
 }
Exemple #17
0
 /** @see java.awt.peer.TextComponentPeer */
 @Override
 public InputMethodRequests getInputMethodRequests() {
   if (xtext != null) return xtext.getInputMethodRequests();
   else return null;
 }
Exemple #18
0
 /** @see java.awt.peer.TextComponentPeer */
 @Override
 public int getSelectionStart() {
   return xtext.getSelectionStart();
 }
Exemple #19
0
 @Override
 public void setVisible(boolean b) {
   super.setVisible(b);
   if (xtext != null) xtext.setVisible(b);
 }
Exemple #20
0
 @Override
 public void focusLost(FocusEvent e) {
   super.focusLost(e);
   xtext.forwardFocusLost(e);
 }
Exemple #21
0
 @Override
 public void focusGained(FocusEvent e) {
   super.focusGained(e);
   xtext.forwardFocusGained(e);
 }
Exemple #22
0
 @Override
 void paintPeer(final Graphics g) {
   if (xtext != null) xtext.paint(g);
 }
Exemple #23
0
 @Override
 public void print(Graphics g) {
   if (xtext != null) {
     xtext.print(g);
   }
 }
Exemple #24
0
 /** @see java.awt.peer.TextComponentPeer */
 @Override
 public int getSelectionEnd() {
   return xtext.getSelectionEnd();
 }
Exemple #25
0
 @Override
 public void repaint() {
   if (xtext != null) xtext.repaint();
 }
Exemple #26
0
 @Override
 public Dimension getPreferredSize() {
   return xtext.getPreferredSize();
 }
Exemple #27
0
 @Override
 public Dimension getMinimumSize() {
   return xtext.getMinimumSize();
 }
Exemple #28
0
 /** @see java.awt.peer.TextComponentPeer */
 @Override
 @SuppressWarnings("deprecation")
 public String getText() {
   return xtext.getText();
 }
Exemple #29
0
 /**
  * to be implemented.
  *
  * @see java.awt.peer.TextComponentPeer
  */
 @Override
 public void setCaretPosition(int position) {
   if (xtext != null) xtext.setCaretPosition(position);
 }
Exemple #30
0
 void repaintText() {
   xtext.repaintNow();
 }