Advertisement
AlexMatveev

View.java

Jun 18th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.36 KB | None | 0 0
  1. package ru.nsu.fit.fabric.View;
  2.  
  3. import ru.nsu.fit.fabric.Departments.Department;
  4. import ru.nsu.fit.fabric.Warehouses.Warehouse;
  5.  
  6. import javax.swing.*;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Map;
  10.  
  11. /**
  12.  * Package: ru.nsu.fit.fabric
  13.  * User:    alex
  14.  * Date:    14.06.12
  15.  * Time:    1:02
  16.  */
  17. public class View extends JFrame {
  18.  
  19.     JLabel motorCount;
  20.     JLabel motorLabel;
  21.     JLabel bodyCount;
  22.     JLabel bodyLabel;
  23.     JLabel accessoryCount;
  24.     JLabel accessoryLabel;
  25.     JLabel autoCount;
  26.     JLabel autoLabel;
  27.     JPanel motorPanel;
  28.     JPanel bodyPanel;
  29.     JPanel accessoryPanel;
  30.     JPanel panel;
  31.     JSlider motorsPerMin;
  32.     JSlider bodiesPerMin;
  33.     JSlider accessoriesPerMin;
  34.     Map<String,List<Department>> departmentMap;
  35.  
  36.     public void registerDepartment(List<Department> _department, String args){
  37.         departmentMap.put(args, _department);
  38.     }
  39.  
  40.     public void warehouseChanged(Warehouse warehouse, String args){
  41.         if("motor".equals(args))
  42.             motorCount.setText(String.valueOf(warehouse.getCountOfDetails()));
  43.         if("body".equals(args))
  44.             bodyCount.setText(String.valueOf(warehouse.getCountOfDetails()));
  45.         if("accessory".equals(args))
  46.             accessoryCount.setText(String.valueOf(warehouse.getCountOfDetails()));
  47.         if("auto".equals(args))
  48.             autoCount.setText(String.valueOf(warehouse.getCountOfDetails()));
  49.     }
  50.  
  51.     public View(){
  52.         departmentMap = new HashMap();
  53.         setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  54.         motorLabel = new JLabel("Motors in warehouse ");
  55.         motorCount = new JLabel("0");
  56.         motorsPerMin = new MyJSlider();
  57.         motorsPerMin.addChangeListener(new WarehouseLister(departmentMap,"motor"));
  58.  
  59.         bodyLabel = new JLabel("Bodies in warehouse ");
  60.         bodyCount = new JLabel("0");
  61.         bodiesPerMin = new MyJSlider();
  62.         bodiesPerMin.addChangeListener(new WarehouseLister(departmentMap, "body"));
  63.  
  64.         accessoryLabel = new JLabel("Accessories in warehouse ");
  65.         accessoryCount = new JLabel("0");
  66.         accessoriesPerMin = new MyJSlider();
  67.         accessoriesPerMin.addChangeListener(new WarehouseLister(departmentMap,"accessory"));
  68.  
  69.         autoLabel = new JLabel("Auto in warehouse ");
  70.         autoCount = new JLabel("0");
  71.  
  72.         panel = new JPanel();
  73.         motorPanel = new JPanel();
  74.         motorPanel.setLayout(new BoxLayout(motorPanel,BoxLayout.X_AXIS));
  75.         bodyPanel = new JPanel();
  76.         bodyPanel.setLayout(new BoxLayout(bodyPanel,BoxLayout.X_AXIS));
  77.         accessoryPanel = new JPanel();
  78.         accessoryPanel.setLayout(new BoxLayout(accessoryPanel,BoxLayout.X_AXIS));
  79.         motorPanel.add(motorLabel);
  80.         motorPanel.add(motorCount);
  81.         motorPanel.add(motorsPerMin);
  82.         bodyPanel.add(bodyLabel);
  83.         bodyPanel.add(bodyCount);
  84.         bodyPanel.add(bodiesPerMin);
  85.         accessoryPanel.add(accessoryLabel);
  86.         accessoryPanel.add(accessoryCount);
  87.         accessoryPanel.add(accessoriesPerMin);
  88.         panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
  89.         panel.add(motorPanel);
  90.         panel.add(bodyPanel);
  91.         panel.add(accessoryPanel);
  92.         panel.add(autoLabel);
  93.         panel.add(autoCount);
  94.  
  95.         setSize(400,300);
  96.         add(panel);
  97.         setVisible(true);
  98.     }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement