| 9 | import javafx.scene.text.Font; |
| 10 | |
| 11 | public class AutoTextArea extends StackPane { |
| 12 | |
| 13 | private Label autoLabel; |
| 14 | private TextArea autoTextArea; |
| 15 | |
| 16 | |
| 17 | public AutoTextArea(String text) { |
| 18 | |
| 19 | this.autoLabel = new Label(text); |
| 20 | this.autoTextArea = new TextArea(text); |
| 21 | |
| 22 | this.autoLabel.setWrapText(true); |
| 23 | this.autoTextArea.setWrapText(true); |
| 24 | this.autoTextArea.setEditable(false); |
| 25 | this.autoLabel.setStyle("-fx-text-fill: transparent;"); |
| 26 | |
| 27 | this.autoLabel.setPadding(new Insets(0, 10, 0, 11)); //Top, Right, Bottom, Left |
| 28 | this.autoTextArea.setPadding(new Insets(2, 0, 0, 0)); //Top, Right, Bottom, Left |
| 29 | |
| 30 | this.autoLabel.prefWidthProperty().bind(this.widthProperty()); |
| 31 | |
| 32 | this.autoTextArea.prefWidthProperty().bind(this.autoLabel.widthProperty().add(14)); |
| 33 | this.autoTextArea.prefHeightProperty().bind(this.autoLabel.heightProperty().add(16)); |
| 34 | |
| 35 | this.getChildren().addAll(this.autoLabel, this.autoTextArea); |
| 36 | |
| 37 | this.autoLabel.textProperty().addListener(new ChangeListener<String>() { |
| 38 | @Override |
| 39 | public void changed(final ObservableValue<? extends String> observable, final String oldValue, final String newValue) { |
| 40 | updateFromLabel(); |
| 41 | } |
| 42 | }); |
| 43 | } |
| 44 | |
| 45 | public AutoTextArea() { |
| 46 | this.autoLabel = new Label(); |
| 47 | this.autoTextArea = new TextArea(); |
| 48 | |
| 49 | this.autoLabel.setWrapText(true); |
| 50 | this.autoTextArea.setWrapText(true); |
| 51 | this.autoTextArea.setEditable(false); |
| 52 | this.autoLabel.setStyle("-fx-text-fill: transparent;"); |
| 53 | |
| 54 | this.autoLabel.setPadding(new Insets(0, 10, 0, 11)); //Top, Right, Bottom, Left |
| 55 | this.autoTextArea.setPadding(new Insets(2, 0, 0, 0)); //Top, Right, Bottom, Left |
| 56 | |
| 57 | this.autoLabel.prefWidthProperty().bind(this.widthProperty()); |
| 58 | |
| 59 | this.autoTextArea.prefWidthProperty().bind(this.autoLabel.widthProperty().add(14)); |
| 60 | this.autoTextArea.prefHeightProperty().bind(this.autoLabel.heightProperty().add(16)); |
| 61 | |
| 62 | this.getChildren().addAll(this.autoLabel, this.autoTextArea); |
| 63 | |
| 64 | this.autoLabel.textProperty().addListener(new ChangeListener<String>() { |
| 65 | @Override |
| 66 | public void changed(final ObservableValue<? extends String> observable, final String oldValue, final String newValue) { |
| 67 | updateFromLabel(); |
| 68 | } |
nothing calls this directly
no outgoing calls
no test coverage detected