Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8096105

[TextArea] TextArea still visible when height set to 0 (regression)



    • Bug
    • Resolution: Fixed
    • P3
    • 8u40
    • 8u20
    • javafx
    • Ubuntu 14.04 and Mac OS X


      I am using an animation in my application to shrink the preferred height of a TextArea to zero (with minimum height already set to zero). On 8u5, this works as I expect: the TextArea reduces to nothing and eventually cannot be seen. However, on 8u20 (on Ubuntu 14.04 and on Mac OS X) the layout height seems to reduce to zero, but the element can still be seen, at a size of about 20 pixels high. Code to reproduce:

      import javafx.animation.KeyFrame;
      import javafx.animation.KeyValue;
      import javafx.animation.Timeline;
      import javafx.application.Application;
      import javafx.beans.property.SimpleDoubleProperty;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Label;
      import javafx.scene.control.TextArea;
      import javafx.scene.layout.Pane;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;
      import javafx.util.Duration;

      public class TestShrink_8u20 extends Application
          private class ShrinkableTextArea extends TextArea
              final SimpleDoubleProperty scale = new SimpleDoubleProperty(1.0);
              public ShrinkableTextArea(String content)
                  scale.addListener((observable, oldVal, newVal) ->
                    setPrefHeight(newVal.doubleValue() * computePrefHeight(9999)));
          public void start(Stage primaryStage) throws Exception
              ShrinkableTextArea area = new ShrinkableTextArea("Some amount\nof text\nin this box\netc");
              // Wrap text makes no difference here:
              Button shrink = new Button("Shrink");
              // Scales text area to nothing
              shrink.setOnAction(e -> {
                  new Timeline(new KeyFrame(Duration.millis(2000), new KeyValue(area.scale, 0.0))).play();
              VBox outer = new VBox();
              outer.getChildren().addAll(new Label("Start"), area, new Label("End"));
              Pane p = new Pane(outer, shrink);
              primaryStage.setScene(new Scene(p));

      When you press the Shrink button, the TextArea should vertically shrink to nothing. On 8u5 it does, leaving the Start label immediately above the End label. But on 8u20, while the Start and End label end up in the same positions (suggesting the layout height has shrunk to 0), the TextArea is still visible on top of the Start label and beneath the End label.




            jgiles Jonathan Giles
            nbrownjfx Neil Brown (Inactive)
            0 Vote for this issue
            6 Start watching this issue