Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaFXML. Two columns layout. First column with fixed width.

 
Petra Cervinkova
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm starting to learn JavaFX and I have some questions. I play with JavaFX Scene Builder 2.0 and root component has this settings: maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity". I can't find what value -Infinity uses for?

And I want make two columns layout with fixed width of the first column and the second column with width of remaing space. So I use HBox container, because there is automatic full height of inside containers. I don't know what is the right settings for second column to fill remaining width. Can you please advise me?



Have a nice day :-)!
 
Petra Cervinkova
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found solution, for second AnchorPane set HBox.hgrow="ALWAYS".

Still I don't know purpose of -Infinity value.
 
Darryl Burke
Bartender
Posts: 5149
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this is related to JavaFX, I've moved the thread to the appropriate section.
 
John Damien Smith
Ranch Hand
Posts: 299
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this code from the Region class.

Hopefully it explains what the NEGATIVE_INFINITY value means in this context => Instruct the control to use the preferred size for a given size constraint, such as minWidth or maxHeight.
FXML isn't really built to be human readable, though it is in most cases, but some of the values such as -Infinity are a little weird to see rather than a more easily understandable constant name such as USE_PREF_SIZE, even though they mean exactly the same thing.



Translating some of the FXML to english:

HBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="555.0"

Means:

Define a HBox of preferred size 555x400 with the maxHeight and maxWidth and minHeight and minWidth all set to the preferred height and width.
So essentially you have defined a container which is 555x400 in size and will always remain that size, as the max/min constraints you set all match the preferred size.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic