This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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 ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Menu Bar design issue.

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • 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!