1

I have different Java programs, each with Swing GUI and I would like to start them and close them from a central GUI window with the press of a JButton. What is the recommended method to do so? These programs need to send and receive state events such as window closing, to save preferences and disappear from memory.

GianniTee
  • 147
  • 1
  • 9
  • Are you unable to combine all the programs into one program and just use multiple JFrames? – Mitch Talmadge Dec 28 '15 at 23:16
  • That would depend. Do you want to dynamically load them at runtime or are the included at compile time? Do they have a common entry point from which you can execute them or does each one need to be started differently? – MadProgrammer Dec 29 '15 at 00:07
  • See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/q/9554636/418556) – Andrew Thompson Dec 29 '15 at 02:43
  • I have the source code, but for some of my old projects, its a chain of windows. For example, one such JFrame evades death when I set it to null and other windows remain in memory running somehow. I would like to close them altogether and also, if they are closed, they need to notify the main application. – GianniTee Dec 30 '15 at 04:15

1 Answers1

0

There's a bunch of ways to do this, but personally I'd probably make a JMX client in the central GUI program and have it connect to an MBean in the other programs that has the capability of shutting the program down. Something along the lines of this article.

Community
  • 1
  • 1
heenenee
  • 19,914
  • 1
  • 60
  • 86