Shaaf's blog

A technical blog about Java, Kubernetes and things that matter

Command, Singleton, JMenuItem, JButton, AbstractButton - One Listener for the app

Here I would like to demonstrate a simple use of JMenuItems being used with Single Listener for the entire system. A simple sample of use would probably be SingleInstance Desktop Application. Lets see how that is done here. First lets create a OneListener class that should be able to listen to ActionEvents and also be able to add Commands to itself. Please refer to my previous post on Command,Singleton if you would like to see more about this patterns and there usage.