• Post Reply Bookmark Topic Watch Topic
  • New Topic

Tabbed Panel design pattern

 
Dean Reedy
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been trying to read up on design patterns and what I would like to know, is how should one seperate a program which uses, a menu and tabbed panel as it main items. i.e. I would like to break out and have each tab of the tabbed panel as a seperate classes to help keep the code simpler. Any ideas on how I could break out each tab panel?
Thanks,
Dean Reedy
 
John Smith
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you're more interested in organizing/simplifying your code than using design patterns. I always like having inner classes inside my main class (which usually corresponds to the main window, i.e., JFrame). You get the advantages of having each view in your tabbed pane be its own class, but it's only visible (if declared private) to the window it resides in, which is the case if these views won't be visible in other windows.
I would also make the menu a private inner class which extends from JMenuBar (or JMenu or whatever). I like doing it this way because it keeps your code organized and in sync with how it actually looks inside the application. Sometimes I go nuts and have inner classes several layers deep...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!