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