The code below shows how the dialog is created using the UIBuilder class
public class AddBidItemDialog
extends AbstractDialog {
public AddBidItemDialog(JFrame owner) {
super(owner);
createUI();
}
private void createUI() {
this.setTitle("Place an Item for Bidding");
getContentPane().setLayout(new BorderLayout());
cancelButton.setBounds(new Rectangle(206, 261, 78, 24));
cancelButton.setText("Cancel");
okButton.setBounds(new Rectangle(114, 262, 78, 24));
okButton.setText("Ok");
jPanel2.add(okButton);
jPanel2.add(cancelButton);
view = UIBuilder.createAddBidItemPanel();
this.getContentPane().add(view, java.awt.BorderLayout.CENTER);
this.getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);
this.setSize(400, 400);
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if( placeTheItem() ) {
dispose();
}
}
});
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
}
The UIBuilder class is based on a Builder design pattern, to allow the flexible to create different user Interfaces for the same purpose.
public class UIBuilder {
public static
AddBidItemView createAddBidItemPanel() {
return new AddBidItemPanel();
}
public static BidOnItemView createBidOnItemPanel()
{
return new BidOnItemPanel();
}
public static BidItemsView createViewBidItemsPanel()
{
return new BidItemsPanel();
}
}