jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java
changeset 4371 dc9dcb8b0ae7
parent 2 90ce3da70b43
child 5506 202f599c92aa
equal deleted inserted replaced
4369:18b883ed2b58 4371:dc9dcb8b0ae7
    58 import javax.swing.text.JTextComponent;
    58 import javax.swing.text.JTextComponent;
    59 
    59 
    60 import javax.swing.plaf.BorderUIResource;
    60 import javax.swing.plaf.BorderUIResource;
    61 import java.awt.im.InputMethodRequests;
    61 import java.awt.im.InputMethodRequests;
    62 import sun.awt.CausedFocusEvent;
    62 import sun.awt.CausedFocusEvent;
    63 import sun.awt.ComponentAccessor;
    63 import sun.awt.AWTAccessor;
    64 
    64 
    65 
    65 
    66 class XTextAreaPeer extends XComponentPeer implements TextAreaPeer {
    66 class XTextAreaPeer extends XComponentPeer implements TextAreaPeer {
    67     boolean editable;
    67     boolean editable;
    68 
    68 
   117 
   117 
   118         setBounds(x, y, width, height, SET_BOUNDS);
   118         setBounds(x, y, width, height, SET_BOUNDS);
   119         textPane.setVisible(true);
   119         textPane.setVisible(true);
   120         textPane.validate();
   120         textPane.validate();
   121 
   121 
   122         foreground = ComponentAccessor.getForeground(target);
   122         AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
       
   123         foreground = compAccessor.getForeground(target);
   123         if (foreground == null)  {
   124         if (foreground == null)  {
   124             foreground = SystemColor.textText;
   125             foreground = SystemColor.textText;
   125         }
   126         }
   126         setForeground(foreground);
   127         setForeground(foreground);
   127 
   128 
   128         background = ComponentAccessor.getBackground(target);
   129         background = compAccessor.getBackground(target);
   129         if (background == null) {
   130         if (background == null) {
   130             if (target.isEditable()) background = SystemColor.text;
   131             if (target.isEditable()) background = SystemColor.text;
   131             else background = SystemColor.control;
   132             else background = SystemColor.control;
   132         }
   133         }
   133         setBackground(background);
   134         setBackground(background);
   134 
   135 
   135         if (!target.isBackgroundSet()) {
   136         if (!target.isBackgroundSet()) {
   136             // This is a way to set the background color of the TextArea
   137             // This is a way to set the background color of the TextArea
   137             // without calling setBackground - go through reflection
   138             // without calling setBackground - go through accessor
   138             ComponentAccessor.setBackground(target, background);
   139             compAccessor.setBackground(target, background);
   139         }
   140         }
   140         if (!target.isForegroundSet()) {
   141         if (!target.isForegroundSet()) {
   141             target.setForeground(SystemColor.textText);
   142             target.setForeground(SystemColor.textText);
   142         }
   143         }
   143 
   144 
   309             textPane.validate();
   310             textPane.validate();
   310         }
   311         }
   311     }
   312     }
   312 
   313 
   313     void handleJavaKeyEvent(KeyEvent e) {
   314     void handleJavaKeyEvent(KeyEvent e) {
   314         ComponentAccessor.processEvent(jtext,e);
   315         AWTAccessor.getComponentAccessor().processEvent(jtext,e);
   315     }
   316     }
   316 
   317 
   317     public boolean handlesWheelScrolling() { return true; }
   318     public boolean handlesWheelScrolling() { return true; }
   318 
   319 
   319     void handleJavaMouseWheelEvent(MouseWheelEvent e) {
   320     void handleJavaMouseWheelEvent(MouseWheelEvent e) {
   320         ComponentAccessor.processEvent(textPane,e);
   321         AWTAccessor.getComponentAccessor().processEvent(textPane,e);
   321     }
   322     }
   322 
   323 
   323     public void handleJavaMouseEvent( MouseEvent e ) {
   324     public void handleJavaMouseEvent( MouseEvent e ) {
   324         super.handleJavaMouseEvent( e );
   325         super.handleJavaMouseEvent( e );
   325         javaMouseEventHandler.handle( e );
   326         javaMouseEventHandler.handle( e );
  1109         public AWTTextPane(JTextArea jt, XWindow xwin, Container parent) {
  1110         public AWTTextPane(JTextArea jt, XWindow xwin, Container parent) {
  1110             super(jt);
  1111             super(jt);
  1111             this.xwin = xwin;
  1112             this.xwin = xwin;
  1112             setDoubleBuffered(true);
  1113             setDoubleBuffered(true);
  1113             jt.addFocusListener(this);
  1114             jt.addFocusListener(this);
  1114             ComponentAccessor.setParent(this,parent);
  1115             AWTAccessor.getComponentAccessor().setParent(this,parent);
  1115             setViewportBorder(new BevelBorder(false,SystemColor.controlDkShadow,SystemColor.controlLtHighlight) );
  1116             setViewportBorder(new BevelBorder(false,SystemColor.controlDkShadow,SystemColor.controlLtHighlight) );
  1116             this.jtext = jt;
  1117             this.jtext = jt;
  1117             setFocusable(false);
  1118             setFocusable(false);
  1118             addNotify();
  1119             addNotify();
  1119         }
  1120         }
  1306                     Point p = toLocalSpace( c, event.getPoint() );
  1307                     Point p = toLocalSpace( c, event.getPoint() );
  1307                     if ( current.getType()==Pointer.Type.BUTTON ) {
  1308                     if ( current.getType()==Pointer.Type.BUTTON ) {
  1308                         c = current.getButton();
  1309                         c = current.getButton();
  1309                         p = toLocalSpace( c, p );
  1310                         p = toLocalSpace( c, p );
  1310                     }
  1311                     }
  1311                     ComponentAccessor.processEvent( c, newMouseEvent( c, p, event ) );
  1312                     AWTAccessor.getComponentAccessor().processEvent( c, newMouseEvent( c, p, event ) );
  1312                     break;
  1313                     break;
  1313             }
  1314             }
  1314         }
  1315         }
  1315 
  1316 
  1316         private static MouseEvent newMouseEvent(
  1317         private static MouseEvent newMouseEvent(