Running JavaFX application using VM argument. Program compiles and runs. Using Eclipse on MacOS. When the program runs it shows the java coffee cup logo in the dock, but no window comes up.
I want to be able to run this program successfully. I believe it's an Eclipse configuration issue rather than code.
I had a lot of issues getting JavaFX to run on Eclipse for Mac with the main one being that libraries did not exist and would not import. I was able to get it to work by downloading JavaFX from here (https://gluonhq.com/products/javafx/), creating a user defined library into my project and running the program with a VM argument: --module-path /Library/Java/JavaVirtualMachines/javafx-sdk-11.0.2/lib --add-modules=javafx.controls. Now the program compiles but I bump into the issue described above.
This post describes the issue I'm having: https://discussions.apple.com/thread/7886329
import javafx.application.*;
import javafx.scene.*;
import javafx.stage.*;
import javafx.scene.layout.*;
import javafx.scene.control.*;
public class SimpleCalculator extends Application
{
private Label firstValue;
private Label secondValue;
private Label sumLabel;
public void start( Stage myStage)
{
myStage.setTitle( "Simple Calculator");
FlowPane rootNode = new FlowPane();
Scene myScene = new Scene( rootNode, 300, 200 );
Label firstValue = new Label( "First Value: ");
Label secondValue = new Label( "Second Value: ");
Label sumLabel = new Label( "Sum is: ");
TextField firstField = new TextField();
TextField secondField = new TextField();
TextField sumField = new TextField();
sumField.setEditable(false);
rootNode.getChildren().addAll( firstValue, firstField, secondValue, secondField, sumLabel, sumField);
myStage.setScene( myScene );
myStage.show();
}
public static void main(String [] args)
{
launch( args );
}
}
Window pops and shows the labels and fields. This is not happening with my current code.