< prev index next >

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

Print this page




  78             setEchoChar(target.getEchoChar());
  79         }
  80         else setEchoChar((char)0);
  81 
  82         int start = target.getSelectionStart();
  83         int end = target.getSelectionEnd();
  84         // Fix for 5100200
  85         // Restoring Motif behaviour
  86         // Since the end position of the selected text can be greater then the length of the text,
  87         // so we should set caret to max position of the text
  88         setCaretPosition(Math.min(end, text.length()));
  89         if (end > start) {
  90             // Should be called after setText() and setCaretPosition()
  91             select(start, end);
  92         }
  93 
  94         setEditable(target.isEditable());
  95 
  96         // After this line we should not change the component's text
  97         firstChangeSkipped = true;

  98     }
  99 
 100     @Override
 101     public void dispose() {
 102         XToolkit.specialPeerMap.remove(xtext);
 103         // visible caret has a timer thread which must be stopped
 104         xtext.getCaret().setVisible(false);
 105         xtext.removeNotify();
 106         super.dispose();
 107     }
 108 
 109     void initTextField() {
 110         setVisible(target.isVisible());
 111 
 112         setBounds(x, y, width, height, SET_BOUNDS);
 113 
 114         AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
 115         foreground = compAccessor.getForeground(target);
 116         if (foreground == null)
 117             foreground = SystemColor.textText;
 118 
 119         setForeground(foreground);
 120 
 121         background = compAccessor.getBackground(target);
 122         if (background == null) {
 123             if (((TextField)target).isEditable()) background = SystemColor.text;
 124             else background = SystemColor.control;
 125         }




  78             setEchoChar(target.getEchoChar());
  79         }
  80         else setEchoChar((char)0);
  81 
  82         int start = target.getSelectionStart();
  83         int end = target.getSelectionEnd();
  84         // Fix for 5100200
  85         // Restoring Motif behaviour
  86         // Since the end position of the selected text can be greater then the length of the text,
  87         // so we should set caret to max position of the text
  88         setCaretPosition(Math.min(end, text.length()));
  89         if (end > start) {
  90             // Should be called after setText() and setCaretPosition()
  91             select(start, end);
  92         }
  93 
  94         setEditable(target.isEditable());
  95 
  96         // After this line we should not change the component's text
  97         firstChangeSkipped = true;
  98         AWTAccessor.getComponentAccessor().setPeer(xtext, this);
  99     }
 100 
 101     @Override
 102     public void dispose() {
 103         XToolkit.specialPeerMap.remove(xtext);
 104         // visible caret has a timer thread which must be stopped
 105         xtext.getCaret().setVisible(false);

 106         super.dispose();
 107     }
 108 
 109     void initTextField() {
 110         setVisible(target.isVisible());
 111 
 112         setBounds(x, y, width, height, SET_BOUNDS);
 113 
 114         AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
 115         foreground = compAccessor.getForeground(target);
 116         if (foreground == null)
 117             foreground = SystemColor.textText;
 118 
 119         setForeground(foreground);
 120 
 121         background = compAccessor.getBackground(target);
 122         if (background == null) {
 123             if (((TextField)target).isEditable()) background = SystemColor.text;
 124             else background = SystemColor.control;
 125         }


< prev index next >