forked from kzaemrio/BadApple
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BadApple.java
85 lines (74 loc) · 1.83 KB
/
BadApple.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
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
76
77
78
79
80
81
82
83
84
85
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.util.StringTokenizer;
import java.io.FileReader;
import java.io.BufferedReader;
import java.applet.Applet;
import java.applet.AudioClip;
class BadApple extends JFrame {
private static AudioClip music;
private static javax.swing.Timer timer;
private Listener listener;
public BadApple() {
music = Applet
.newAudioClip(this.getClass().getResource("BadApple.wav"));
listener = new Listener();
getContentPane().add(listener);
timer = new javax.swing.Timer(32, listener);
setTitle("BadApple");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(650, 510);
setVisible(true);
}
public static void main(String[] args) {
new BadApple();
music.play();
timer.start();
}
class Listener extends JPanel implements ActionListener {
private String fileName;
private int i = 1;
public void actionPerformed(ActionEvent e) {
repaint();
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (i == 6569) {
System.exit(0);
}
else {
i++;
}
fileName = "data/out (" + i + ").txt";
FileReader fr = null;
BufferedReader br = null;
try {
fr = new FileReader(fileName);
br = new BufferedReader(fr);
String temp;
int j = 0;
while ((temp = br.readLine()) != null) {
StringTokenizer st = new StringTokenizer(temp);
while (st.hasMoreTokens()) {
int start = Integer.parseInt(st.nextToken());
int end = Integer.parseInt(st.nextToken());
g.drawLine(start, j, end, j);
}
j++;
}
} catch (Exception e) {
System.out.println(e);
} finally {
try {
fr.close();
br.close();
} catch (Exception e) {
System.out.println(e);
}
}
}
}
}