-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyProgram.java
More file actions
60 lines (48 loc) · 1.71 KB
/
MyProgram.java
File metadata and controls
60 lines (48 loc) · 1.71 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
import java.awt.event.ActionEvent;
import java.io.File;
import javax.sound.midi.MidiUnavailableException;
import javax.swing.*;
public class MyProgram {
public static void main(String[] args) throws java.io.IOException, java.net.URISyntaxException, java.net.MalformedURLException, MidiUnavailableException {
Load.Load();
//creating instance of JFrame
JFrame window = new JFrame();
window.setSize(640, 320);
window.setLocation(0, 20);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setResizable(false);
Input input = new Input();
window.addKeyListener(input);
window.setVisible(true);
Renderer renderer = new Renderer(640, 320);
window.add(renderer);
window.pack();
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File("."));
int result = chooser.showOpenDialog(null);
File file;
if (result == JFileChooser.APPROVE_OPTION) {
file = chooser.getSelectedFile();
}
else {
return;
}
Processor processor = new Processor(file, renderer, input);
Timer screenTimer = new Timer(33, (ActionEvent e) -> {
window.repaint();
});
screenTimer.setRepeats(true);
screenTimer.start();
Timer procTimer = new Timer(1, (ActionEvent e) -> {
processor.tick();
input.updateOld();
});
procTimer.setRepeats(true);
procTimer.start();
Timer timerTimer = new Timer(1, (ActionEvent e) -> {
processor.timerTick();
});
timerTimer.setRepeats(true);
timerTimer.start();
}
}