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.ActionEvent;
28 import javafx.event.Event;
29 import javafx.event.EventHandler;
30 import javafx.scene.Scene;
31 import javafx.scene.control.Button;
32 import javafx.scene.control.ButtonBuilder;
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 TextFieldPropertiesApp extends TextControlApp {
41 public final static String SET_ON_ACTION_BUTTON_ID = "SET_ON_ACTION_BUTTON_ID";
42 public final static String ON_ACTION_COUNTER = "ON_ACTION_COUNTER";
43
44 public static void main(String[] args) {
45 Utils.launch(TextFieldPropertiesApp.class, args);
46 }
47
48 @Override
49 protected Scene getScene() {
50 setTitle();
51 return new TextFieldScene();
52 }
53
62 protected void addControlDependentProperties() {
63 tb.addCounter(ON_ACTION_COUNTER);
64 }
65
66 @Override
67 public void resetControl() {
68 TextField fresh = new TextField();
69 TextField tested = (TextField) testedTextInput;
70 tested.setPrefWidth(fresh.getPrefWidth());
71 tested.setPrefHeight(fresh.getPrefHeight());
72 tested.setDisable(fresh.isDisable());
73 tested.setEditable(fresh.isEditable());
74 tested.setPrefColumnCount(fresh.getPrefColumnCount());
75 tested.setText(fresh.getText());
76 tested.setPromptText(fresh.getPromptText());
77 tested.setFocusTraversable(fresh.isFocusTraversable());
78 }
79
80 @Override
81 public void addControlSpecificButtons(Pane pane) {
82 Button setOnActionListenerButton = ButtonBuilder.create().id(SET_ON_ACTION_BUTTON_ID).text("Set on action listener").build();
83 setOnActionListenerButton.setOnAction(new EventHandler() {
84
85 public void handle(Event t) {
86 ((TextField) testedTextInput).onActionProperty().setValue(new EventHandler<ActionEvent>() {
87
88 public void handle(ActionEvent t) {
89 tb.incrementCounter(ON_ACTION_COUNTER);
90 }
91 });
92 }
93 });
94
95 Button addTextButton = ButtonBuilder.create().id(ADD_TEXT_BUTTON_ID).text("Add \"sometext\"").build();
96 addTextButton.setOnAction(new EventHandler() {
97
98 public void handle(Event t) {
99 testedTextInput.setText(testedTextInput.getText() + "some\ntext");
100 }
101 });
102
103 pane.getChildren().addAll(setOnActionListenerButton, addTextButton);
104 }
105 }
106 }
|
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.ActionEvent;
28 import javafx.event.Event;
29 import javafx.event.EventHandler;
30 import javafx.scene.Scene;
31 import javafx.scene.control.Button;
32 import javafx.scene.control.TextField;
33 import static javafx.scene.control.test.textinput.TextControlApp.ADD_TEXT_BUTTON_ID;
34 import javafx.scene.layout.Pane;
35 import test.javaclient.shared.Utils;
36
37 /**
38 * @author Alexander Kirov
39 */
40 public class TextFieldPropertiesApp extends TextControlApp {
41 public final static String SET_ON_ACTION_BUTTON_ID = "SET_ON_ACTION_BUTTON_ID";
42 public final static String ON_ACTION_COUNTER = "ON_ACTION_COUNTER";
43
44 public static void main(String[] args) {
45 Utils.launch(TextFieldPropertiesApp.class, args);
46 }
47
48 @Override
49 protected Scene getScene() {
50 setTitle();
51 return new TextFieldScene();
52 }
53
62 protected void addControlDependentProperties() {
63 tb.addCounter(ON_ACTION_COUNTER);
64 }
65
66 @Override
67 public void resetControl() {
68 TextField fresh = new TextField();
69 TextField tested = (TextField) testedTextInput;
70 tested.setPrefWidth(fresh.getPrefWidth());
71 tested.setPrefHeight(fresh.getPrefHeight());
72 tested.setDisable(fresh.isDisable());
73 tested.setEditable(fresh.isEditable());
74 tested.setPrefColumnCount(fresh.getPrefColumnCount());
75 tested.setText(fresh.getText());
76 tested.setPromptText(fresh.getPromptText());
77 tested.setFocusTraversable(fresh.isFocusTraversable());
78 }
79
80 @Override
81 public void addControlSpecificButtons(Pane pane) {
82 Button setOnActionListenerButton = new Button("Set on action listener");
83 setOnActionListenerButton.setId(SET_ON_ACTION_BUTTON_ID);
84 setOnActionListenerButton.setOnAction(new EventHandler() {
85
86 public void handle(Event t) {
87 ((TextField) testedTextInput).onActionProperty().setValue(new EventHandler<ActionEvent>() {
88
89 public void handle(ActionEvent t) {
90 tb.incrementCounter(ON_ACTION_COUNTER);
91 }
92 });
93 }
94 });
95
96 Button addTextButton = new Button("Add \"sometext\"");
97 addTextButton.setId(ADD_TEXT_BUTTON_ID);
98 addTextButton.setOnAction(new EventHandler() {
99
100 public void handle(Event t) {
101 testedTextInput.setText(testedTextInput.getText() + "some\ntext");
102 }
103 });
104
105 pane.getChildren().addAll(setOnActionListenerButton, addTextButton);
106 }
107 }
108 }
|