GUI( JavaFX Scene Builder )/Control
TextField
by pms93
2022. 8. 18.
package controls;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class TextFieldEx extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
// TextField
// - 생성자 혹은 .setText() 매서드를 통해 textfield에 미리 문자열을 준비해둘 수 있다.
TextField tf1 = new TextField("아이디"), tf2 = new TextField("이름");
tf1.setMaxSize(180, 60);
tf2.setMaxSize(180, 60);
tf1.setText("ID");
tf2.setText("PW");
VBox vbox = new VBox(20);
vbox.getChildren().addAll(tf1, tf2);
vbox.setAlignment(Pos.CENTER);
vbox.setPrefSize(400, 400);
primaryStage.setScene(new Scene(vbox));
primaryStage.show();
}
}