-
Bug
-
Resolution: Duplicate
-
P4
-
8u40
-
Windows7, JDK 8u40
Since using JDK 8u40, if a GridPane has some columns (fixed number) and these column are defined to use a percent of the width available (using percentWidth of columnConstraint), the refresh of the various column size will not occur in the smooth way they use to using JDK 8u31. This leads to ugly spaces where a component would have fitted perfectly before.
Same behavior observed on 8u60 EA.
Here is a sample code I used to simply show the issue :
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class test extends Application
{
@Override
public void start(final Stage stage) throws Exception
{
// Création de la fenêtre
Scene scene = new Scene(construire());
stage.setScene(scene);
stage.setWidth(400);
stage.setHeight(400);
stage.show();
}
private GridPane construire()
{
GridPane pane = new GridPane();
pane.setGridLinesVisible(true);
// create a 20 column gridPane
ColumnConstraints col = new ColumnConstraints();
// the column share the whole gridPane space
col.setPercentWidth(100/20);
for( int i = 0; i < 20; i++)
{
pane.getColumnConstraints().add(col);
}
// add some label (one would be enough to force the gridPane to have a non 0 height)
Label lbl1 = new Label();
lbl1.setMaxWidth(Double.MAX_VALUE);
lbl1.setStyle("-fx-background-color:red");
pane.add(lbl1, 0, 0, 4, 1);
Label lbl2 = new Label();
lbl2.setMaxWidth(Double.MAX_VALUE);
lbl2.setStyle("-fx-background-color:blue");
pane.add(lbl2, 4, 0, 4, 1);
Label lbl3 = new Label();
lbl3.setMaxWidth(Double.MAX_VALUE);
lbl3.setStyle("-fx-background-color:yellow");
pane.add(lbl3, 8, 0, 4, 1);
Label lbl4 = new Label();
lbl4.setMaxWidth(Double.MAX_VALUE);
lbl4.setStyle("-fx-background-color:black");
pane.add(lbl4, 12, 0, 4, 1);
Label lbl5 = new Label();
lbl5.setMaxWidth(Double.MAX_VALUE);
lbl5.setStyle("-fx-background-color:green");
pane.add(lbl5, 16, 0, 4, 1);
return(pane);
}
}
Same behavior observed on 8u60 EA.
Here is a sample code I used to simply show the issue :
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class test extends Application
{
@Override
public void start(final Stage stage) throws Exception
{
// Création de la fenêtre
Scene scene = new Scene(construire());
stage.setScene(scene);
stage.setWidth(400);
stage.setHeight(400);
stage.show();
}
private GridPane construire()
{
GridPane pane = new GridPane();
pane.setGridLinesVisible(true);
// create a 20 column gridPane
ColumnConstraints col = new ColumnConstraints();
// the column share the whole gridPane space
col.setPercentWidth(100/20);
for( int i = 0; i < 20; i++)
{
pane.getColumnConstraints().add(col);
}
// add some label (one would be enough to force the gridPane to have a non 0 height)
Label lbl1 = new Label();
lbl1.setMaxWidth(Double.MAX_VALUE);
lbl1.setStyle("-fx-background-color:red");
pane.add(lbl1, 0, 0, 4, 1);
Label lbl2 = new Label();
lbl2.setMaxWidth(Double.MAX_VALUE);
lbl2.setStyle("-fx-background-color:blue");
pane.add(lbl2, 4, 0, 4, 1);
Label lbl3 = new Label();
lbl3.setMaxWidth(Double.MAX_VALUE);
lbl3.setStyle("-fx-background-color:yellow");
pane.add(lbl3, 8, 0, 4, 1);
Label lbl4 = new Label();
lbl4.setMaxWidth(Double.MAX_VALUE);
lbl4.setStyle("-fx-background-color:black");
pane.add(lbl4, 12, 0, 4, 1);
Label lbl5 = new Label();
lbl5.setMaxWidth(Double.MAX_VALUE);
lbl5.setStyle("-fx-background-color:green");
pane.add(lbl5, 16, 0, 4, 1);
return(pane);
}
}
- duplicates
-
JDK-8094332 GridPane percentage layout bug since JavaFx 8u40
- Resolved