Is builder design pattern is the right one to create itemBrowsePanel object? this object needs 2 others objects (iconBrowsePanel,textBrowsePanel) in order to be ready to use, as follows:
HTMLPanel itemBrowsePanel=new HTMLPanel("");
HTMLPanel iconBrowsePanel=new HTMLPanel("");
HTMLPanel textBrowsePanel=new HTMLPanel("");
HTMLPanel titlePanel=new HTMLPanel(titlePanelText);
HTMLPanel subTitlePanel=new HTMLPanel(subTitlePanelText+" "+panelName);
textBrowsePanel.add(titlePanel);
textBrowsePanel.add(subTitlePanel);
itemBrowsePanel.add(iconBrowsePanel);
itemBrowsePanel.add(textBrowsePanel);
if builder design pattern is the right one, is it applicable to pass arguments to any object on creation in order to construct other objects ?
Composite Pattern is better in this case because you are building an aggregated object. It also offer more flexibility, for example, it's easier to change the panel to accept 3 instead of 2 child objects.
First, you create a base class for all UI elements in your system.
Then you add
HTMLPaneland override Add to do whatever you want. In this case, you want to limit its child objects to two.To construct the object, it's similar or exactly the same as what you did in your question.
In the future, you might want to show labels in panels. You can achieve that easily by adding a new class.
And you can just add it to the panel.