java - making AnchorPane resizeable based on its parent -


i have column 3 rows. each row includes image . column child of gridpane . can see in following fxml :

<gridpane gridpane.columnindex="1">     <columnconstraints>       <columnconstraints hgrow="sometimes" maxwidth="7.0" minwidth="0.0" prefwidth="0.0" />       <columnconstraints hgrow="sometimes" maxwidth="30.0" minwidth="10.0" prefwidth="30.0" />     </columnconstraints>     <rowconstraints>       <rowconstraints minheight="10.0" prefheight="30.0" vgrow="sometimes" />       <rowconstraints minheight="10.0" prefheight="30.0" vgrow="sometimes" />       <rowconstraints minheight="10.0" prefheight="30.0" vgrow="sometimes" />     </rowconstraints>     <children>        <imageview fitheight="31.0" fitwidth="29.0" onmousepressed="#addnewuser" pickonbounds="true" preserveratio="true" gridpane.columnindex="1" gridpane.rowindex="0">             <image>               <image url="@/views/add.png" />             </image>       </imageview>       <imageview fitheight="31.0" fitwidth="29.0" onmousepressed="#removeuser" pickonbounds="true" preserveratio="true" gridpane.columnindex="1" gridpane.rowindex="1">             <image>               <image url="@/views/remove.png" />             </image>       </imageview>       <imageview fitheight="31.0" fitwidth="29.0" onmousepressed="#edituser" pickonbounds="true" preserveratio="true" gridpane.columnindex="1" gridpane.rowindex="2">             <image>               <image url="@/views/edit.png" />             </image>       </imageview>    </children> </gridpane> 

based on understanding gridpane has fixed size , won't changed accordingly size of parent . (feel free correct me if i'm wrong). need wrap them anchorpane can resized . added , got following :

        <children>             <anchorpane prefheight="1000.0" prefwidth="900.0" style="-fx-background-color:red" >                 <gridpane gridpane.columnindex="1">                     <columnconstraints>                         <columnconstraints hgrow="sometimes" maxwidth="7.0" minwidth="0.0" prefwidth="0.0" />                         <columnconstraints hgrow="sometimes" maxwidth="30.0" minwidth="10.0" prefwidth="30.0" />                     </columnconstraints>                     <rowconstraints>                         <rowconstraints minheight="10.0" prefheight="30.0" vgrow="sometimes" />                         <rowconstraints minheight="10.0" prefheight="30.0" vgrow="sometimes" />                         <rowconstraints minheight="10.0" prefheight="30.0" vgrow="sometimes" />                     </rowconstraints>                     <children>                         <imageview fitheight="31.0" fitwidth="29.0" onmousepressed="#addnewuser" pickonbounds="true" preserveratio="true" gridpane.columnindex="1" gridpane.rowindex="0">                             <image>                                 <image url="@/views/add.png" />                             </image>                         </imageview>                         <imageview fitheight="31.0" fitwidth="29.0" onmousepressed="#removeuser" pickonbounds="true" preserveratio="true" gridpane.columnindex="1" gridpane.rowindex="1">                             <image>                                 <image url="@/views/remove.png" />                             </image>                         </imageview>                         <imageview fitheight="31.0" fitwidth="29.0" onmousepressed="#edituser" pickonbounds="true" preserveratio="true" gridpane.columnindex="1" gridpane.rowindex="2">                             <image>                                 <image url="@/views/edit.png" />                             </image>                         </imageview>                     </children>                 </gridpane>             </anchorpane>         </children>     </gridpane> </children> 

and result 3 sticking each other , no sign of resizing @ all. sake of debugging i've set background of anchorpane red , shows height , and it's width should still images sticking each other. idea how can fix ?

your anchorpane takes available place, children not. that's default behavior, can change explicitly setting anchors zero.

<gridpane gridpane.columnindex="1"           anchorpane.topanchor="0" anchorpane.rightanchor="0"           anchorpane.bottomanchor="0" anchorpane.leftanchor="0"> 

likewise, if don't want table stretch vertically, can set right , left anchors.

<gridpane gridpane.columnindex="1" anchorpane.rightanchor="0" anchorpane.leftanchor="0"> 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -