0

I'm trying to get a starter project for a template running over for JavaFX, the assignment is to get a hello world program up and running using JavaFX to get the program running.

(Some Background context: We're using IntelliJ for our class assignment, but recently we found out that it seems(?) support for JavaFx has been discontinued within InteliJ, regardless the same assignment remains so we installed a third party library following the steps over from a guide about getting the library, ( How to get JavaFX and Java 11 working in IntelliJ IDEA ), the instructions helped to get the program running and compiled and I used the paths out, but when I ran the program, I got a blank white screen, and I have no clue if this is normal or not.)

The code is just the default JavaFX template from Intllij, I've tried installing the SDKS and JDKS (which seemed to help the program compile), but when running, I just get a blank white screen.

Here is a screenshot of the white screen problem https://i.stack.imgur.com/EmdNS.jpg

And the code below; it's just a IntelliJ default startup, but I don't know why it doesn't work.

package sample;

// Original Imports found in testTemplate
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{
        Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
        primaryStage.setTitle("Hello World");
        primaryStage.setScene(new Scene(root, 300, 275));
        primaryStage.show();

    }


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

package sample;

public class Controller {
}

We expected the results to say hello world. I think so anyways, but I actually have no clue what it's supposed to look like as it's my first time, I think it's supposed to say hello world. (Later on, we're supposed to get the GUI configured, but for right now, I just want to figure out what's going wrong with the program.)

Slaw
  • 37,820
  • 8
  • 53
  • 80
  • That is normal and looks correct to me. You've set the title of the window to "Hello World," but the scene does not have any other nodes (text boxes, labels, etc). Your screenshot **does** show the "Hello World" title. – Zephyr Feb 04 '19 at 05:28
  • On a side note, IntelliJ has not discontinued JavaFX support. Java 11, however, does not include JavaFX by default, and it needs to be installed separately. – Zephyr Feb 04 '19 at 05:29
  • 1
    What does `sample.fxml` look like? – Slaw Feb 04 '19 at 07:26
  • To test your installation just copy-paste-run a verified [Hello World][https://docs.oracle.com/javafx/2/get_started/hello_world.htm] code – c0der Feb 04 '19 at 12:12
  • Thank you everyone, i followed the instructions above and tried a couple sample programs, and it just turned out that like you guys said that it was missing text nodes to make the texts display, and upon adding in some coding for the text boxes, that the problem went away, i guess the template was meant to just a blank white screen all along! Thanks guys! – Rukanth Feb 04 '19 at 20:02

0 Answers0