Skip to content

Commit

Permalink
8307208: Add GridPane constructor that accepts hGap and vGap values
Browse files Browse the repository at this point in the history
Reviewed-by: angorya, nlisker, jhendrikx, kcr
  • Loading branch information
Marius Hanl committed May 5, 2023
1 parent 0a1fd6e commit c50ce60
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -734,6 +734,20 @@ public GridPane() {
getChildren().addListener((Observable o) -> requestLayout());
}

/**
* Creates a {@code GridPane} layout with the given {@link #hgapProperty() hgap} and {@link #vgapProperty() vgap}.
*
* @param hgap the size of the horizontal gaps between columns
* @param vgap the size of the vertical gaps between rows
*
* @since 21
*/
public GridPane(double hgap, double vgap) {
this();
setHgap(hgap);
setVgap(vgap);
}

/**
* The width of the horizontal gaps between columns.
* @return the width of the horizontal gaps between columns
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -3158,4 +3158,15 @@ public void testAllRowsFixedButNotUpTo100() {

assertEquals(160, gridpane.prefHeight(-1), 1e-100);
}

@Test
public void testGridPaneHgapVgapConstructor() {
assertEquals(0, gridpane.getHgap(), 0);
assertEquals(0, gridpane.getVgap(), 0);

gridpane = new GridPane(3, 8);

assertEquals(3, gridpane.getHgap(), 0);
assertEquals(8, gridpane.getVgap(), 0);
}
}

1 comment on commit c50ce60

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.