hi..
I don't know why the circle doesn't move ..
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MouseGameV2 extends JFrame implements MouseMotionListener {
CircleClass a[];
Graphics gx;
int m = 5;
Thread move1;
//---------------------//
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JPanel p3 = new JPanel();
JPanel p4 = new JPanel();
JPanel p5 = new JPanel();
JLabel tL = new JLabel(" Your Time >> ");
JLabel mL = new JLabel(" Minute(s)");
JTextField mF = new JTextField ("0");
JLabel sL = new JLabel(" Second(s)");
JTextField sF = new JTextField ("0");
JLabel spaceL = new JLabel (" ");
//---------------------//
public MouseGameV2() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("MouseGame");
setSize(500, 500);
p1.setLayout(new GridLayout(1,5));
mF.setEditable(false);
sF.setEditable(false);
p1.add(tL); p1.add(mF); p1.add(mL); p1.add(sF); p1.add(sL);
add(p1, BorderLayout.NORTH);
p2.setLayout(new FlowLayout());
p2.add(p3);
p3.setBackground(Color.WHITE);
p2.setBackground(Color.WHITE);
add(p2,BorderLayout.CENTER);
p2.addMouseMotionListener(this);
a = new CircleClass[m];
for(int i = 0 ; i < a.length ; i++){
a[i] = new CircleClass(32+(i*2),66-(i*7),50,50,1,1);
}
setVisible(true);
}
public class ToMove{
public ToMove(){
Thread move1 = new Thread(){
public void run(){
while (true){
try{Thread.sleep(20);} catch(InterruptedException e){System.out.println("Ooops ..!!"); System.exit(0);}
// for(int i = 0; i < m; i++){
// a[i].move();
System.out.println(" moveFOR");
// }
System.out.println(" move2");
repaint();
}
}
public void update(Graphics g){
paint(g); // to kill the blinking ..
}
};
move1.start();
}
}
//--------Timer Class--------//
public class TimerClass {
public TimerClass(){
Thread time1 = new Thread(){
public void run(){
int sec = 55;
int min = 0;
int i = 0;
while(true){
sF.setText(""+ sec++);
if(sec == 60){
sec=0;
mF.setText(""+(++min));
new CircleClass(50,50,50,50,1,1).paint(getGraphics());
}
try{
Thread.sleep(1000);
} catch(InterruptedException ex){
System.out.println("ERROR");
System.exit(0);
}
}
}
};
time1.start();
}
}
//--------Timer Class--------//
public void mouseDragged(MouseEvent e) {
}
public void mouseMoved(MouseEvent e) {
System.out.println(e.getX() + " .... " + e.getY());
}
public static void main(String [] args){
new MouseGameV2().new TimerClass();
}
}