Links

  • 1. Sogeti
  • 2. JBoss
  • 3. IBM
  • 4. Oracle
  • 5. SpringSource
  • 6. NL-JUG
  • 7. Java

Archives

Syndication  RSS 2.0

RSS 1.0
RSS 2.0

Bookmark this site

Add 'JCN Blog' site to delicious  Add 'JCN Blog' site to technorati  Add 'JCN Blog' site to digg  Add 'JCN Blog' site to dzone

Posted by Jan-Hendrik Kuperus at 12:10 on Wednesday 8 September    Add 'JavaFX Grid Component Worries' site to delicious  Add 'JavaFX Grid Component Worries' site to technorati  Add 'JavaFX Grid Component Worries' site to digg  Add 'JavaFX Grid Component Worries' site to dzone

If you’re working with JavaFX, you will probably know these two truths:

  • The JFXtras library has some really awesome components
  • The JavaFX platform is trying out new controls in the preview packages

A good thing about this, is that the JavaFX team is taking the good stuff from the JFXtras library and putting it into the platform. A bad thing about it is you start to expect the preview controls have the same functionality as the JFXtras controls.

I was working with the Grid layout container from the preview packages and ran into a wall. I was trying to make a node have a vspan of 2, and two nodes in the next column, like the image on the right here.

The code I tried, was simple enough:

def s = Stage {
   title: "Grid"
   scene: Scene {
       content: [
            Grid {
                id: "debug"
               rows: [
                   GridRow { cells: [
                       Button { text: "..." 
                         layoutInfo: GridLayoutInfo {
                           vspan: 2
                           vfill: true} }
                       Button { text: "..."}
                   ] }
                   GridRow { cells: [
                       Button { text: "..." }
                   ] }
               ]
           }
       ]
   }
}

That should have worked. However, when starting the little test application, the result looked like this:

The vspan does not seem to work as expected. At first I thought I was doing something wrong. Then I tried to switch out the preview Grid with the JFXtras XGrid. Check out the result:

Tadaaa, that was the result I was looking for. As it turns out, the preview container does not handle the vspan attribute correctly. I guess that’s why it’s called a preview :) .

Another small illustration of the differences. Amy Fowler has an example at JFXtras with the XGrid container. I switched out the XGrid with the normal Grid and got these two results:

Bottom line is: if you need vspan right now, use the XGrid. If you only need hspan, you can safely use the preview container, as long as you keep in mind that it may change in the next JavaFX release.

Cheers!

–JH


© 2017 Java Competence Network. All Rights Reserved.