-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnimateCardThread.java
32 lines (31 loc) · 981 Bytes
/
AnimateCardThread.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
public class AnimateCardThread implements Runnable{
Frame frame;
int handNum;
int xDest;
boolean isRunning;
public AnimateCardThread(Frame frame, int handNum, int xDest){
this.frame = frame;
this.xDest = xDest;
this.handNum = handNum;
isRunning = true;
}
//translates jlabel to xDest
public void run(){
frame.isAnimating = true;
int xStart= frame.handLabels.get(handNum).getX();
while(isRunning) {
for(int i = xStart;i>=xDest;i-=1){
frame.handLabels.get(handNum).setBounds(i,frame.handLabels.get(handNum).getY(),130,200);
frame.repaint();
if(i==xDest){
isRunning = false;
frame.isAnimating = false;
}
try{
Thread.currentThread().sleep(5);
}
catch(InterruptedException e){}
}
}
}
}