1 /*
   2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation. Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package javafx.scene.control.test.textinput;
  26 
  27 import javafx.event.Event;
  28 import javafx.event.EventHandler;
  29 import javafx.scene.Scene;
  30 import javafx.scene.control.Button;

  31 import javafx.scene.control.TextArea;

  32 import javafx.scene.layout.Pane;
  33 import test.javaclient.shared.Utils;
  34 
  35 /**
  36  * @author Alexander Kirov
  37  */
  38 public class TextAreaPropertiesApp extends TextControlApp {
  39     public static void main(String[] args) {
  40         Utils.launch(TextAreaPropertiesApp.class, args);
  41     }
  42 
  43     @Override
  44     protected Scene getScene() {
  45         setTitle();
  46         return new TextAreaScene();
  47     }
  48 
  49     public class TextAreaScene extends TextInputScene {
  50 
  51         @Override
  52         public void setNewControl() {
  53             testedTextInput = new TextArea();
  54         }
  55 
  56         @Override
  57         public void resetControl() {
  58             TextArea fresh = new TextArea();
  59             TextArea tested = (TextArea) testedTextInput;
  60             tested.setPrefWidth(fresh.getPrefWidth());
  61             tested.setPrefHeight(fresh.getPrefHeight());
  62             tested.setDisable(fresh.isDisable());
  63             tested.setEditable(fresh.isEditable());
  64             tested.setPrefColumnCount(fresh.getPrefColumnCount());
  65             tested.setPrefRowCount(fresh.getPrefRowCount());
  66             tested.setText(fresh.getText());
  67             tested.setFocusTraversable(fresh.isFocusTraversable());
  68             tested.setWrapText(fresh.isWrapText());
  69         }
  70 
  71         @Override
  72         public void addControlSpecificButtons(Pane pane) {
  73             Button button = new Button("Add much text");
  74             button.setId(ADD_TEXT_BUTTON_ID);
  75             button.setOnAction(new EventHandler() {
  76 
  77                 public void handle(Event t) {
  78                     for (int i = 0; i < 1000; i++) {
  79                         TextArea ta = (TextArea) testedTextInput;
  80                         ta.setText(ta.getText() + " some text");
  81                         if (i % 10 == 0) {
  82                             ta.setText(ta.getText() + "\n");
  83                         }
  84                     }
  85                 }
  86             });
  87             pane.getChildren().add(button);
  88         }
  89 
  90         @Override
  91         protected void addControlDependentProperties() {
  92             TextArea textArea = (TextArea) testedTextInput;
  93             tb.addSimpleListener(textArea.focusedProperty(), textArea);
  94         }
  95     }
  96 }
--- EOF ---