-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrain
More file actions
75 lines (72 loc) · 1.65 KB
/
train
File metadata and controls
75 lines (72 loc) · 1.65 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
67
68
69
70
71
72
73
74
75
/**
*
* @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, 50, 50);
g.setColor(Color.green);
g.fillRect(x+50, y, 50, 50);
g.setColor(Color.blue);
g.fillRect(x+100, y, 50, 50);
g.setColor(Color.pink);
g.fillRect(x+150, y, 50, 50);
g.setColor(Color.red);
g.fillRect(x+200, y, 50, 50);
g.setColor(Color.green);
g.fillRect(x+250, y, 50, 50);
g.setColor(Color.blue);
g.fillRect(x+300, y, 50, 50);
g.setColor(Color.pink);
g.fillRect(x+350, y, 50, 50);
g.setColor(Color.black);
g.fillOval(x+350, k, 25, 25);
}
panelAn(){
x=0;
y=100;
k=75;
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=75;
}
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);
}
}