0

I am creating a window with a jframe. But when the program terminates the window closes. I want to the window to stay up even when the program closes.

The window doesn't have any functionality apart from displaying from text. I have tried to edit the default close process with:

setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

But this doesn't stop the window from closes when the program stops. Is there a way to keep this window/jframe open even when the program stops?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • 2
    There is no way to do that. It's not how windows (or macs or the various linux based GUIs) work. Some application needs to draw those pixels. Even if they aren't changing (what if the another window moves over it? An application needs to redraw the pixels previously covered by it). Thus, the solution is trivial: Don't close your app. Perhaps ask an SO question about how to keep your app running. – rzwitserloot Mar 28 '22 at 13:09
  • 1
    A System Tray application might be what you could use: https://stackoverflow.com/questions/758083/how-do-i-put-a-java-app-in-the-system-tray – Joop Eggen Mar 28 '22 at 13:14
  • 1
    *even when the program stops?* - don't use System.exit(). The frame will then just sit there waiting for further user interacation. – camickr Mar 28 '22 at 13:43
  • Is there more than one `JFrame` in this app.? – Andrew Thompson Apr 09 '22 at 06:50

0 Answers0