0

I am trying to launch a .exe file (made from a .jar), which at the beginning opens a UI/window and a user types multiple information in it. Later the user presses "OK" or "Cancel" and the program continues accordingly while using this information. This UI should also be visible in the taskbar.

I have managed to write a UI with the help of JPanel.

The Problem is that the window that opens may get "lost" when the user switches to other programs/browsers. This window cannot be found in Windows 10 when using alt+tab.

I am aware that in Windows 10 a UI opens in the taskbar while using JFrame.

Unfortunately, when using JFrame the rest of the code does not wait for the input of the user and continues to run. This part was solved while using the JPanel.

I am quite confused as of how to implement my code. What would be the optimal solution to my task?

  • Use JFrame? If so, how to make the code to wait for the user's Input?
  • Use JPanel? How to make a task icon out of it or how to make the window to pop over everything else.
  • Another option??

This should be a standard procedure for many applications. I do not understand why there is not a straight forward solution for this matter. I appreciate any tip.

Georgios
  • 861
  • 2
  • 12
  • 30
  • `frame.setAlwaysOnTop( true );` – achAmháin Mar 13 '19 at 16:53
  • 2
    Use a JDialog instead of JFrame and pass true to the constructor to make the dialog modal (wait for user input) – Palamino Mar 13 '19 at 16:58
  • @Palamino I thought that the JDialog was only for pop-up informational/error use. Is it possible to use JDialog as a window with multiple fields for the user to type in information? – Georgios Mar 13 '19 at 17:11
  • 1
    @Georgios yes, a JDialog is a subclass of java.awt.Window and can contain multiple fields for the user to type in information – Palamino Mar 13 '19 at 17:18
  • @Palamino Lovely, although after running a small test there is no icon in the taskbar. The window can be found in Windows 10 while using alt+tab though. This is the main reason why I wanted to avoid JPanel. – Georgios Mar 13 '19 at 17:47
  • @Lunchbox has posted here a way to open it on the taskbar: https://stackoverflow.com/questions/8006502/show-jdialog-on-windows-taskbar ----> JDialog dialog = new JDialog((Dialog)null); – Georgios Mar 13 '19 at 17:52

0 Answers0