-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabout.java
More file actions
147 lines (122 loc) · 4.38 KB
/
about.java
File metadata and controls
147 lines (122 loc) · 4.38 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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package notejava;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.*;
/**
*
* @author Ryu Saplad>
*/
public class about extends JFrame implements ActionListener, KeyListener {
JPanel panel;
JLabel movingObject;
ImageIcon icon;
JPanel borderPanel;
JLabel information;
JLabel information2;
JLabel information3;
JLabel counterLabel;
JButton back;
int counter = 0;
about() {
back = new JButton("X");
back.setBounds(425, 5, 20, 20);
back.setBackground(Color.BLACK);
back.setFocusable(false);
back.setBorder(BorderFactory.createLineBorder(Color.BLACK));
back.setForeground(Color.RED);
back.addActionListener(this);
counterLabel = new JLabel();
counterLabel.setBounds(190, 450, 140, 50);
counterLabel.setText("Counter: " + counter);
counterLabel.setFont(new Font("sans-serif", Font.BOLD, 12));
counterLabel.setForeground(Color.BLACK);
information = new JLabel();
information.setBounds(160, 5, 140, 50);
information.setText("\"ABOUT\"\n");
information.setFont(new Font("sans-serif", Font.BOLD, 30));
information.setForeground(Color.BLACK);
information2 = new JLabel();
information2.setBounds(115, 60, 250, 50);
information2.setText("Develop By: Ryu Saplad");
information2.setFont(new Font("sans-serif", Font.BOLD, 20));
information2.setForeground(Color.BLACK);
icon = new ImageIcon("Rocket.gif");
movingObject = new JLabel();
movingObject.setIcon(icon);
movingObject.setBounds(170, 288, 100, 200);
panel = new JPanel();
panel.setPreferredSize(new Dimension(450, 510));
panel.setBorder(BorderFactory.createLineBorder(new Color(240, 255, 255)));
panel.setBackground(new Color(248, 248, 255));
panel.setLayout(null);
panel.add(back);
panel.add(counterLabel);
panel.add(information);
panel.add(information2);
panel.add(movingObject);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setUndecorated(true);
this.setSize(new Dimension(460, 520));
this.setLayout(new FlowLayout());
//this.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
this.setLocationRelativeTo(null);
this.setResizable(false);
this.setTitle("About");
this.add(panel);
this.setVisible(true);
this.addKeyListener(this);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
switch (e.getKeyCode()) {
case 65:
counter += 1;
counterLabel.setText("Counter: " + counter);
movingObject.setLocation(movingObject.getX() - 10, movingObject.getY());
break;
case 87:
counter += 1;
counterLabel.setText("Counter: " + counter);
movingObject.setLocation(movingObject.getX(), movingObject.getY() - 10);
break;
case 83:
counter += 1;
counterLabel.setText("Counter: " + counter);
movingObject.setLocation(movingObject.getX(), movingObject.getY() + 10);
break;
case 68:
counter += 1;
counterLabel.setText("Counter: " + counter);
movingObject.setLocation(movingObject.getX() + 10, movingObject.getY());
break;
}
if (counter == 100) {
String[] choices = {"OK"};
movingObject.setVisible(false);
counterLabel.setText("Times up");
int getInput = JOptionPane.showOptionDialog(null, "TIMES UP!", "Sorry :(!",
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, choices, choices[0]);
if (getInput == 0) {
this.hide();
}
}
}
@Override
public void keyReleased(KeyEvent e) {
}
@Override
@SuppressWarnings("deprecation")
public void actionPerformed(ActionEvent e) {
if (e.getSource() == back) {
this.hide();
}
}
}