JavaFX layout

Hi,

At last, I have started to work on JavaFX. For my first development, I share with you a new Layout named RefPointLayout. It’s principal is simple as you define one node position or two points node relatively to some reference points.

With one point you can set only the node position. With two points you can set the node position and size. The below diagram shows you the main key points of this layout :

refpoint

Let’s see together an example with scaled node and fixed size node. The HMI contains two scalable list views and two fixed size buttons. For the list view of the left side, its top left corner is relative to the top left parent reference point and the bottom right corner is relative to the bottom centre parent reference point. This way it is following window resize with a constant delta x and y. For the two buttons their position is set relatively to the middle centre reference point.

RefPointLayoutThe code to create the above HMi is the following :

In order to compile the above code, you need to download Ermine.jar. The layout is also available as a pane. Personally I quite like it as an independent layout interface. In the future, I might improve it by adding some customed reference points.

Cheers,

Mik

 

capcaval_logo_small Ermine_logo_small

 

4 thoughts on “JavaFX layout

  1. Pingback: JavaFX links of the (past few) week(s), October 13 // JavaFX News, Demos and Insight // FX Experience

  2. Pingback: Java desktop links of the (past few) week(s), October 13 « Jonathan Giles

  3. Interesting approach and it will work up to a degree. I forsee one of two problems: either you need to juggle a lot of absolute values, when enough nodes are place into a single container (you can only have so many node in the pane until it becomes confusing), and that may be with a lower number than expected. Or you will need to use a lot of nested layouts, like the HBox, and that is a well known performance issue, in both Swing and JavaFX.

    There are layout managers that work similarly, but also use other nodes as reference (so you get rules like “top the top of the parent” and “to the left of child x”).

    • Hi Tom,
      Thanks for your feedback. About your two points :
      I agree that having too many values can be too complex. In order to reduce the number of values you can simply use some variables. This way it will be easier to read.
      About the performance problem of nested layouts, as I have just started using JavaFx, I have to admit that I do not know how bad or good it is. I will see it soon probably. But on swing, I have developed quite a lot of complex near real time HMI on embedded system( hardware is much less powerful than standard desktop), and I never had such problem even on old system.
      If you encounter such problem with some nested RefPoint layout please give a sample and I will try to solve it by adding some simple optimization patterns.
      Personally, I prefer having a tree organisation of layout and pane this way split of work is simpler and reuse of a sub pane is much easier.
      Thanks again for your interest.

Leave a Reply

Your email address will not be published. Required fields are marked *

*