Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently trying to figure out the best techniques for organizing GUI view hierarchies, that is dividing a window into several panels which are in turn divided into other components.

I've given a look to the Composite Design Pattern, but I don't know if I can find better alternatives, so I'd appreciate to know if using the Composite is a good idea, or it would be better looking for some other techniques.

I'm currently developing in Java Swing, but I don't think that the framework or the language can have a great impact on this.

Any help will be appreciated.


I was currently developing a frame containing three labels, one button and a text field. At the button pressed, the content inside the text field would be searched, and the results written inside the three labels.

One of my typical structure would be the following:

    Main panel
       Panel with text field and labels.
       Panel with search button

Now, as the title explains, I was looking for a suitable way of organizing both the MainPanel and the other two panels.
But here came problems, since I'm not sure whether organizing them like attributes or storing inside some data structure (i.e. LinkedList or something like this).

Anyway, I don't really think that both my solution are really good, so I'm wondering if there are really better approaches for facing this kind of problems.

Hope it helps

share|improve this question
Sharing your research helps everyone. Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer. Also see How to Ask – gnat Oct 18 '13 at 7:54
Please give a real-world example and describe the problem you are currently want to solve, then I am sure you will get good answers. – Doc Brown Oct 18 '13 at 8:12
I've just edited my question. I hope it is now more clear. – none Oct 18 '13 at 8:25
You may get a more immediate answer on User Experience site which has a lot of people very knowledgeable about user interface design. – DocSalvager Oct 25 '13 at 5:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.