I'm not quite sure I understood your ultimate goal, so here are two possibilities:
First (no more than one BalloonWindow at a time)
Create a static boolean isOpen in your class containing the execute() method. Set this variable to true after creating BalloonWindow and check this variable every time you type execute() . If it is false , create a new BalloonWindow , if it is true , return .
Second (close BalloonWindow )
BalloonWindow has an open() method. Use this method to open it instead of setVisible(true) . If you want to close BalloonWindow , just call close() . setVisible(false) will have the same visual effect (the window is gone), but it will still be (only invisible). close really closes the window.
source share