-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathTextFieldDemo.java
38 lines (31 loc) · 1.01 KB
/
TextFieldDemo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package chapter_sixteen.samples;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
/**
* Listing 16.5 TextFieldDemo.java
*/
public class TextFieldDemo extends RadioButtonDemo
{
@Override // Override the getPane() method in the super class
protected BorderPane getPane()
{
BorderPane pane = super.getPane();
BorderPane paneForTextField = new BorderPane();
paneForTextField.setPadding(new Insets(5, 5, 5, 5));
paneForTextField.setStyle("−fx−border−color: green");
paneForTextField.setLeft(new Label("Enter a new message: "));
TextField tf = new TextField();
tf.setAlignment(Pos.BOTTOM_RIGHT);
paneForTextField.setCenter(tf);
pane.setTop(paneForTextField);
tf.setOnAction(e -> text.setText(tf.getText()));
return pane;
}
public static void main(String[] args)
{
launch(args);
}
}