home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 25 / CDROM25.iso / Share / prog / VJ11 / VJTRIAL.EXE / IE30Java.exe / classd.exe / sun / awt / win32 / MTextAreaPeer.java < prev    next >
Encoding:
Java Source  |  1997-01-27  |  2.6 KB  |  82 lines

  1. /*
  2.  * @(#)MTextAreaPeer.java    1.9 96/04/02 Sami Shaio
  3.  *
  4.  * Copyright (c) 1995 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19.  
  20. package sun.awt.win32;
  21.  
  22. import java.awt.*;
  23. import java.awt.peer.*;
  24.  
  25. public class MTextAreaPeer extends MComponentPeer implements TextAreaPeer {
  26.  
  27.     int verticalScrollWidth;        // set by create()
  28.     int horizontalScrollHeight;        // set by create()
  29.  
  30.     native void create(MComponentPeer parent);
  31.  
  32.     void initialize() {
  33.     TextArea txt = (TextArea)target;
  34.     String    text;
  35.  
  36.     if ((text = txt.getText()) != null) {
  37.         setText(text);
  38.     }
  39.     select(txt.getSelectionStart(), txt.getSelectionEnd());
  40.     setEditable(txt.isEditable());
  41.  
  42.     super.initialize();
  43.     }
  44.  
  45.     public MTextAreaPeer(TextArea target) {
  46.     super(target);
  47.     }
  48.  
  49.     public void setEditable(boolean editable) {
  50.     pSetEditable(editable);
  51.     setBackground(target.getBackground());
  52.     }
  53.     public void setBackground(Color c) {
  54.     TextArea t = (TextArea)target;
  55.     if (t.isEditable()) {
  56.         c = c.brighter();
  57.     }
  58.     super.setBackground(c);
  59.     }
  60.  
  61.     public native void pSetEditable(boolean e);
  62.     public native void select(int selStart, int selEnd);
  63.     public native int getSelectionStart();
  64.     public native int getSelectionEnd();
  65.     public native void setText(String txt);
  66.     public native String getText();
  67.     public native void insertText(String txt, int pos);
  68.     public native void replaceText(String txt, int start, int end);
  69.  
  70.     public Dimension minimumSize() {
  71.     return minimumSize(10, 60);
  72.     }
  73.     public Dimension preferredSize(int rows, int cols) {
  74.     return minimumSize(rows, cols);
  75.     }
  76.     public Dimension minimumSize(int rows, int cols) {
  77.     FontMetrics fm = getFontMetrics(target.getFont());
  78.     return new Dimension(fm.charWidth('0') * cols + verticalScrollWidth, 
  79.                              fm.getHeight() * rows + horizontalScrollHeight);
  80.     }
  81. }
  82.