Search code examples
javaswingawtjmenubar

How to use a created JMenuBar in each of the java swing form?


I have created a JMenuBar and I want to use that JMenuBar in every form of my swing application. Writing JMenuBar in every form is not an efficient programming. So, I want to use the same JMenuBar in every form. But I have no clue how to do it. Can anyone show me some sample, so I can use it in my project.


Solution

  • The easiest way to do this would be making the JMenuBar Object public and static to allow access from every other class in the program without creating extra instances.