home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / solaris2 / jdk / src / java / awt / test / textarea.jav < prev    next >
Encoding:
Text File  |  1995-10-30  |  2.1 KB  |  78 lines

  1. /*
  2.  * @(#)TextAreaTest.java    1.2 95/08/07 Arthur van Hoff
  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. import java.awt.*;
  21.  
  22. /**
  23.  * A test of a Container with BorderLayout.
  24.  */
  25. public class TextAreaTest extends Frame {
  26.     TextArea t1;
  27.     TextArea t2;
  28.  
  29.     public TextAreaTest() {
  30.     super("TextAreaTest");
  31.     add("North", t1 = new TextArea(4, 40));
  32.     t1.setForeground(Color.blue);
  33.     t1.setEditable(false);
  34.     add("Center", t2 = new TextArea(10, 40));
  35.     t2.setFont(new Font("Helvetica", Font.BOLD, 18));
  36.     Panel p = new Panel();
  37.     p.add(new Button("clear"));
  38.     p.add(new Button("reset"));
  39.     p.add(new Button("select"));
  40.     p.add(new Button("print"));
  41.     add("South", p);
  42.     move(200, 100);
  43.     pack();
  44.     show();
  45.     }
  46.  
  47.     public boolean handleEvent(Event evt) {
  48.     if (evt.id == Event.ACTION_EVENT) {
  49.         if ("clear".equals(evt.arg)) {
  50.         t1.setText("");
  51.         t2.setText("");
  52.         return true;
  53.         }
  54.         if ("reset".equals(evt.arg)) {
  55.         t1.setText("Arthur van Hoff");
  56.         t2.setText("Sami Shaio");
  57.         return true;
  58.         }
  59.         if ("select".equals(evt.arg)) {
  60.         t2.selectAll();
  61.         return true;
  62.         }
  63.         if ("print".equals(evt.arg)) {
  64.         System.out.println("-- values --");
  65.         System.out.println("text=" + t1.getText());
  66.         System.out.println("text=" + t2.getText());
  67.         return true;
  68.         }
  69.     }
  70.     System.out.println(evt.toString());
  71.     return true;
  72.     }
  73.  
  74.     public static void main(String args[]) {
  75.     new TextAreaTest();
  76.     }
  77. }
  78.