-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPickup
More file actions
66 lines (62 loc) · 1.32 KB
/
Pickup
File metadata and controls
66 lines (62 loc) · 1.32 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
*
* @author $_F
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class panelAn extends JPanel implements ActionListener{
int x;
int y;
int k;
boolean b1,b2;
public void paint(Graphics g){
super.paint(g);
g.setColor(Color.red);
g.fillRect(x, y, 10, 10);
g.setColor(Color.green);
g.fillRect(x+10, y-40, 80, 50);
g.setColor(Color.blue);
g.fillRect(x+80, y-70, 40, 80);
g.setColor(Color.black);
g.fillOval(x-10, k, 15, 15);
}
panelAn(){
x=0;
y=100;
k=100;
b1=true;
b2=true;
new Timer(10,this).start();
}
@Override
public void actionPerformed(ActionEvent e) {
if(b1==true){
if(x==800){
x=-80;
}
x+=5;
}
if(b2==true){
if(k==0){
k=100;
}
k-=5;
}
repaint();
}
}
class Frame extends JFrame{
Frame(){
this.add(new panelAn());
this.setTitle("inw");
}
}
public class FinalLab {
public static void main(String[] args) {
Frame f = new Frame();
f.setSize(800, 600);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}