Reputation: 21
First, I'm sorry about my english and i am new here.. I'd like to know.. is there a way to get the stages that are already open on javafx ?
** Something like "Application.OpenForms" from C#
For example:
I have a menu with 3 items: Register, Reports and Help. When I click on Register, it will open the register form for me. Then I click on Reports, it will open the reports for me. If I click on register again, the form that is already open will request the focus instead open a new form.
Someone help me, please ?
Upvotes: 1
Views: 873
Reputation: 1110
You can define your main stage as a static variable. For example, you have the following main file.
public class Main extends Application {
public static Stage main_stage;
@Override
public void start(Stage stage) throws Exception{
main_stage = stage;
stage.show();
}
public static void main(String[] args) {
launch(args);
}
So you can access your main_stage from anywhere by using Main.main_stage.
Upvotes: 1