01: package net.ar.webonswing.petstore;
02:
03: import java.util.*;
04:
05: import javax.swing.*;
06:
07: import net.ar.webonswing.petstore.actions.*;
08: import net.ar.webonswing.petstore.helpers.*;
09: import net.ar.webonswing.petstore.model.*;
10:
11: public class ProductsView extends JPanel {
12: public ProductsView(Collection aProducts) {
13: GenericTable table = new GenericTable(new String[] {
14: "ProductID", "Name", "Description" });
15:
16: Collection products = aProducts;
17:
18: for (Iterator i = products.iterator(); i.hasNext();) {
19: final Product product = (Product) i.next();
20:
21: JLabel productId = new JLabel(product.getProductId());
22: productId.addMouseListener(new ProductViewAction(product));
23:
24: table.addRow(new JComponent[] { productId,
25: new JLabel(product.getName()),
26: new JLabel(product.getDescription()) });
27: }
28:
29: add(table);
30: }
31: }
|