Exemple #1
0
  /** Creates an places the components used by the GUI. */
  private void placeComponents() {
    memory = new Resource("Memory");
    cpu = new Resource("CPU");
    io = new Resource("I/O");
    loadImages();

    backgroundPanel = new PicturePanel(background);
    getContentPane().setLayout(null);
    getContentPane().add(backgroundPanel);
    backgroundPanel.setBounds(0, 0, 494, 374);
    backgroundPanel.setLayout(null);
    backgroundPanel.add(memoryQueue);
    backgroundPanel.add(cpuQueue);
    backgroundPanel.add(ioQueue);
    backgroundPanel.add(memory);
    backgroundPanel.add(cpu);
    backgroundPanel.add(io);
    memoryQueue.setBounds(110, 20, 200, 50);
    memory.setBounds(310, 10, 90, 90);
    cpuQueue.setBounds(200, 120, 200, 50);
    cpu.setBounds(110, 110, 90, 90);
    ioQueue.setBounds(110, 220, 200, 50);
    io.setBounds(310, 210, 90, 90);

    JPanel lowerPanel = new JPanel();
    lowerPanel.setLayout(null);
    getContentPane().add(lowerPanel);
    lowerPanel.setBounds(0, 374, 494, 100);
    simulationSpeedSlider = new JSlider(0, 10000, 8000);
    lowerPanel.add(simulationSpeedSlider);
    addSliderLabels(lowerPanel, 10, 10, 474, 20, "Slow", "Fast", "Simulation speed");
    simulationSpeedSlider.setBounds(10, 30, 474, 20);
    timeElapsedLabel = new JLabel("Simulated time elapsed: " + timeElapsed + " ms.");
    lowerPanel.add(timeElapsedLabel);
    timeElapsedLabel.setBounds(10, 60, 300, 20);
    startButton = new JButton("Start simulation");
    lowerPanel.add(startButton);
    startButton.setBounds(320, 60, 154, 20);
    startButton.addActionListener(this);
  }