File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

should very swing components in respective object?

 
Nakata kokuyo
Ranch Hand
Posts: 465
  • 0
  • 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
  • 0
  • 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());
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic