aspose file tools
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
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply 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: 437
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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: should very swing components in respective object?
 
Similar Threads
OO Question
Head First Java - Swing Chapters
how to draw lines across components
some java interview Questions
JPanel inside JFrame