wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes should very swing components in respective object? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "should very swing components in respective object?" Watch "should very swing components in respective object?" New topic
Author

should very swing components in respective object?

Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 442
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

Joined: Jun 09, 2003
Posts: 4632
> 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
 
subject: should very swing components in respective object?