Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing Design Question  RSS feed

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In developing Swing Applications and using a JDesktopPane with JInternalFrames, I usually have a JMenuBar and a JToolBar. At first, I was creating these components in my constructor of my main class file. But I was wondering if there is a protocal for doing this or should I be calling methods that create these components instead of creating them in my constructor.
Any and all suggestions would be appreciated.

------------------
Happy Coding,
Gregg Bolinger
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think alot of it would have to do with:
Do you plan to use them anywhere else?
For instance, if you have a standard menu bar, you might want to use a separate class file.
If you don't plan to use them anywhere else, it is probably just a preference. Some IDEs will use a separate method for each component. Haven't read anywhere that it makes a difference though.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul. My Menu Bar will be the same throughout the Aplication. The Tool Bar on the other hand will be a little more dynamic. I would like to set it up so that the user can modify the tool bar, so I will probably put that in a class by itself.
Thanks Again!!

------------------
Happy Coding,
Gregg Bolinger
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!