Fixed stall refresh issue.

This commit is contained in:
jendave
2011-08-06 15:18:38 +00:00
parent 60e95ee33a
commit f947bd5fc0

View File

@@ -16,8 +16,7 @@ public abstract class QuestAbstractBazaarStall extends JPanel implements NewCons
ImageIcon icon;
private JPanel inventoryPanel;
private JPanel inventoryPanel = new JPanel();
protected QuestData questData = AllZone.QuestData;
@@ -26,10 +25,14 @@ public abstract class QuestAbstractBazaarStall extends JPanel implements NewCons
this.icon = GuiUtils.getIconFromFile(iconName);
this.stallName = stallName;
initUI();
}
private void initUI() {
JLabel stallNameLabel;
JLabel creditLabel;
GridBagLayout layout = new GridBagLayout();
this.setLayout(layout);
@@ -48,7 +51,17 @@ public abstract class QuestAbstractBazaarStall extends JPanel implements NewCons
fluffArea.setEditable(false);
fluffArea.setFocusable(false);
GridBagConstraints constraints = new GridBagConstraints(0,0,1,1,1,0,GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(2,2,2,2), 0,0);
GridBagConstraints constraints = new GridBagConstraints(0,
0,
1,
1,
1,
0,
GridBagConstraints.CENTER,
GridBagConstraints.NONE,
new Insets(2, 2, 2, 2),
0,
0);
layout.setConstraints(stallNameLabel, constraints);
this.add(stallNameLabel);
@@ -76,7 +89,7 @@ public abstract class QuestAbstractBazaarStall extends JPanel implements NewCons
}
else {
constraints.gridy++;
constraints.gridy=3;
constraints.insets = new Insets(10, 5, 10, 5);
JLabel saleLabel = new JLabel("The following items are for sale:");
@@ -92,27 +105,33 @@ public abstract class QuestAbstractBazaarStall extends JPanel implements NewCons
constraints.fill = GridBagConstraints.BOTH;
constraints.gridy++;
inventoryPanel = new JPanel();
populateInventory(stallItems);
inventoryPanel.setBorder(new LineBorder(Color.ORANGE, 2));
JScrollPane scrollPane = new JScrollPane(inventoryPanel);
layout.setConstraints(scrollPane, constraints);
this.add(scrollPane);
}
}
private void populateInventory(java.util.List<QuestAbstractBazaarItem> stallItems) {
inventoryPanel = new JPanel();
GridBagLayout innerLayout = new GridBagLayout();
inventoryPanel.setLayout(innerLayout);
GridBagConstraints innerConstraints =
new GridBagConstraints(0,0,1,1,1,0,GridBagConstraints.NORTHWEST,GridBagConstraints.HORIZONTAL,new Insets(2,2,2,2), 0, 0);
new GridBagConstraints(0,
0,
1,
1,
1,
0,
GridBagConstraints.NORTHWEST,
GridBagConstraints.HORIZONTAL,
new Insets(2, 2, 2, 2),
0,
0);
for (QuestAbstractBazaarItem item : stallItems) {
JPanel itemPanel = item.getItemPanel();
@@ -132,7 +151,6 @@ public abstract class QuestAbstractBazaarStall extends JPanel implements NewCons
protected abstract java.util.List<QuestAbstractBazaarItem> populateItems();
public ImageIcon getStallIcon() {
return icon;
}
@@ -142,7 +160,7 @@ public abstract class QuestAbstractBazaarStall extends JPanel implements NewCons
}
public void updateItems() {
this.inventoryPanel.removeAll();
this.populateInventory(populateItems());
this.removeAll();
this.initUI();
}
}