问题描述:

I have a UI I have made using Netbeans and Scene builder using Java FX / FXML. I have never had a problem with it before but for this project for some reason in Scene building my UI would look one way, even the windows preview would look identical to it, but when running it in netbeans it would look messed up. In netbeans, all I am doing is loading and calling it. I have no idea on what the issue can be and nothing is helping on Google.

working screen shot on scene builder and editing and netbeans

http://imgur.com/laZYjck

compile and run

http://imgur.com/NOMVBZe

main.java

public class main

{

public static void main(String[] args)

{

View view = new View();

view.launch();

}

}

view.java

public class View extends Application

{

@FXML

private Button login;

@Override

public void start(Stage primaryStage)

{

Parent login_page = null;

try {

login_page = FXMLLoader.load(getClass().getResource("FXMLViewLogin.fxml"));

}

catch (IOException ex)

{

}

primaryStage.setTitle("Welcome!");

primaryStage.setScene(new Scene(login_page));

primaryStage.show();

}

@FXML

private void login(ActionEvent event)

{}

}

FXMLViewLogin.fxml

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

<?import java.net.*?>

<?import javafx.geometry.*?>

<?import javafx.scene.control.*?>

<?import javafx.scene.layout.*?>

<?import javafx.scene.text.*?>

<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="520.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="view.ViewControllerLogin">

<children>

<Button fx:id="button1" defaultButton="true" layoutX="74.0" layoutY="296.0" text="Sign Up" />

<Label layoutX="198.0" layoutY="153.0" text="Password" />

<Label layoutX="187.0" layoutY="35.0" text="User Name" />

<TextField fx:id="password" layoutX="74.0" layoutY="204.0" />

<TextField fx:id="username" layoutX="74.0" layoutY="80.0" />

<Button fx:id="button" layoutX="323.0" layoutY="296.0" onAction="#login" text="Log In" />

</children>

</Pane>

相关阅读:
Top