java - JavaFX auto scaling -


i want, when increase window, elements bigger.

see here: see here

i'm using javafx scenebuilder 2.0: enter image description here

start.fxml :

<?import javafx.scene.effect.*?> <?import javafx.scene.control.*?> <?import java.lang.*?> <?import javafx.scene.layout.*?> <?import javafx.geometry.insets?> <?import javafx.scene.layout.gridpane?> <?import javafx.scene.control.button?> <?import javafx.scene.control.label?>  <anchorpane cachehint="scale" focustraversable="true" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.controller">    <children>       <button fx:id="delterowbtn" layoutx="25.0" layouty="272.0" maxheight="1.7976931348623157e308" maxwidth="1.7976931348623157e308" mnemonicparsing="false" onaction="#delrowaction" prefheight="30.0" prefwidth="51.0" text="zeile" />       <button fx:id="addcolumnbtn" layoutx="193.0" layouty="272.0" maxheight="1.7976931348623157e308" maxwidth="1.7976931348623157e308" mnemonicparsing="false" onaction="#addcolumnaction" prefheight="30.0" prefwidth="51.0" text="spalte" />       <button fx:id="movebtn" layoutx="258.0" layouty="272.0" maxheight="1.7976931348623157e308" maxwidth="1.7976931348623157e308" mnemonicparsing="false" prefheight="30.0" prefwidth="90.0" text="move" />       <button fx:id="linkbtn" layoutx="363.0" layouty="272.0" maxheight="1.7976931348623157e308" maxwidth="1.7976931348623157e308" mnemonicparsing="false" prefheight="30.0" prefwidth="90.0" text="link" />       <button fx:id="splitbtn" layoutx="468.0" layouty="272.0" maxheight="1.7976931348623157e308" maxwidth="1.7976931348623157e308" mnemonicparsing="false" prefheight="30.0" prefwidth="90.0" text="split" />       <button fx:id="tcodebtn" layoutx="574.0" layouty="272.0" maxheight="1.7976931348623157e308" maxwidth="1.7976931348623157e308" mnemonicparsing="false" prefheight="30.0" prefwidth="90.0" text="transcode" />       <button fx:id="cnvrtbtn" layoutx="679.0" layouty="272.0" maxheight="1.7976931348623157e308" maxwidth="1.7976931348623157e308" mnemonicparsing="false" prefheight="30.0" prefwidth="90.0" text="convert" />       <button fx:id="savebtn" layoutx="684.0" layouty="551.0" maxheight="1.7976931348623157e308" maxwidth="1.7976931348623157e308" mnemonicparsing="false" onaction="#saveaction" prefheight="30.0" prefwidth="90.0" text="save" />       <tableview fx:id="sourcetable" editable="true" layoutx="17.0" layouty="40.0" maxheight="1.7976931348623157e308" maxwidth="1.7976931348623157e308" prefheight="190.0" prefwidth="766.0" />       <tableview fx:id="finaltable" layoutx="17.0" layouty="348.0" maxheight="1.7976931348623157e308" maxwidth="1.7976931348623157e308" prefheight="190.0" prefwidth="766.0" />       <button fx:id="openbtn" layoutx="572.0" layouty="551.0" maxheight="1.7976931348623157e308" maxwidth="1.7976931348623157e308" mnemonicparsing="false" onaction="#openaction" prefheight="30.0" prefwidth="90.0" text="open" />       <textfield fx:id="srcinput" editable="false" layoutx="69.0" layouty="551.0" prefheight="30.0" prefwidth="495.0" />       <textfield editable="false" layoutx="17.0" layouty="11.0" text="source file" />       <textfield editable="false" layoutx="17.0" layouty="319.0" text="converted file" />       <button fx:id="deltecolumnbtn" layoutx="77.0" layouty="272.0" maxheight="1.7976931348623157e308" maxwidth="1.7976931348623157e308" mnemonicparsing="false" onaction="#delcolumnaction" prefheight="30.0" prefwidth="51.0" text="spalte" />       <button fx:id="addrowbtn" layoutx="141.0" layouty="272.0" maxheight="1.7976931348623157e308" maxwidth="1.7976931348623157e308" mnemonicparsing="false" onaction="#addrowaction" prefheight="30.0" prefwidth="51.0" text="zeile" />       <label contentdisplay="center" layoutx="140.0" layouty="248.0" prefheight="25.0" prefwidth="104.0" text="    hinzufÜgen" textalignment="center" />       <label contentdisplay="center" layoutx="24.0" layouty="248.0" prefheight="25.0" prefwidth="104.0" text="      lÖschen" textalignment="center" />    </children> </anchorpane> 

you need anchor 4 sides. cause them stretch when screen enlarged. if want widen not taller, anchor left, right, , top, not bottom. may easier test interface using graphical scene builder set small details without having trial , error compiling. still able edit fxml , css files manually if this. here link: http://www.oracle.com/technetwork/java/javase/downloads/sb2download-2177776.html

i find helpful use in conjunction handcoding while working javafx


Comments