#Pane size is different

6 messages · Page 1 of 1 (latest)

glad vault
#

Started JavaFX recently and ran into this problem where the pane size i set in my java code (1000x600) is not the same as the pane size in my Scene Builder (600x400). Aren't they supposed to be the same? Not sure what I'm doing wrong.

Java Code:


public class Application extends javafx.application.Application {
    @Override
    public void start(Stage stage) throws IOException {
        Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("Scene1.fxml")));
        Scene scene = new Scene(root, 1000, 600);
        stage.setTitle("App");
        String css = Objects.requireNonNull(getClass().getResource("/com/example/javafx/style1.css")).toExternalForm();
        scene.getStylesheets().add(css);
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch();
    }
}
hoary flameBOT
#

This post has been reserved for your question.

Hey @glad vault! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

glad vault
# glad vault Started JavaFX recently and ran into this problem where the pane size i set in m...

FXML Code:

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

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" stylesheets="@style1.css" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.javafx.Controller1">
   <children>
      <Label fx:id="levelLabel" layoutX="4.0" layoutY="58.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="25.0" prefWidth="600.0" text="Level 1" textAlignment="CENTER" />
      <Label fx:id="nameLabel" layoutY="188.0" prefHeight="17.0" prefWidth="600.0" text="Enter Name to Continue:" textAlignment="CENTER" />
      <Button layoutX="239.0" layoutY="336.0" mnemonicParsing="false" onAction="#switchToScene2" prefHeight="39.0" prefWidth="122.0" text="Switch">
         <font>
            <Font size="20.0" />
         </font>
      </Button>
      <TextField fx:id="nameTextField" layoutX="220.0" layoutY="231.0" prefHeight="25.0" prefWidth="168.0" />
   </children>
</AnchorPane>
hoary flameBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.

north shadow