home *** CD-ROM | disk | FTP | other *** search
- import com.sun.java.swing.Box;
- import com.sun.java.swing.BoxLayout;
- import com.sun.java.swing.ButtonGroup;
- import com.sun.java.swing.DefaultListModel;
- import com.sun.java.swing.ImageIcon;
- import com.sun.java.swing.JButton;
- import com.sun.java.swing.JCheckBox;
- import com.sun.java.swing.JComponent;
- import com.sun.java.swing.JLabel;
- import com.sun.java.swing.JList;
- import com.sun.java.swing.JPanel;
- import com.sun.java.swing.JRadioButton;
- import com.sun.java.swing.JScrollPane;
- import java.awt.Container;
-
- public class ListPanel extends JPanel {
- int fastfoodIndex;
- int dessertIndex;
- int fruitIndex;
- int veggieIndex;
- boolean fastfoodShown;
- boolean dessertShown;
- boolean fruitShown;
- boolean veggieShown;
- public ImageIcon burger = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/burger.gif", "burger");
- public ImageIcon fries = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/fries.gif", "fries");
- public ImageIcon softdrink = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/softdrink.gif", "soft drink");
- public ImageIcon hotdog = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/hotdog.gif", "hot dog");
- public ImageIcon pizza = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/pizza.gif", "pizza");
- public ImageIcon icecream = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/icecream.gif", "ice cream");
- public ImageIcon pie = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/pie.gif", "pie");
- public ImageIcon cake = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/cake.gif", "cake");
- public ImageIcon donut = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/donut.gif", "donut");
- public ImageIcon treat = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/treat.gif", "treat");
- public ImageIcon grapes = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/grapes.gif", "grapes");
- public ImageIcon banana = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/banana.gif", "banana");
- public ImageIcon watermelon = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/watermelon.gif", "watermelon");
- public ImageIcon cantaloupe = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/cantaloupe.gif", "cantaloupe");
- public ImageIcon peach = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/peach.gif", "peach");
- public ImageIcon broccoli = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/broccoli.gif", "broccoli");
- public ImageIcon carrot = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/carrot.gif", "carrot");
- public ImageIcon peas = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/peas.gif", "peas");
- public ImageIcon corn = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/corn.gif", "corn");
- public ImageIcon radish = SwingSet.sharedInstance().loadImageIcon("images/ImageClub/food/radish.gif", "radish");
- SwingSet swing;
- JList listBox;
- JScrollPane scrollPane;
- DefaultListModel model = new DefaultListModel();
- JLabel priceLabel;
- int listPrice;
- JButton reset;
- JButton purchase;
- JRadioButton dessertRadioButton;
- JRadioButton veggieRadioButton;
- JRadioButton fruitRadioButton;
- JRadioButton fastfoodRadioButton;
- JCheckBox dessertCheckbox;
- JCheckBox veggieCheckbox;
- JCheckBox fruitCheckbox;
- JCheckBox fastfoodCheckbox;
- static int ITEMS = 20;
- ImageIcon[] images;
- String[] desc;
- int[] price;
-
- public ListPanel(SwingSet var1) {
- this.swing = var1;
- ((JComponent)this).setBorder(SwingSet.emptyBorder5);
- ((Container)this).setLayout(new BoxLayout(this, 0));
-
- for(int var2 = 0; var2 < ITEMS; ++var2) {
- this.model.addElement(new Integer(var2));
- }
-
- this.listBox = new ListPanel$1(this.model);
- this.listBox.setCellRenderer(new ListPanel$TestCellRenderer(this, this.listBox));
- ListPanel$2 var3 = new ListPanel$2();
- ((Container)var3).setLayout(new BoxLayout(var3, 1));
- ((JComponent)var3).setBorder(SwingSet.loweredBorder);
- ((JComponent)var3).setAlignmentY(0.0F);
- JPanel var4 = SwingSet.createHorizontalPanel(false);
- ((JComponent)var4).setAlignmentY(0.0F);
- ((JComponent)var4).setAlignmentX(0.0F);
- ((Container)var3).add(var4);
- this.purchase = new JButton("Purchase");
- this.purchase.setToolTipText("Adds the selected item(s) to your grocery bill.");
- ((Container)var4).add(this.purchase);
- ((Container)var4).add(Box.createRigidArea(SwingSet.hpad10));
- this.priceLabel = new JLabel("Total: ");
- ((Container)var4).add(this.priceLabel);
- ((Container)var3).add(Box.createRigidArea(SwingSet.vpad20));
- JLabel var5 = new JLabel("Jump To:");
- var5.setFont(var1.boldFont);
- ((Container)var3).add(var5);
- ButtonGroup var6 = new ButtonGroup();
- this.fastfoodRadioButton = new JRadioButton("Fast Food");
- this.fastfoodRadioButton.setToolTipText("Calls list.ensureVisible() to jump to the items.");
- var6.add(this.fastfoodRadioButton);
- ((Container)var3).add(this.fastfoodRadioButton);
- this.dessertRadioButton = new JRadioButton("Desserts");
- this.dessertRadioButton.setToolTipText("Calls list.ensureVisible() to jump to the items.");
- var6.add(this.dessertRadioButton);
- ((Container)var3).add(this.dessertRadioButton);
- this.fruitRadioButton = new JRadioButton("Fruits");
- this.fruitRadioButton.setToolTipText("Calls list.ensureVisible() to jump to the items.");
- var6.add(this.fruitRadioButton);
- ((Container)var3).add(this.fruitRadioButton);
- this.veggieRadioButton = new JRadioButton("Vegetables");
- this.veggieRadioButton.setToolTipText("Calls list.ensureVisible(index) to jump to the items.");
- var6.add(this.veggieRadioButton);
- ((Container)var3).add(this.veggieRadioButton);
- ((Container)var3).add(Box.createRigidArea(SwingSet.vpad20));
- var5 = new JLabel("Show:");
- var5.setFont(var1.boldFont);
- ((Container)var3).add(var5);
- this.fastfoodCheckbox = new JCheckBox("Fast Food");
- this.fastfoodCheckbox.setToolTipText("Calls list.remove(index1,indexN) to remove items.");
- this.fastfoodCheckbox.setSelected(true);
- ((Container)var3).add(this.fastfoodCheckbox);
- this.dessertCheckbox = new JCheckBox("Desserts");
- this.dessertCheckbox.setToolTipText("Calls list.remove(index1,indexN) to remove items.");
- this.dessertCheckbox.setSelected(true);
- ((Container)var3).add(this.dessertCheckbox);
- this.fruitCheckbox = new JCheckBox("Fruits");
- this.fruitCheckbox.setToolTipText("Calls list.remove(index1,indexN) to remove items.");
- this.fruitCheckbox.setSelected(true);
- ((Container)var3).add(this.fruitCheckbox);
- this.veggieCheckbox = new JCheckBox("Vegetables");
- this.veggieCheckbox.setToolTipText("Calls list.remove(index1,indexN) to remove items.");
- this.veggieCheckbox.setSelected(true);
- ((Container)var3).add(this.veggieCheckbox);
- ((Container)var3).add(Box.createGlue());
- this.reset = new JButton("Reset");
- this.reset.setToolTipText("Resets the state of the demo.");
- ((Container)var3).add(this.reset);
- this.scrollPane = new JScrollPane(this.listBox);
- this.scrollPane.setAlignmentX(0.0F);
- this.scrollPane.setAlignmentY(0.0F);
- ((Container)this).add(this.scrollPane);
- ((Container)this).add(Box.createRigidArea(SwingSet.hpad10));
- ((Container)this).add(var3);
- ListPanel$3 var7 = new ListPanel$3(this);
- this.purchase.addActionListener(var7);
- ListPanel$4 var8 = new ListPanel$4(this);
- this.fruitCheckbox.addActionListener(var8);
- this.veggieCheckbox.addActionListener(var8);
- this.dessertCheckbox.addActionListener(var8);
- this.fastfoodCheckbox.addActionListener(var8);
- ListPanel$5 var9 = new ListPanel$5(this);
- this.fruitRadioButton.addActionListener(var9);
- this.veggieRadioButton.addActionListener(var9);
- this.dessertRadioButton.addActionListener(var9);
- this.fastfoodRadioButton.addActionListener(var9);
- ListPanel$6 var10 = new ListPanel$6(this);
- this.reset.addActionListener(var10);
- }
-
- public void resetAll() {
- this.model.removeAllElements();
- this.fastfoodCheckbox.setSelected(true);
- this.fruitCheckbox.setSelected(true);
- this.veggieCheckbox.setSelected(true);
- this.dessertCheckbox.setSelected(true);
- this.fastfoodRadioButton.setEnabled(true);
- this.fruitRadioButton.setEnabled(true);
- this.veggieRadioButton.setEnabled(true);
- this.dessertRadioButton.setEnabled(true);
- this.fastfoodRadioButton.setSelected(true);
-
- for(int var1 = 0; var1 < ITEMS; ++var1) {
- this.model.addElement(new Integer(var1));
- }
-
- this.fastfoodShown = true;
- this.dessertShown = true;
- this.fruitShown = true;
- this.veggieShown = true;
- this.fastfoodIndex = 0;
- this.dessertIndex = 5;
- this.fruitIndex = 10;
- this.veggieIndex = 15;
- this.listPrice = 0;
- this.priceLabel.setText("Total: $0.00 ");
- this.listBox.ensureIndexIsVisible(this.fastfoodIndex);
- this.scrollPane.validate();
- }
- }
-