JFXtras / jfxtras

A supporting library for JavaFX, containing helper classes, extended layouts, controls and other interesting widgets.
http://jfxtras.org
Other
599 stars 123 forks source link

Set id for Layout in ResponsivePane #87

Closed marckaraujo closed 7 years ago

marckaraujo commented 7 years ago

How do I set an id for Layouts?

My FXML:

<ResponsivePane debug="true" prefHeight="900.0" prefWidth="1600.0" trace="false" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1">
    <reusableNodes>
        <Label id="label" text="refLabel" />
        <Button id="button" text="refButton" />
    </reusableNodes>

    <layouts>
        <Layout sizeAtLeast="3.0in">
            <VBox>
                <Ref to="label" />
                <Label text="layout_3.0" />
            </VBox>
        </Layout>

        <Layout sizeAtLeast="width:20cm">
            <HBox>
                <Ref id="labelid" to="label" />
                <Ref to="button" />
                <Label text="layout_width3.0" />
            </HBox>
        </Layout>     

        <Layout sizeAtLeast="width:40cm">
            <BorderPane fx:id="borderPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="900.0" prefWidth="1600.0" styleClass="background">
                <center>
                    <AnchorPane fx:id="ilustrationAnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" BorderPane.alignment="CENTER_RIGHT">
                        <children>
                            <ImageView fitHeight="900.0" fitWidth="1315.0" layoutX="180.0" pickOnBounds="true" scaleX="1.2" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                                <image>
                                    <Image url="@../img/dashboard/dashboard.png" />
                                </image>
                            </ImageView>
                            <Button fx:id="minimizeButton" layoutX="1243.0" layoutY="12.0" mnemonicParsing="false" onAction="#performMinimizeWindow" styleClass="button-action--minimize" AnchorPane.rightAnchor="46.0" AnchorPane.topAnchor="10.0" />
                            <Button fx:id="closeButton" layoutX="1278.0" layoutY="12.0" mnemonicParsing="false" onAction="#performCloseWindow" styleClass="button-action--close" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0" />
                        </children>
                        <BorderPane.margin>
                            <Insets />
                        </BorderPane.margin>
                    </AnchorPane>
                </center>
                <left>
                </left>
                <left>
                    <AnchorPane fx:id="leftAnchorPane" prefHeight="200.0" prefWidth="200.0" style="-fx-background-color: #334455;" BorderPane.alignment="CENTER" />
                </left>
            </BorderPane>
        </Layout>     
    </layouts>

    <sceneStylesheets>
        <Stylesheet sizeAtLeast="3.0in">  
            <URL value="@../styles/controller/res1024/Dashboard.css" /> 
        </Stylesheet>
        <Stylesheet sizeAtLeast="width:20cm"> 
            <URL value="@../styles/controller/res1280/Dashboard.css" /> 
        </Stylesheet>
        <Stylesheet sizeAtLeast="width:40cm"> 
            <URL value="@../styles/controller/res1600/Dashboard.css" /> 
        </Stylesheet>
    </sceneStylesheets>
</ResponsivePane>

I got null for borderPane in Class:

@FXML
    private BorderPane borderPane;
marckaraujo commented 7 years ago

It seems that only BorderPane doesnt get id properly.

tbee commented 7 years ago

I can take a look this weekend. But I suspect the way FXML does injection conflicts with the way ResponsivePane does layout; at certain resolutions the border pane is not present in the node graph.

tbee commented 7 years ago

I have no problems getting the borderPane initialized, but I did need to add a fx:controller attribute to the ResponsivePane XML tag. Have you forgotten that?