title: Reference and Guidelines for Dynamic Layout using JavaFX
body: <p>I am using FXML via Scene Builder to establish some JavaFX scenes and formatting templates.  Having scanned the web and Oracle tutorials, I still find determining the '<em>rules</em>' around how layouts size/wrap/fit-contents/etc. and spacing between elements and compoents to be 90% a black art to me. What I'm missing is the "layout overview" (missing chapter) that puts FXML (and JavaFX) layouts all together.  If you've come across such a creature, please share link(s).  </p>
  
  <p>To date I've only found small bits of information.  For example the: </p>
  
  <ul>
  <li><a href="http://www.oracle.com/technetwork/java/javafx/documentation/reference-137773.html" rel="nofollow">JavaFX References</a></li>
  <li><a href="http://docs.oracle.com/javafx/2/api/" rel="nofollow">JavaFx JavaDocs</a></li>
  <li><a href="http://docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html" rel="nofollow">Java CSS Reference</a></li>
  </ul>
  
  <p>Give some useful infomation on one attribute, parameter or characteristic.  There seems to be nothing outlining the big picture nor making an effort to connect the dots between say "font-family" to (what are) "valid fonts"?  </p>
  
  <p>Also I'm looking for some examples that do more business or applications type work.  More real-world(tm) examples like a data entry form that takes details with text fields, comboboxes, radio buttons, etc.  Doing 'normal' on-screen things not just looking shiny graphics to show what JavaFX <em>might do</em>.</p>
  
  <p>The <strong>main thing</strong> that I see as missing is a description relating the different JavaFX containers and elements and relating them together for formatted-appearance, formatted-layout, rendered-sizing relating to each other.</p>
  
  <p>Forgive me for giving an example that sounds like a critism, it isn't intended to be I simply haven't found the information to let me satisfy some simple requirements:</p>
  
  <ol>
  <li>Want a dynamic layout that will work on different sized displays/windows.</li>
  <li>Some screne areas will need to size according to the content.  More or less what I'd describe as, <em>fit-to-content</em>.</li>
  <li>Other areas may need to be fixed width or height (as constraints).</li>
  <li>The remaining parts of the formetted-layout would shrink or grow depending on the size and capacity of the window.</li>
  <li>I want this in FXML: so that we can have a menu of layout styles with the same information (as <em>views</em>).  That way we are expecting to match display with the best layout.</li>
  </ol>
  
  <p>I can list the main, specific roadblocks I've come across (next).  The thing I accept is that there are gaps in my knowldge and in what I'm reading about how containter work, how do min-prefered-max widths and heights work?  How to they interact, etc.?  That may be too large a question for now.  I can give an example and some specifics to follow and leave it to the wisdom of the crowd ...</p>
  
  <p><strong>Example</strong></p>
  
  <pre><code>  | col-01   |  col-02 | col-03 | col-04   |  col-04 |
    |          |         |        |          |         |
    |  expand  |  fixed  | scale  |  expand  |   fit   |
    |          | percent |conetnet|          | content |
    |          |         |        |          |         |
  </code></pre>
  
  <p>Specifics:</p>
  
  <ol>
  <li>If I used a GridPane, there is NO properties or style field in SceneBuilder for the columns or rows.<br>
  <ul>
  <li>Question: can I code style for GridPane rows and columns in the FXML file?</li>
  </ul></li>
  <li>Percentages are not valid in most places (<a href="http://docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html" rel="nofollow">Java CSS Reference</a>).  Where can we use a percent and not use percent.</li>
  <li>I want the columns with "<em>expand</em>" to grow/shrink according to the display size.</li>
  <li><em>Fit content</em> shouldn't expand (or only expand moderately).</li>
  <li><em>Scale content</em> should expand/shrink to suit the 'remaining space' and at the same time I want the content to '<em>fit-space</em>' (which will normally be a graphic or other media) </li>
  <li>What are the VALID CSS styles for elements.<br>
  <ul>
  <li>What are the VALID values for the different JavaFX CCS styles?</li>
  <li>Which style (path) selectors and combination work for JavaFX? </li>
  </ul></li>
  </ol>
  
  <p>I still believe these constraints are do-able with JavaFX.  I want the "outline rules" for my layout to be set-up in FXML.  I feel that FXML should capable of doing what's needed provided I get the inforation about how to combine and set-up my layouts to satisfy the deploymed display constraints.</p>
  
  <p>I'm expecting all these answers are not all in one place.  As this is my second time (project) where I needed to know these things.  I would prefer to get things working with a little less brute force this time because we want the flexibility offered with FXML definitions.   I also think lots of us want to know how to do this but JavaFX styling is not the same as HTML. <em>My thanks in advance</em>.</p>
  
  <p><strong><em>see also</em></strong>:</p>
  
  <ul>
  <li><a href="http://fxexperience.com/2011/10/fxml-guice/" rel="nofollow">FXML Guice</a>, could be very useful.</li>
  </ul>