Code:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Slider;
import javafx.scene.control.SliderBuilder;
import javafx.scene.control.TextArea;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
/**
* @author alexandr_kirov
*/
public class JavaFX_TextArea_PrefCount extends Application {
public static void main(String[] args) {
launch();
}
@Override
public void start(Stage stage) throws Exception {
final TextArea ta = new TextArea();
ta.setWrapText(true);
for (int i = 0; i < 1000; i++) {
ta.setText(ta.getText() + " some text");
if (i % 10 == 0) {
ta.setText(ta.getText() + "\n");
}
}
final Slider s1 = SliderBuilder.create().max(200).min(0).value(10).majorTickUnit(50).minorTickCount(49).showTickLabels(true).showTickMarks(true).build();
final Slider s2 = SliderBuilder.create().max(200).min(0).value(10).majorTickUnit(50).minorTickCount(49).showTickLabels(true).showTickMarks(true).build();
ta.prefColumnCountProperty().bind(s1.valueProperty());
ta.prefRowCountProperty().bind(s2.valueProperty());
Pane pane = new Pane();
pane.setPrefWidth(200);
pane.setPrefHeight(200);
pane.getChildren().addAll(ta);
VBox vb = new VBox(5);
vb.getChildren().addAll(pane, s1, s2);
Scene scene = new Scene(vb, 300, 300);
stage.setScene(scene);
stage.show();
}
}
Steps to reproduce:
Change values of sliders and try to resize scene window. Changes will be applied only after window resize. Try to change pref counts again and resize window again. It doesn't help now.
Also see attached movie.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Slider;
import javafx.scene.control.SliderBuilder;
import javafx.scene.control.TextArea;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
/**
* @author alexandr_kirov
*/
public class JavaFX_TextArea_PrefCount extends Application {
public static void main(String[] args) {
launch();
}
@Override
public void start(Stage stage) throws Exception {
final TextArea ta = new TextArea();
ta.setWrapText(true);
for (int i = 0; i < 1000; i++) {
ta.setText(ta.getText() + " some text");
if (i % 10 == 0) {
ta.setText(ta.getText() + "\n");
}
}
final Slider s1 = SliderBuilder.create().max(200).min(0).value(10).majorTickUnit(50).minorTickCount(49).showTickLabels(true).showTickMarks(true).build();
final Slider s2 = SliderBuilder.create().max(200).min(0).value(10).majorTickUnit(50).minorTickCount(49).showTickLabels(true).showTickMarks(true).build();
ta.prefColumnCountProperty().bind(s1.valueProperty());
ta.prefRowCountProperty().bind(s2.valueProperty());
Pane pane = new Pane();
pane.setPrefWidth(200);
pane.setPrefHeight(200);
pane.getChildren().addAll(ta);
VBox vb = new VBox(5);
vb.getChildren().addAll(pane, s1, s2);
Scene scene = new Scene(vb, 300, 300);
stage.setScene(scene);
stage.show();
}
}
Steps to reproduce:
Change values of sliders and try to resize scene window. Changes will be applied only after window resize. Try to change pref counts again and resize window again. It doesn't help now.
Also see attached movie.
- duplicates
-
JDK-8126989 TextArea PrefRowCount is not working at runtime
-
- Closed
-