JavaFX GridPane行跨高度错误

时间:2018-07-16 13:07:41

标签: javafx layout rows gridpane

在我看来,当我使用rowspan时,GridPane计算出其节点上的错误高度。

// 01 - Half OK
final GridPane gp = new GridPane();
gp.add( new Text( "aaa\nbbb\nccc\nddd\neee" ), 0, 0, 1, 2 );
gp.add( new Text( "aaaa1" ), 1, 0, 1, 1 );
gp.add( new Text( "aaaa2" ), 1, 1, 1, 1 );
gp.setGridLinesVisible( true );
new VBox( 8, new Text( "text1" ), gp, new Text( "text2" ) );

“半确定”是因为“ aaaa1”和“ aaaa2”的高度不同。 看到图片。

// 02 - BAD
final GridPane gp = new GridPane();
gp.add( new Text( "aaa\nbbb\nccc\nddd\neee" ), 0, 0, 1, 2 );
gp.add( new Text( "aaaa1" ), 1, 0, 1, 1 );
gp.add( new Text( "aaaa2" ), 1, 1, 1, 2 );     // '1' -> '2'
gp.setGridLinesVisible( true );
new VBox( 8, new Text( "text1" ), gp, new Text( "text2" ) );

// 03 - BAD
final GridPane gp = new GridPane();
gp.add( new Text( "aaa\nbbb\nccc\nddd\neee" ), 0, 0, 1, 3 );
gp.add( new Text( "aaaa1" ), 1, 0, 1, 1 );
gp.add( new Text( "aaaa2" ), 1, 1, 1, 2 );
gp.setGridLinesVisible( true );
new VBox( 8, new Text( "text1" ), gp, new Text( "text2" ) );

// 04 - BAD
final GridPane gp = new GridPane();
gp.add( new Text( "aaa\nbbb\nccc\nddd\neee" ), 0, 0, 1, 3 );
gp.add( new Text( "aaaa1" ), 1, 0, 1, 1 );
gp.add( new Text( "aaaa2" ), 1, 1, 1, 2 );
gp.add( new Text( "xxx11" ), 2, 0, 1, 1 );
gp.add( new Text( "xxx21" ), 2, 1, 1, 1 );
gp.add( new Text( "xxx22" ), 2, 2, 1, 1 );
gp.setGridLinesVisible( true );
new VBox( 8, new Text( "text1" ), gp, new Text( "text2" ) );

是JavaFX错误还是可以解决的问题?

图片:https://imgur.com/3USWNyQ

0 个答案:

没有答案