FULL PRODUCT VERSION :
java version "1.8.0_141"
Java(TM) SE Runtime Environment (build 1.8.0_141-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
x86_64 GNU/Linux Centos, Ubuntu
A DESCRIPTION OF THE PROBLEM :
When a GridPane with a maximum width and a HGap > 0 contains a label with colSpan=2 and textWrap=true, and the label contains some text that is just barely short enough to fit without wrapping to a new line, the GridPane will still increase the row height for the label as if the text had been wrapped.
If HGap == 0, the row height for the label will be correct.
If the label has colSpan=1, the row height for the label will be correct.
A related bug might be https://bugs.openjdk.java.net/browse/JDK-8178029 .
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a GridPane with a maximum width MW and an HGap > 0.
2. Add a label with wrapText=true containing some text (no spaces) to the gridPane, each spanning 2 columns.
a) If the width of the text of the label is a bit smaller than MW, the text is not wrapped and its row is one line high.
b) If the width of the text of the label is almost exactly MW, the text is not wrapped, but the row is two lines high (as if the text had been wrapped). This is NOT expected and does not occur if, for example, GridPane.HGap == 0 or the label's colSpan=1.
c) If the width of the text of the label is a bit wider than MW, the text is wrapped into two lines and its row is two lines high.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When the label's text is NOT wrapped to a new line when the text is ALMOST long enough to wrap, the label's row should NOT get higher.
ACTUAL -
When the label's text is NOT wrapped to a new line when the text is ALMOST long enough to wrap, the label's row DOES get higher.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class TestGridPaneLabel extends Application {
@Override
public void start(final Stage primaryStage) {
final Scene scene = new Scene(new VBox(getGridPane(false), new Label(), getGridPane(true)), 300, 250);
primaryStage.setScene(scene);
primaryStage.show();
}
private static GridPane getGridPane(final boolean withHGap) {
final GridPane gridPane = new GridPane();
gridPane.setGridLinesVisible(true);
if (withHGap) {
gridPane.setHgap(10);
}
gridPane.setMaxWidth(165);
final Label label1 = new Label("TEST_LENGTH_IN_GP_A");
label1.setWrapText(true);
// the row containing this label will be too high if withHGap is true
final Label label2 = new Label("TEST_LENGTH_IN_GP_AB");
label2.setWrapText(true);
final Label label3 = new Label("TEST_LENGTH_IN_GP_ABC");
label3.setWrapText(true);
gridPane.add(label1, 0, 0, 2, 1);
gridPane.add(label2, 0, 1, 2, 1);
gridPane.add(label3, 0, 2, 2, 1);
return gridPane;
}
public static void main(final String[] args) {
launch();
}
}
---------- END SOURCE ----------
java version "1.8.0_141"
Java(TM) SE Runtime Environment (build 1.8.0_141-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
x86_64 GNU/Linux Centos, Ubuntu
A DESCRIPTION OF THE PROBLEM :
When a GridPane with a maximum width and a HGap > 0 contains a label with colSpan=2 and textWrap=true, and the label contains some text that is just barely short enough to fit without wrapping to a new line, the GridPane will still increase the row height for the label as if the text had been wrapped.
If HGap == 0, the row height for the label will be correct.
If the label has colSpan=1, the row height for the label will be correct.
A related bug might be https://bugs.openjdk.java.net/browse/JDK-8178029 .
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a GridPane with a maximum width MW and an HGap > 0.
2. Add a label with wrapText=true containing some text (no spaces) to the gridPane, each spanning 2 columns.
a) If the width of the text of the label is a bit smaller than MW, the text is not wrapped and its row is one line high.
b) If the width of the text of the label is almost exactly MW, the text is not wrapped, but the row is two lines high (as if the text had been wrapped). This is NOT expected and does not occur if, for example, GridPane.HGap == 0 or the label's colSpan=1.
c) If the width of the text of the label is a bit wider than MW, the text is wrapped into two lines and its row is two lines high.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When the label's text is NOT wrapped to a new line when the text is ALMOST long enough to wrap, the label's row should NOT get higher.
ACTUAL -
When the label's text is NOT wrapped to a new line when the text is ALMOST long enough to wrap, the label's row DOES get higher.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class TestGridPaneLabel extends Application {
@Override
public void start(final Stage primaryStage) {
final Scene scene = new Scene(new VBox(getGridPane(false), new Label(), getGridPane(true)), 300, 250);
primaryStage.setScene(scene);
primaryStage.show();
}
private static GridPane getGridPane(final boolean withHGap) {
final GridPane gridPane = new GridPane();
gridPane.setGridLinesVisible(true);
if (withHGap) {
gridPane.setHgap(10);
}
gridPane.setMaxWidth(165);
final Label label1 = new Label("TEST_LENGTH_IN_GP_A");
label1.setWrapText(true);
// the row containing this label will be too high if withHGap is true
final Label label2 = new Label("TEST_LENGTH_IN_GP_AB");
label2.setWrapText(true);
final Label label3 = new Label("TEST_LENGTH_IN_GP_ABC");
label3.setWrapText(true);
gridPane.add(label1, 0, 0, 2, 1);
gridPane.add(label2, 0, 1, 2, 1);
gridPane.add(label3, 0, 2, 2, 1);
return gridPane;
}
public static void main(final String[] args) {
launch();
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-8178029 GridPane layouting problems USE_PREF_SIZE + ColSpan
- Open