-
Bug
-
Resolution: Fixed
-
P3
-
8u20
-
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)
{
super(content);
setMinHeight(0.0);
scale.addListener((observable, oldVal, newVal) ->
setPrefHeight(newVal.doubleValue() * computePrefHeight(9999)));
}
}
@Override
public void start(Stage primaryStage) throws Exception
{
ShrinkableTextArea area = new ShrinkableTextArea("Some amount\nof text\nin this box\netc");
area.setMaxWidth(300.0);
// Wrap text makes no difference here:
//area.setWrapText(true);
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();
});
shrink.setLayoutX(300);
shrink.setLayoutY(50);
VBox outer = new VBox();
outer.getChildren().addAll(new Label("Start"), area, new Label("End"));
Pane p = new Pane(outer, shrink);
p.setMinWidth(400);
p.setMinHeight(600);
primaryStage.setScene(new Scene(p));
primaryStage.show();
}
}
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.
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)
{
super(content);
setMinHeight(0.0);
scale.addListener((observable, oldVal, newVal) ->
setPrefHeight(newVal.doubleValue() * computePrefHeight(9999)));
}
}
@Override
public void start(Stage primaryStage) throws Exception
{
ShrinkableTextArea area = new ShrinkableTextArea("Some amount\nof text\nin this box\netc");
area.setMaxWidth(300.0);
// Wrap text makes no difference here:
//area.setWrapText(true);
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();
});
shrink.setLayoutX(300);
shrink.setLayoutY(50);
VBox outer = new VBox();
outer.getChildren().addAll(new Label("Start"), area, new Label("End"));
Pane p = new Pane(outer, shrink);
p.setMinWidth(400);
p.setMinHeight(600);
primaryStage.setScene(new Scene(p));
primaryStage.show();
}
}
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.