2

Here is a screenshot of original view of an interface built in JavaFX. Those buttons at the bottom look alright in this screen size. Original size window

And this is the view when the window is set to fullscreen. Those buttons don't grow with the increase in screen size. They look so tiny in comparison to the whole window.

Fullscreen window

These buttons are JFXButtons imported from JFoenix library and are wrapped in inside a HBox.I have set VGrow option to always but there is no HGrow option for buttons. I am using Scene Builder from developing this GUI. So how can i make these buttons adjust their size (especially width) with change in screen size. Here is .fxml of the interface.

 <?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.*?>
<?import com.jfoenix.controls.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>

<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainController">
    <top>
        <MenuBar BorderPane.alignment="CENTER">
            <menus>
                <Menu mnemonicParsing="false" text="File">
                    <items>
                        <MenuItem mnemonicParsing="false" text="Close" />
                    </items>
                </Menu>
                <Menu mnemonicParsing="false" text="Edit">
                    <items>
                        <MenuItem mnemonicParsing="false" text="Delete" />
                    </items>
                </Menu>
                <Menu mnemonicParsing="false" text="Help">
                    <items>
                        <MenuItem mnemonicParsing="false" text="About" />
                    </items>
                </Menu>
            </menus>
        </MenuBar>
    </top>
    <bottom>
        <VBox prefHeight="90.0" prefWidth="1000.0" spacing="5.0">
            <children>
                <HBox alignment="CENTER" prefHeight="40.0" prefWidth="200.0" spacing="10.0" stylesheets="@../../bin/application/style1.css" BorderPane.alignment="CENTER" VBox.vgrow="ALWAYS">
                    <children>
                        <JFXButton fx:id="playpauseBtn" buttonType="RAISED" layoutX="310.0" layoutY="18.0" HBox.hgrow="ALWAYS" />
                  <JFXButton fx:id="playpauseBtn1" buttonType="RAISED" layoutX="485.0" layoutY="17.0" />
                  <JFXButton fx:id="playpauseBtn11" buttonType="RAISED" layoutX="515.0" layoutY="17.0" />
                  <JFXButton fx:id="playpauseBtn12" buttonType="RAISED" layoutX="485.0" layoutY="17.0" />
                  <JFXButton fx:id="playpauseBtn111" buttonType="RAISED" layoutX="515.0" layoutY="17.0" />
                    </children>
                </HBox>
                <JFXSlider prefHeight="21.0" prefWidth="1000.0" VBox.vgrow="ALWAYS">
               <padding>
                  <Insets bottom="8.0" />
               </padding></JFXSlider>
            </children>
        </VBox>
    </bottom>
</BorderPane>
Manoj
  • 17
  • 4
  • This isn't what I am looking for. I want those buttons to automatically resize according to the change in the window size. Currently, they look good on the original window but look very small when the window is maximized. – Manoj Jul 14 '17 at 02:43
  • Post the FXML to get more precise help. – SedJ601 Jul 14 '17 at 02:51
  • @SedrickJefferson I have posted FXML. Please have a look once. – Manoj Jul 14 '17 at 03:12
  • You are going to have to use a `GridPane` with constraints to accomplish this. https://stackoverflow.com/questions/10318467/how-to-bind-stage-resizing-with-resizing-of-components – SedJ601 Jul 14 '17 at 05:45
  • [This](https://stackoverflow.com/questions/23229149/javafx-automatic-resizing-and-button-padding) is probably close what you are trying to achieve. – SedJ601 Jul 16 '17 at 07:39

1 Answers1

0

The only I could think ofis to bind the width and height of those buttons to the width and height of the scene programmaticaly. For example:

playpauseBtn.scaleXProperty().bind(playpauseBtn.getScene().widthProperty().multiply(0.5));
playpauseBtn.scaleYProperty().bind(playpauseBtn.getScene().heightProperty().multiply(0.5));  
mrdlink
  • 266
  • 4
  • 15