-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
116 lines (62 loc) · 2.39 KB
/
Main.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class Main extends Component implements ActionListener {
JTextField animationTextFied;
JButton startButton;
JButton pauseButton;
JButton stopButton;
JPanel superPanel;
JPanel controlPane;
JFrame window;
int yLocation;
Timer t;
@Override
public void paint(Graphics gg){
super.paint(gg);
Graphics2D g = (Graphics2D) gg;
g.fillRect( 0,0,1300,1000 );
//this.setBackground( Color.BLACK );
g.setColor( Color.WHITE );
g.setFont( new Font("Lucida console",Font.PLAIN,40) );
g.drawString( animationTextFied.getText() , 30, yLocation );
}
public Main(){
// Initialization
animationTextFied = new JTextField(20);
startButton = new JButton("Start");
startButton.addActionListener(this);
pauseButton = new JButton("Pause");
pauseButton.addActionListener(this);
stopButton = new JButton("Stop");
stopButton.addActionListener(this);
controlPane = new JPanel( new FlowLayout() );
superPanel = new JPanel( new BorderLayout() );
window = new JFrame("Moview Ending");
// Adding components
controlPane.add( startButton );
controlPane.add( pauseButton );
controlPane.add( stopButton );
superPanel.add( animationTextFied,BorderLayout.NORTH );
superPanel.add(this,BorderLayout.CENTER);
superPanel.add( controlPane,BorderLayout.SOUTH );
window.add(superPanel);
window.setSize(500,500);
window.setLocation( 200,200 );
window.setVisible( true );
window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
t = new Timer(33,this);
t.start();
}
public static void main(String[] args){
Main m = new Main();
}
@Override
public void actionPerformed(ActionEvent event ){
yLocation--;
if(yLocation<=0){
yLocation = 800;
}
paint( getGraphics() );
}
}