< prev index next >

modules/javafx.graphics/src/main/java/javafx/scene/layout/GridPane.java

Print this page




  53 import java.util.Arrays;
  54 import java.util.BitSet;
  55 import java.util.Iterator;
  56 import java.util.Map.Entry;
  57 import java.util.Set;
  58 import java.util.SortedMap;
  59 import java.util.TreeMap;
  60 import java.util.TreeSet;
  61 
  62 import javafx.beans.Observable;
  63 import javafx.css.Styleable;
  64 import javafx.css.StyleableProperty;
  65 import javafx.geometry.BoundingBox;
  66 import javafx.geometry.Bounds;
  67 import javafx.util.Callback;
  68 
  69 
  70 
  71 /**
  72  * GridPane lays out its children within a flexible grid of rows and columns.
  73  * If a border and/or padding is set, then its content will be layed out within
  74  * those insets.
  75  * <p>
  76  * A child may be placed anywhere within the grid and may span multiple
  77  * rows/columns.  Children may freely overlap within rows/columns and their
  78  * stacking order will be defined by the order of the gridpane's children list
  79  * (0th node in back, last node in front).
  80  * <p>
  81  * GridPane may be styled with backgrounds and borders using CSS.  See
  82  * {@link javafx.scene.layout.Region Region} superclass for details.</p>
  83  *
  84  * <h3>Grid Constraints</h3>
  85  * <p>
  86  * A child's placement within the grid is defined by it's layout constraints:
  87  * </p>
  88  *
  89  * <table border="1">
  90  * <caption>Grid Constraint Table</caption>
  91  * <tr><th scope="col">Constraint</th><th scope="col">Type</th><th scope="col">Description</th></tr>
  92  * <tr><th scope="row">columnIndex</th><td>integer</td><td>column where child's layout area starts.</td></tr>
  93  * <tr><th scope="row">rowIndex</th><td>integer</td><td>row where child's layout area starts.</td></tr>


 206  * <td>left/right insets plus the sum of each column's pref width.</td>
 207  * <td>top/bottom insets plus the sum of each row's pref height.</td></tr>
 208  * <tr><th scope="row">maximum</th>
 209  * <td>Double.MAX_VALUE</td><td>Double.MAX_VALUE</td></tr>
 210  * </table>
 211  * <p>
 212  * A gridpane's unbounded maximum width and height are an indication to the parent that
 213  * it may be resized beyond its preferred size to fill whatever space is assigned
 214  * to it.
 215  * <p>
 216  * GridPane provides properties for setting the size range directly.  These
 217  * properties default to the sentinel value USE_COMPUTED_SIZE, however the
 218  * application may set them to other values as needed:
 219  * <pre><code>     <b>gridpane.setPrefSize(300, 300);</b>
 220  *     // never size the gridpane larger than its preferred size:
 221  *     <b>gridpane.setMaxSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE);</b>
 222  * </code></pre>
 223  * Applications may restore the computed values by setting these properties back
 224  * to USE_COMPUTED_SIZE.
 225  * <p>
 226  * GridPane does not clip its content by default, so it is possible that childrens'
 227  * bounds may extend outside its own bounds if a child's min size prevents it from
 228  * being fit within it space.</p>
 229  *
 230  * <h3>Optional Layout Constraints</h3>
 231  *
 232  * <p>
 233  * An application may set additional constraints on children to customize how the
 234  * child is sized and positioned within the layout area established by it's row/column
 235  * indices/spans:
 236  * </p>
 237  *
 238  * <table border="1">
 239  * <caption>GridPane Constraint Table</caption>
 240  * <tr><th scope="col">Constraint</th><th scope="col">Type</th><th scope="col">Description</th></tr>
 241  * <tr><th scope="row">halignment</th><td>javafx.geometry.HPos</td><td>The horizontal alignment of the child within its layout area.</td></tr>
 242  * <tr><th scope="row">valignment</th><td>javafx.geometry.VPos</td><td>The vertical alignment of the child within its layout area.</td></tr>
 243  * <tr><th scope="row">hgrow</th><td>javafx.scene.layout.Priority</td><td>The horizontal grow priority of the child.</td></tr>
 244  * <tr><th scope="row">vgrow</th><td>javafx.scene.layout.Priority</td><td>The vertical grow priority of the child.</td></tr>
 245  * <tr><th scope="row">margin</th><td>javafx.geometry.Insets</td><td>Margin space around the outside of the child.</td></tr>
 246  * </table>




  53 import java.util.Arrays;
  54 import java.util.BitSet;
  55 import java.util.Iterator;
  56 import java.util.Map.Entry;
  57 import java.util.Set;
  58 import java.util.SortedMap;
  59 import java.util.TreeMap;
  60 import java.util.TreeSet;
  61 
  62 import javafx.beans.Observable;
  63 import javafx.css.Styleable;
  64 import javafx.css.StyleableProperty;
  65 import javafx.geometry.BoundingBox;
  66 import javafx.geometry.Bounds;
  67 import javafx.util.Callback;
  68 
  69 
  70 
  71 /**
  72  * GridPane lays out its children within a flexible grid of rows and columns.
  73  * If a border and/or padding is set, then its content will be laid out within
  74  * those insets.
  75  * <p>
  76  * A child may be placed anywhere within the grid and may span multiple
  77  * rows/columns.  Children may freely overlap within rows/columns and their
  78  * stacking order will be defined by the order of the gridpane's children list
  79  * (0th node in back, last node in front).
  80  * <p>
  81  * GridPane may be styled with backgrounds and borders using CSS.  See
  82  * {@link javafx.scene.layout.Region Region} superclass for details.</p>
  83  *
  84  * <h3>Grid Constraints</h3>
  85  * <p>
  86  * A child's placement within the grid is defined by it's layout constraints:
  87  * </p>
  88  *
  89  * <table border="1">
  90  * <caption>Grid Constraint Table</caption>
  91  * <tr><th scope="col">Constraint</th><th scope="col">Type</th><th scope="col">Description</th></tr>
  92  * <tr><th scope="row">columnIndex</th><td>integer</td><td>column where child's layout area starts.</td></tr>
  93  * <tr><th scope="row">rowIndex</th><td>integer</td><td>row where child's layout area starts.</td></tr>


 206  * <td>left/right insets plus the sum of each column's pref width.</td>
 207  * <td>top/bottom insets plus the sum of each row's pref height.</td></tr>
 208  * <tr><th scope="row">maximum</th>
 209  * <td>Double.MAX_VALUE</td><td>Double.MAX_VALUE</td></tr>
 210  * </table>
 211  * <p>
 212  * A gridpane's unbounded maximum width and height are an indication to the parent that
 213  * it may be resized beyond its preferred size to fill whatever space is assigned
 214  * to it.
 215  * <p>
 216  * GridPane provides properties for setting the size range directly.  These
 217  * properties default to the sentinel value USE_COMPUTED_SIZE, however the
 218  * application may set them to other values as needed:
 219  * <pre><code>     <b>gridpane.setPrefSize(300, 300);</b>
 220  *     // never size the gridpane larger than its preferred size:
 221  *     <b>gridpane.setMaxSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE);</b>
 222  * </code></pre>
 223  * Applications may restore the computed values by setting these properties back
 224  * to USE_COMPUTED_SIZE.
 225  * <p>
 226  * GridPane does not clip its content by default, so it is possible that children's
 227  * bounds may extend outside its own bounds if a child's min size prevents it from
 228  * being fit within it space.</p>
 229  *
 230  * <h3>Optional Layout Constraints</h3>
 231  *
 232  * <p>
 233  * An application may set additional constraints on children to customize how the
 234  * child is sized and positioned within the layout area established by it's row/column
 235  * indices/spans:
 236  * </p>
 237  *
 238  * <table border="1">
 239  * <caption>GridPane Constraint Table</caption>
 240  * <tr><th scope="col">Constraint</th><th scope="col">Type</th><th scope="col">Description</th></tr>
 241  * <tr><th scope="row">halignment</th><td>javafx.geometry.HPos</td><td>The horizontal alignment of the child within its layout area.</td></tr>
 242  * <tr><th scope="row">valignment</th><td>javafx.geometry.VPos</td><td>The vertical alignment of the child within its layout area.</td></tr>
 243  * <tr><th scope="row">hgrow</th><td>javafx.scene.layout.Priority</td><td>The horizontal grow priority of the child.</td></tr>
 244  * <tr><th scope="row">vgrow</th><td>javafx.scene.layout.Priority</td><td>The vertical grow priority of the child.</td></tr>
 245  * <tr><th scope="row">margin</th><td>javafx.geometry.Insets</td><td>Margin space around the outside of the child.</td></tr>
 246  * </table>


< prev index next >