UI: A class of its own or built by objects?

Should the UI be an object in and of itself or should the top-level container be built and maintained by a UI object while the components to this are designed and added by other objects.
[193 byte] By [ThomasOwensa] at [2007-10-3 0:41:05]
# 1
You plan on making a whole UI with a single object?
_dnoyeBa at 2007-7-14 17:35:21 > top of Java-index,Other Topics,Patterns & OO Design...
# 2

> Should the UI be an object in and of itself

What else can it be?

> or should

> the top-level container be built and maintained by a

> UI object while the components to this are designed

> and added by other objects.

A UI is a complex Component with other Components and Containers as children.

I would put it in its own package and give the Controller a builder or factory that creates it as needed.

%

duffymoa at 2007-7-14 17:35:21 > top of Java-index,Other Topics,Patterns & OO Design...
# 3
With that said, a complex UI is most likely to be several objects. If this is a Swing UI, you might have more than one JFrame/JPanel.If it's a web UI, made up of JSPs, you'll have at least one JSP per page. You might use SiteMesh to composite one page out of several.%
duffymoa at 2007-7-14 17:35:21 > top of Java-index,Other Topics,Patterns & OO Design...