• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Menu Bar design issue.  RSS feed

Ranch Hand
Posts: 15304
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been building Menu Bars for my Swing apps since I started with SWING several years ago.
While playing around with some different ideas on how to seperate and really modularize an app I am playing around with I had a thought and was wondering if anyone else would consider this a good idea or waste time or whatever.
I have a class called MainMenu which subclasses JMenuBar and basically consists of all my menu items for the main menu of the app.
What I thought about doing was go a step further and create a seperate class for each JMenu. So instead of having

fileMenu would actually be a seperate custom class of my own where I would add all the JMenuItems to it.
The reason I thought about doing this is a custom JMenuBar class can become quite large after adding a lot of JMenu's and JMenuItem's to it. But by subclassing JMenu, I have a file for each single Menu and can easily access and update that as neccessary rather than searching through an even larger file.
Of course the other thing is, other than what I mentioned above, is there really any other point to doing this.
So I would like to know if anyone else has done this, considered doing this, and generally what is thought of the above approach.
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would think a class such as that would be useful. If you added a few methods such as -
addMainMenuItem(string name)
addSubMenuItem(string name, string parentItem)
getMenuItem(string name)
It would probably speed up menu development for simple menus.
[ October 28, 2003: Message edited by: Aaron Roberts ]
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!