Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.nsu.fit.fabric.View;
- import ru.nsu.fit.fabric.Departments.Department;
- import ru.nsu.fit.fabric.Warehouses.Warehouse;
- import javax.swing.*;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * Package: ru.nsu.fit.fabric
- * User: alex
- * Date: 14.06.12
- * Time: 1:02
- */
- public class View extends JFrame {
- JLabel motorCount;
- JLabel motorLabel;
- JLabel bodyCount;
- JLabel bodyLabel;
- JLabel accessoryCount;
- JLabel accessoryLabel;
- JLabel autoCount;
- JLabel autoLabel;
- JPanel motorPanel;
- JPanel bodyPanel;
- JPanel accessoryPanel;
- JPanel panel;
- JSlider motorsPerMin;
- JSlider bodiesPerMin;
- JSlider accessoriesPerMin;
- Map<String,List<Department>> departmentMap;
- public void registerDepartment(List<Department> _department, String args){
- departmentMap.put(args, _department);
- }
- public void warehouseChanged(Warehouse warehouse, String args){
- if("motor".equals(args))
- motorCount.setText(String.valueOf(warehouse.getCountOfDetails()));
- if("body".equals(args))
- bodyCount.setText(String.valueOf(warehouse.getCountOfDetails()));
- if("accessory".equals(args))
- accessoryCount.setText(String.valueOf(warehouse.getCountOfDetails()));
- if("auto".equals(args))
- autoCount.setText(String.valueOf(warehouse.getCountOfDetails()));
- }
- public View(){
- departmentMap = new HashMap();
- setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
- motorLabel = new JLabel("Motors in warehouse ");
- motorCount = new JLabel("0");
- motorsPerMin = new MyJSlider();
- motorsPerMin.addChangeListener(new WarehouseLister(departmentMap,"motor"));
- bodyLabel = new JLabel("Bodies in warehouse ");
- bodyCount = new JLabel("0");
- bodiesPerMin = new MyJSlider();
- bodiesPerMin.addChangeListener(new WarehouseLister(departmentMap, "body"));
- accessoryLabel = new JLabel("Accessories in warehouse ");
- accessoryCount = new JLabel("0");
- accessoriesPerMin = new MyJSlider();
- accessoriesPerMin.addChangeListener(new WarehouseLister(departmentMap,"accessory"));
- autoLabel = new JLabel("Auto in warehouse ");
- autoCount = new JLabel("0");
- panel = new JPanel();
- motorPanel = new JPanel();
- motorPanel.setLayout(new BoxLayout(motorPanel,BoxLayout.X_AXIS));
- bodyPanel = new JPanel();
- bodyPanel.setLayout(new BoxLayout(bodyPanel,BoxLayout.X_AXIS));
- accessoryPanel = new JPanel();
- accessoryPanel.setLayout(new BoxLayout(accessoryPanel,BoxLayout.X_AXIS));
- motorPanel.add(motorLabel);
- motorPanel.add(motorCount);
- motorPanel.add(motorsPerMin);
- bodyPanel.add(bodyLabel);
- bodyPanel.add(bodyCount);
- bodyPanel.add(bodiesPerMin);
- accessoryPanel.add(accessoryLabel);
- accessoryPanel.add(accessoryCount);
- accessoryPanel.add(accessoriesPerMin);
- panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
- panel.add(motorPanel);
- panel.add(bodyPanel);
- panel.add(accessoryPanel);
- panel.add(autoLabel);
- panel.add(autoCount);
- setSize(400,300);
- add(panel);
- setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement