JavaFX TextArea set editable
import javafx.application.Application; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.CheckBox; import javafx.scene.control.ScrollPane; import javafx.scene.control.TextArea; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.stage.Stage; public class Main extends Application { @Override/*from w w w. j a va 2s. co m*/ public void start(Stage primaryStage) { // Create a text area TextArea textArea = new TextArea(); textArea.setEditable(false); textArea.setWrapText(false); // Create a scrollPane ScrollPane scrollPane = new ScrollPane(textArea); // Create two check boxes CheckBox chkEditable = new CheckBox("Editable"); CheckBox chkWrap = new CheckBox("Wrap"); // Create a hbox HBox paneForButtons = new HBox(5); paneForButtons.setAlignment(Pos.CENTER); paneForButtons.getChildren().addAll(chkEditable, chkWrap); // Create a pane BorderPane pane = new BorderPane(); pane.setCenter(scrollPane); pane.setBottom(paneForButtons); // Create and register handlers chkEditable.setOnAction(e -> { textArea.setEditable(chkEditable.isSelected()); }); chkWrap.setOnAction(e -> { textArea.setWrapText(chkWrap.isSelected()); }); // Create a scene and place it in the stage Scene scene = new Scene(pane); primaryStage.setTitle("java2s.com"); primaryStage.setScene(scene); primaryStage.show(); } }