与标题一样,我需要在其他课程中运行JavaFX的帮助。例如,我要从Main输入“ new TempClass()”之类的内容,然后希望有新的Window,但我什么也没得到xD谢谢您提前解决问题! <3
主要:
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
new TempClass();
}
public static void main(String[] args) {
launch(args); // when i launch(args) the 'start' func starting btw
}
}
TempClass:
public class TempClass extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Pane root = new Pane();
root.setPrefSize(300,300);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
答案 0 :(得分:0)
以下是解决我的问题的几种方法之一:
主要:
public class Main {
public static void main(String[] args) {
Application.launch(TempClass.class, args);
}
}
TempClass:
public class TempClass extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Pane root = new Pane();
root.setPrefSize(300,300);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
}