0

It seems to me, that GridPane calculates wrong height over its Nodes when I use rowspan.

// 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" ) );

"Half OK" because height of "aaaa1" and "aaaa2" differs. See the picture.

// 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" ) );

Is it JavaFX error or something can be fixed?

Image: https://i.stack.imgur.com/us5Me.jpg

Dmitry
  • 105
  • 1
  • 9
  • This appears to all be expected behavior. I suggest you ask how do you achieve what it is you are trying to achieve. – SedJ601 Jul 16 '18 at 14:12
  • >> This appears to all be expected behavior. I suggest you ask how do you achieve what it is you are trying to achieve. On image you can see that GridPane damage outer space, that is not the expected behavior. Interface of my program is dynamic, elements are placed in GridPane layout, some them have height in several rows, because must be aligned with other cells. Also I noticed, that different rowspan value makes different outer interface damage. – Dmitry Jul 16 '18 at 15:12
  • How did you determine it's not expected behavior? Because it's not doing what you expect it to do or because it's not doing what the authors expect it to do? Your problem is most likely due to incorrect usage. Post you problem and what you are trying to achieve. – SedJ601 Jul 16 '18 at 15:18
  • I don't understand what you can't understand. Complete program is very big, here I placed simple example. Picture 02 -- wrong interval, cell (0,0) breaks GridPane border. Picture 03 -- Text value of (0,0) breaks both top and bottom borders, 04 -- same thing. If discoverd nonresolved bug about GridPane and rowspan (https://bugs.openjdk.java.net/browse/JDK-8173467), may be this is one more. Goal in this sample simple -- text1, gridpane, text2 must not intersects. Text "aaabbb..." must be inside GridPane cell (0,0), not out. That'll be"expected behavior". – Dmitry Jul 16 '18 at 18:21
  • I don't think that bug has anything to do with your problem. https://docs.oracle.com/javase/8/javafx/api/javafx/scene/layout/GridPane.html. I think `Note: Nodes spanning multiple rows/columns will be also size to the preferred sizes. The affected rows/columns are resized by the following priority: grow priorities, last row. This is with respect to row/column constraints.` is the reason you are having problems, I am guessing. – SedJ601 Jul 16 '18 at 18:40
  • If you can show what you are trying to achieve, then maybe you can get some help. If you are just trying to figure out if your problem is a bug, then maybe you are in the wrong place. Note: You have things like `okay`, `half okay`, `bad`, etc. Are we supposed to know what you mean? The simple route here is to explain what you think is wrong and then explain what you are trying to achieve. – SedJ601 Jul 16 '18 at 18:42
  • When I have layout problems, I use `SceneBuilder` to create what I was trying to do. (If you run into the same problem using `SceneBuilder`, I would then think it's a bug.) Once I got the layout I needed from `SceneBuilder`, I would then translate that into code. – SedJ601 Jul 16 '18 at 18:48

0 Answers0