0

I have a GUI application that I made and I wanted it to run in the background if it was closed so I simply set it's default close operation to be HIDE_ON_CLOSE and it will add a tray icon which will re-open the window when clicked. However, I want to make sure the same thing happens if I click on the desktop icon of my java application (I want it to just set the frame to visible) instead of going through its normal start procedures. Will this happen by default if I have hidden my JFrame? Thanks

  • This is a somewhat complex problem. Double clicking the desktop icon will create a new instance of the application, which is probably not what you really want. There are any number of ways you "might" work around this. You might make the "work" it's own process, allowing to execute independently of the UI and then use sockets to facilitate communication between them, this means that the you could "technically" have any number instances of the UI running, but they'd all be taking to the same instance of the "work". – MadProgrammer Jan 02 '19 at 23:55
  • Another mechanism is to setup a server socket when the app is first launched. Any new instances of the App would connect to this socket, which would trigger original instance to launch the UI and the new instance to terminate – MadProgrammer Jan 02 '19 at 23:56
  • *"Will this happen by default if I have hidden my JFrame?"* You should **try it** and see for yourself what will happen. – Andreas Jan 03 '19 at 00:06
  • @Andreas Hey genius I am still developing my application I don't have an actual icon you can click on from the desktop – AlwaysThinkingDifferently Jan 03 '19 at 01:14

0 Answers0