This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

should very swing components in respective object?

 
Nakata kokuyo
Ranch Hand
Posts: 467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i read most of the Swing application have contains long code in a single class, which means if we create a menubar, i need a method which contains many lines in order to create further like add on menuitems and so on ..

just wonder, should we put every components into respective class ? means menubar will have their own class , tabbedPane have their own class , then we use a manager class (contains main() method)..to act as facade ?

thank you very much for guidance
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> should we put every components into respective class

I would say no, unless you plan re-using the specific item.
Perhaps what you want to do is to isolate you components in methods eg

public JMenuBar createMenuBar()
{
JMenuBar menuBar = new JMenuBar();
menuBar.add(something);
menuBar.add(somethingElse);
return menuBar;
}

then, when the GUI is constructed
frame.setJMenuBar(createMenuBar());
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic