Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- public class Main {
- public static void main(String[] args) {
- BarberGui b = new BarberGui();
- Human human1 = new Human(b, 0);
- Human human2 = new Human(b, 1);
- Human human3 = new Human(b, 2);
- Human human4 = new Human(b, 3);
- Human human5 = new Human(b, 4);
- human1.start();
- human2.start();
- human3.start();
- human4.start();
- human5.start();
- }
- }
- class Human extends Thread {
- Button mButton;
- BarberGui mBarberGui;
- Integer mHumanID;
- public Human(BarberGui b, int i) {
- mHumanID = i;
- mBarberGui = b;
- mButton = new Button();
- mButton.setBounds(b.pos[mHumanID][0].x, b.pos[mHumanID][0].y, 20, 20);
- mButton.setFont(new Font("TimesRoman", 0, 10));
- mButton.setBackground(Color.blue);
- mButton.setForeground(Color.white);
- mButton.setLabel(new Integer(mHumanID).toString());
- mButton.setVisible(true);
- b.add(mButton);
- }
- public void Go(int i) {
- mButton.setLocation(mBarberGui.pos[mHumanID][i].x, mBarberGui.pos[mHumanID][i].y);
- }
- public void run() {
- int counter = 0;
- while(true) {
- try {
- Thread.sleep((int)(Math.random() * 5000));
- }catch(InterruptedException e) {
- System.err.println(e.toString());
- }
- if(counter == 4) counter = 0;
- Go(counter++);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement