< prev index next >

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

Print this page




  56  * wrapping at the flowpane's height.  If the flowpane has a border and/or padding set,
  57  * the content will be flowed within those insets.
  58  * <p>
  59  * FlowPane's prefWrapLength property establishes it's preferred width
  60  * (for horizontal) or preferred height (for vertical). Applications should set
  61  * prefWrapLength if the default value (400) doesn't suffice.  Note that prefWrapLength
  62  * is used only for calculating the preferred size and may not reflect the actual
  63  * wrapping dimension, which tracks the actual size of the flowpane.
  64  * <p>
  65  * The alignment property controls how the rows and columns are aligned
  66  * within the bounds of the flowpane and defaults to Pos.TOP_LEFT.  It is also possible
  67  * to control the alignment of nodes within the rows and columns by setting
  68  * rowValignment for horizontal or columnHalignment for vertical.
  69  * <p>
  70  * Example of a horizontal flowpane:
  71  * <pre><code>     Image images[] = { ... };
  72  *     FlowPane flow = new FlowPane();
  73  *     flow.setVgap(8);
  74  *     flow.setHgap(4);
  75  *     flow.setPrefWrapLength(300); // preferred width = 300
  76  *     for (int i = 0; i < images.length; i++) {
  77  *         flow.getChildren().add(new ImageView(image[i]);
  78  *     }
  79  * </code></pre>
  80  *
  81  *<p>
  82  * Example of a vertical flowpane:
  83  * <pre><code>     FlowPane flow = new FlowPane(Orientation.VERTICAL);
  84  *     flow.setColumnHalignment(HPos.LEFT); // align labels on left
  85  *     flow.setPrefWrapLength(200); // preferred height = 200
  86  *     for (int i = 0; i < titles.size(); i++) {
  87  *         flow.getChildren().add(new Label(titles[i]);
  88  *     }
  89  * </code></pre>
  90  *
  91  * <p>
  92  * FlowPane lays out each managed child regardless of the child's visible property value;
  93  * unmanaged children are ignored for all layout calculations.</p>
  94  *
  95  * <p>
  96  * FlowPane may be styled with backgrounds and borders using CSS.  See
  97  * {@link javafx.scene.layout.Region Region} superclass for details.</p>
  98  *
  99  * <h4>Resizable Range</h4>
 100  *
 101  * A flowpane's parent will resize the flowpane within the flowpane's resizable range
 102  * during layout.   By default the flowpane computes this range based on its content
 103  * as outlined in the tables below.
 104  * <p>
 105  * horizontal:
 106  * <table border="1">


 179      * Removes all flowpane constraints from the child node.
 180      * @param child the child node
 181      */
 182     public static void clearConstraints(Node child) {
 183         setMargin(child, null);
 184     }
 185 
 186     /********************************************************************
 187      *  END static methods
 188      ********************************************************************/
 189 
 190     /**
 191      * Creates a horizontal FlowPane layout with hgap/vgap = 0.
 192      */
 193     public FlowPane() {
 194         super();
 195     }
 196 
 197     /**
 198      * Creates a FlowPane layout with the specified orientation and hgap/vgap = 0.
 199      * @param orientation the direction the tiles should flow & wrap
 200      */
 201     public FlowPane(Orientation orientation) {
 202         this();
 203         setOrientation(orientation);
 204     }
 205 
 206     /**
 207      * Creates a horizontal FlowPane layout with the specified hgap/vgap.
 208      * @param hgap the amount of horizontal space between each tile
 209      * @param vgap the amount of vertical space between each tile
 210      */
 211     public FlowPane(double hgap, double vgap) {
 212         this();
 213         setHgap(hgap);
 214         setVgap(vgap);
 215     }
 216 
 217     /**
 218      * Creates a FlowPane layout with the specified orientation and hgap/vgap.
 219      * @param orientation the direction the tiles should flow & wrap
 220      * @param hgap the amount of horizontal space between each tile
 221      * @param vgap the amount of vertical space between each tile
 222      */
 223     public FlowPane(Orientation orientation, double hgap, double vgap) {
 224         this();
 225         setOrientation(orientation);
 226         setHgap(hgap);
 227         setVgap(vgap);
 228     }
 229 
 230     /**
 231      * Creates a horizontal FlowPane layout with hgap/vgap = 0.
 232      * @param children The initial set of children for this pane.
 233      * @since JavaFX 8.0
 234      */
 235     public FlowPane(Node... children) {
 236         super();
 237         getChildren().addAll(children);
 238     }
 239 
 240     /**
 241      * Creates a FlowPane layout with the specified orientation and hgap/vgap = 0.
 242      * @param orientation the direction the tiles should flow & wrap
 243      * @param children The initial set of children for this pane.
 244      * @since JavaFX 8.0
 245      */
 246     public FlowPane(Orientation orientation, Node... children) {
 247         this();
 248         setOrientation(orientation);
 249         getChildren().addAll(children);
 250     }
 251 
 252     /**
 253      * Creates a horizontal FlowPane layout with the specified hgap/vgap.
 254      * @param hgap the amount of horizontal space between each tile
 255      * @param vgap the amount of vertical space between each tile
 256      * @param children The initial set of children for this pane.
 257      * @since JavaFX 8.0
 258      */
 259     public FlowPane(double hgap, double vgap, Node... children) {
 260         this();
 261         setHgap(hgap);
 262         setVgap(vgap);
 263         getChildren().addAll(children);
 264     }
 265 
 266     /**
 267      * Creates a FlowPane layout with the specified orientation and hgap/vgap.
 268      * @param orientation the direction the tiles should flow & wrap
 269      * @param hgap the amount of horizontal space between each tile
 270      * @param vgap the amount of vertical space between each tile
 271      * @param children The initial set of children for this pane.
 272      * @since JavaFX 8.0
 273      */
 274     public FlowPane(Orientation orientation, double hgap, double vgap, Node... children) {
 275         this();
 276         setOrientation(orientation);
 277         setHgap(hgap);
 278         setVgap(vgap);
 279         getChildren().addAll(children);
 280     }
 281 
 282     /**
 283      * The orientation of this flowpane.
 284      * A horizontal flowpane lays out children left to right, wrapping at the
 285      * flowpane's width boundary.   A vertical flowpane lays out children top to
 286      * bottom, wrapping at the flowpane's height.
 287      * The default is horizontal.
 288      */




  56  * wrapping at the flowpane's height.  If the flowpane has a border and/or padding set,
  57  * the content will be flowed within those insets.
  58  * <p>
  59  * FlowPane's prefWrapLength property establishes it's preferred width
  60  * (for horizontal) or preferred height (for vertical). Applications should set
  61  * prefWrapLength if the default value (400) doesn't suffice.  Note that prefWrapLength
  62  * is used only for calculating the preferred size and may not reflect the actual
  63  * wrapping dimension, which tracks the actual size of the flowpane.
  64  * <p>
  65  * The alignment property controls how the rows and columns are aligned
  66  * within the bounds of the flowpane and defaults to Pos.TOP_LEFT.  It is also possible
  67  * to control the alignment of nodes within the rows and columns by setting
  68  * rowValignment for horizontal or columnHalignment for vertical.
  69  * <p>
  70  * Example of a horizontal flowpane:
  71  * <pre><code>     Image images[] = { ... };
  72  *     FlowPane flow = new FlowPane();
  73  *     flow.setVgap(8);
  74  *     flow.setHgap(4);
  75  *     flow.setPrefWrapLength(300); // preferred width = 300
  76  *     for (int i = 0; i &lt; images.length; i++) {
  77  *         flow.getChildren().add(new ImageView(image[i]);
  78  *     }
  79  * </code></pre>
  80  *
  81  *<p>
  82  * Example of a vertical flowpane:
  83  * <pre><code>     FlowPane flow = new FlowPane(Orientation.VERTICAL);
  84  *     flow.setColumnHalignment(HPos.LEFT); // align labels on left
  85  *     flow.setPrefWrapLength(200); // preferred height = 200
  86  *     for (int i = 0; i &lt; titles.size(); i++) {
  87  *         flow.getChildren().add(new Label(titles[i]);
  88  *     }
  89  * </code></pre>
  90  *
  91  * <p>
  92  * FlowPane lays out each managed child regardless of the child's visible property value;
  93  * unmanaged children are ignored for all layout calculations.</p>
  94  *
  95  * <p>
  96  * FlowPane may be styled with backgrounds and borders using CSS.  See
  97  * {@link javafx.scene.layout.Region Region} superclass for details.</p>
  98  *
  99  * <h4>Resizable Range</h4>
 100  *
 101  * A flowpane's parent will resize the flowpane within the flowpane's resizable range
 102  * during layout.   By default the flowpane computes this range based on its content
 103  * as outlined in the tables below.
 104  * <p>
 105  * horizontal:
 106  * <table border="1">


 179      * Removes all flowpane constraints from the child node.
 180      * @param child the child node
 181      */
 182     public static void clearConstraints(Node child) {
 183         setMargin(child, null);
 184     }
 185 
 186     /********************************************************************
 187      *  END static methods
 188      ********************************************************************/
 189 
 190     /**
 191      * Creates a horizontal FlowPane layout with hgap/vgap = 0.
 192      */
 193     public FlowPane() {
 194         super();
 195     }
 196 
 197     /**
 198      * Creates a FlowPane layout with the specified orientation and hgap/vgap = 0.
 199      * @param orientation the direction the tiles should flow &amp; wrap
 200      */
 201     public FlowPane(Orientation orientation) {
 202         this();
 203         setOrientation(orientation);
 204     }
 205 
 206     /**
 207      * Creates a horizontal FlowPane layout with the specified hgap/vgap.
 208      * @param hgap the amount of horizontal space between each tile
 209      * @param vgap the amount of vertical space between each tile
 210      */
 211     public FlowPane(double hgap, double vgap) {
 212         this();
 213         setHgap(hgap);
 214         setVgap(vgap);
 215     }
 216 
 217     /**
 218      * Creates a FlowPane layout with the specified orientation and hgap/vgap.
 219      * @param orientation the direction the tiles should flow &amp; wrap
 220      * @param hgap the amount of horizontal space between each tile
 221      * @param vgap the amount of vertical space between each tile
 222      */
 223     public FlowPane(Orientation orientation, double hgap, double vgap) {
 224         this();
 225         setOrientation(orientation);
 226         setHgap(hgap);
 227         setVgap(vgap);
 228     }
 229 
 230     /**
 231      * Creates a horizontal FlowPane layout with hgap/vgap = 0.
 232      * @param children The initial set of children for this pane.
 233      * @since JavaFX 8.0
 234      */
 235     public FlowPane(Node... children) {
 236         super();
 237         getChildren().addAll(children);
 238     }
 239 
 240     /**
 241      * Creates a FlowPane layout with the specified orientation and hgap/vgap = 0.
 242      * @param orientation the direction the tiles should flow &amp; wrap
 243      * @param children The initial set of children for this pane.
 244      * @since JavaFX 8.0
 245      */
 246     public FlowPane(Orientation orientation, Node... children) {
 247         this();
 248         setOrientation(orientation);
 249         getChildren().addAll(children);
 250     }
 251 
 252     /**
 253      * Creates a horizontal FlowPane layout with the specified hgap/vgap.
 254      * @param hgap the amount of horizontal space between each tile
 255      * @param vgap the amount of vertical space between each tile
 256      * @param children The initial set of children for this pane.
 257      * @since JavaFX 8.0
 258      */
 259     public FlowPane(double hgap, double vgap, Node... children) {
 260         this();
 261         setHgap(hgap);
 262         setVgap(vgap);
 263         getChildren().addAll(children);
 264     }
 265 
 266     /**
 267      * Creates a FlowPane layout with the specified orientation and hgap/vgap.
 268      * @param orientation the direction the tiles should flow &amp; wrap
 269      * @param hgap the amount of horizontal space between each tile
 270      * @param vgap the amount of vertical space between each tile
 271      * @param children The initial set of children for this pane.
 272      * @since JavaFX 8.0
 273      */
 274     public FlowPane(Orientation orientation, double hgap, double vgap, Node... children) {
 275         this();
 276         setOrientation(orientation);
 277         setHgap(hgap);
 278         setVgap(vgap);
 279         getChildren().addAll(children);
 280     }
 281 
 282     /**
 283      * The orientation of this flowpane.
 284      * A horizontal flowpane lays out children left to right, wrapping at the
 285      * flowpane's width boundary.   A vertical flowpane lays out children top to
 286      * bottom, wrapping at the flowpane's height.
 287      * The default is horizontal.
 288      */


< prev index next >