Issue
When I try to run my code in NetBeans I get a empty window saying "Browse JavaFX Application classes" but there are none to select. How can I solve this? Im trying to create a card game. This is the start to the main method.
import cardutils.Deck;
public class Main {
public static void main(String[] args) {
Deck deck = new Deck();
System.out.println(deck.toString());
}
}
Solution
If you want to make a JavaFX application, you need to create a class which extends the Application
class of JavaFX and which also contains your main method. So something like this:
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;
public class Deck extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage stage) {
Group root = new Group(new Label("Hello JavaFX!"));
Scene scene = new Scene(root, 1024, 786);
stage.setScene(scene);
stage.show();
}
}
And then simply run the project and Netbeans will find this class because it contains a main method and will let you select it.
If, however, this project does not really need JavaFX (I just wondered because you're simply printing out something to the command line), you might have selected the wrong project type when creating your Netbeans project (JavaFX Project instead of normal Java Project). In this case create a new standard Java project and copy the code over from the old project.
EDIT: The list with "available classes" is empty because Netbeans can't find any classes that extend javafx.application.Application
inside the JavaFX project you seem to have created.
Answered By - Ignatiamus
Answer Checked By - David Goodson (JavaFixing Volunteer)