You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JavaFX TextArea contains two methods setText and appendText. Test code:
public class JavaFxTest10 extends Application {
@Override
public void start(Stage primaryStage) {
var t = "Some text.\nSome text.\nSome text.\nSome text.\nSome text.\nSome text.\nSome text.\nSome text.\nSome text.";
var textArea = new TextArea();
var setButton = new Button("Set");
setButton.setOnAction(e -> textArea.setText(t));
var appendButton = new Button("Append");
appendButton.setOnAction(e -> textArea.appendText(t));
var clearButton = new Button("Clear");
clearButton.setOnAction(e -> textArea.clear());
VBox vbox = new VBox(textArea, new HBox(setButton, appendButton, clearButton));
Scene scene = new Scene(vbox, 300, 100);
primaryStage.setScene(scene);
primaryStage.setTitle("TableView Binding Test");//yes, that's wrong title
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Result:
Currently RichTextFX areas don't have setText method, that sets new text and doesn't scroll to bottom, that's why it is necessary to use something like this:
or to use custom class that extends InlineCssTextArea. I suggest to provide this feature out of box.
The second feature is related to set text. I suggest to make textProperty as a normal not readonly StringProperty. For example, this problem is well visible when MVVM pattern is used. When in ViewModel we need to get current value, process it and replace with new value. It should be this way
public class ViewModel {
private final StringProperty text = new SimpleStringProperty();
...
public void doIt() {
var text = text.get();
text = doSomething(text);
text.set(text);
}
}
and
public class View {
private final InlineCssTextArea textArea = new InlineCssTextArea();
....
this.textArea.textProperty().bindBidirectional(viewModel.textProperty());
}
The text was updated successfully, but these errors were encountered:
JavaFX TextArea contains two methods setText and appendText. Test code:
Result:
Currently RichTextFX areas don't have setText method, that sets new text and doesn't scroll to bottom, that's why it is necessary to use something like this:
or to use custom class that extends InlineCssTextArea. I suggest to provide this feature out of box.
The second feature is related to set text. I suggest to make textProperty as a normal not readonly StringProperty. For example, this problem is well visible when MVVM pattern is used. When in ViewModel we need to get current value, process it and replace with new value. It should be this way
and
The text was updated successfully, but these errors were encountered: