package frame;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JFrame;
import javax.swing.JLabel;
/**
*
* @author Paolo
*/
public class Palle
extends JFrame{
private int angolo;
public Mouse(){
this.angolo=0;
}
@Override
int random
=(int) (Math.
random()*360
);
int vel
=(int) (Math.
random()*20
);
vel+=2;
lab2.setText("Ultima velocità /angolo: "+vel+"/"+random);
Palla p= new Palla(new Angle(random), vel);
add(p);
p.start();
this.angolo++;
lab.setText("Conto palle: "+this.angolo);
}
}
public Palle() {
super("Palle");
this.setResizable(false);
this.setLayout(null);
this.
setDefaultCloseOperation(JFrame.
EXIT_ON_CLOSE);
this.setBounds(100, 100, 400, 400);
this.
lab= new JLabel("Conto palle: 0");
this.lab.setBounds(0, 0, 100, 16);
this.lab.setVisible(true);
this.add(this.lab);
this.
lab2= new JLabel("Ultima velocità /angolo: 0/0");
this.lab2.setBounds(0, 16, 200, 16);
this.lab2.setVisible(true);
this.add(this.lab2);
this.addMouseListener(new Mouse());
}
public static void main
(String...
args) {
new Palle().setVisible(true);
}
}