JavaFX Can i repaint a Stage?


Question

enter image description hereAfter you put some values in the programm over the keyboard, the stage started, But at the same time i would like to have the stage is open, user can put some values again and the stage restart.

Is that possible?

I would like to do something like this:

     primaryStage.setScene(scene);
    primaryStage.show();

    javafx.application.Platform.runLater(new Runnable() {
        public void run() {
            if (TastaturEingabe.readBoolean("Möchten Sie ein neues Diagramm zeichnen?")) {

                // Input through keyboard
                readInputJahrgang(vintage, FIRST_PROMPT);
                readInputLager(vintage, FIRST_PROMPT);
                primaryStage.hide();
            } else {
                primaryStage.close();
            }
            return;
        }
    });
1
0
3/6/2013 11:01:29 PM

Accepted Answer

This is a wrong design of interacting between user and application.

javafx.application.Platform.runLater(new Runnable() {
    public void run() {

will be run on JFX thread, and while you are talking with a user in a command line, UI will be frozen.

You can talk to a user via comandline in a separate thread, which can use runLater() calls to inform JFX, about new user input.

So, you can create a separate thread in a start method, and put

readInputJahrgang(vintage, FIRST_PROMPT);
readInputLager(vintage, FIRST_PROMPT);

calls in its runnable.

When user input new info, which is needed to redraw a UI, call runLater().

In common case, you don't need to force JavaFX to redraw anything. It will do everything by itself

2
3/7/2013 4:04:19 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon