GUI( JavaFX Scene Builder )/Control
TextArea
pms93
2022. 8. 18. 14:51
package controls;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.TextArea;
import javafx.scene.layout.HBox;
import javafx.scene.text.Font;
import javafx.stage.Stage;
public class TextAreaEx extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
// TextArea
// - text를 작성할 수 있는 영역 생성
// - 영역 내 글자가 기존 사이즈를 초과할시에 자동으로 공간을 늘려준다.
TextArea ta = new TextArea();
ta.setMaxSize(300, 150);
// .setText() 를 통해서 실행시 보여질 text입력이 가능
ta.setText("내용 입력");
// .setFont() 를 통해 font size 조절 가능
ta.setFont(new Font(25));
HBox hbox = new HBox();
hbox.getChildren().add(ta);
hbox.setAlignment(Pos.CENTER);
primaryStage.setScene(new Scene(hbox, 400, 200));
primaryStage.show();
}
}