Layouts with constraint classes (original) (raw)
Tom Eugelink tbee at tbee.org
Fri Nov 30 22:28:28 PST 2012
- Previous message: Layouts with constraint classes
- Next message: Layouts with constraint classes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Not variables, but references. There are constraints specified for nodes that are not yet part of a layout (or even exist at that time, because they are declared further down). Note the absense of a label in the first HBox.C.
Tom
On 2012-11-30 14:11, Daniel Zwolenski wrote:
Ah ok, from your example code it looks like you want to use variables in FXML to define your constraints - getting into that territory of CSS-like style definitions that Richard was talking about?
Assuming this is what you want, this can be done in the current setup using the ridiculously under-documented fx:define thing. I knocked up a very rough sample for you quickly. The FXML looks like this: <BorderPane xmlns:fx="http://javafx.com/fxml"> fx:define (see https://code.google.com/p/zenjava-playtime/source/browse/trunk/layouts/src/main/resources/fxml/example.fxml) I made a base Constraints class with a static helper method on it (called via "Constraints.constraints" in the FXML above): https://code.google.com/p/zenjava-playtime/source/browse/trunk/layouts/src/main/java/com/playtime/layouts/Constraints.java And then a specific instance of HBoxConstraints: https://code.google.com/p/zenjava-playtime/source/browse/trunk/layouts/src/main/java/com/playtime/layouts/HBoxConstraints.java Obviously you would add others, like VBoxConstraints, GridPaneConstraints, etc. All pretty trivial. These helper classes could easily be included in something like JFXtras. So I stick with the stance that FXML is more or less OK here (not to say I wouldn't improve it lots in other areas), and really your conversation is about the Java API which is nicely decoupled to what can/can't be done in FXML. Kudos to Richard and the JFX team for designing the builders right.
On Fri, Nov 30, 2012 at 9:20 PM, Tom Eugelink <tbee at tbee.org <mailto:tbee at tbee.org>> wrote: On 2012-11-30 10:59, Daniel Zwolenski wrote: It just doesn't do it the exact way you suggest where you specify multiple possibilities directly in the child in case it ends up in a different parent - not an approach I agree with anyway (see my previous comments), but that's just my opinion. Just to make sure my suggestion is not misunderstood, it does not specify multiple possibilities in the child, but in the layout. <HBox.C for="arrow" vgrow="NEVER" valignment="RIGHT"/> <HBox.C vgrow="ALWAYS" valignment="LEFT" maxWidth="Infinity"/>
- Previous message: Layouts with constraint classes
- Next message: Layouts with constraint classes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]