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