Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JavaFX - Timers and application termination

974949Nov 19 2012 — edited Nov 19 2012
Hello,

I need to do a job in the background with several seconds of delay after the user presses a key (a delayed search to be more precise). To do this, I use a java.util.Timer, but since including it the application does not exit correctly after the last window is closed.

To reduce the problem to the minimum expression, I've created this applicacion that shows the problem (eclipse shows it is still running after pressing close button):

public class ApplicationClosing extends Application {

private final Timer timerFiltro = new Timer();

public static void main(final String[] args) {
Application.launch(args);
}

@Override
public void start(final Stage primaryStage) {
Group root = new Group();
Scene scene = new Scene(root, 400, 250, Color.WHITE);
BorderPane borderPane = new BorderPane();
borderPane.setCenter(new Label("Hello"));
root.getChildren().add(borderPane);
primaryStage.setScene(scene);
primaryStage.show();
}
}

If a comment the line of the Timer, the application ends correctly. Any ideas?

Thank you all for your help :)
This post has been answered by James_D on Nov 19 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 17 2012
Added on Nov 19 2012
3 comments
1,088 views