I want to use JavaFX as a solution to Java's issues with buffered input making things like 'press any key to continue' not easy.
I plan to use an event listener to detect keyboard input. But before I start down that road I want to know if this is on the right track.
Is the code below a good way to use JavaFX to implement a shell-based program?
- Is this the minimum JavaFX code required to do shell?
- Am I missing something that's gonna bite me down the road (like some kind of object de-referencing: I am very new to JavaFX so I don't have a clue!)
- Is it OK to consider the
start
method as effectively now mymain
method?
import java.util.Scanner;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.stage.Stage;
public class TextBased extends Application {
public static void main(String argv[]) {
Application.launch(argv);
}
@Override
public void start(Stage primaryStage) {
System.out.println("Hello world");
Scanner scanner = new Scanner(System.in);
scanner.nextLine();
Platform.exit();
}
}