-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleText.java
More file actions
75 lines (60 loc) · 1.92 KB
/
SimpleText.java
File metadata and controls
75 lines (60 loc) · 1.92 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
//lala lalai lalai lala lai lai
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.security.SecureRandom;
public class SimpleText implements ActionListener {
JTextField field;
JPanel panel;
JFrame frame;
public static int a;
public static int r = randomm();
public SimpleText(JFrame frame, JTextField field, JPanel panel) {
this.field = field;
this.panel = panel;
this.frame = frame;
}
public void go() {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 600);
panel.setBackground(Color.darkGray);
JLabel label = new JLabel();
label.setText("your angle is : Pi/" + String.valueOf(r) + '\n' + " please give me your velocity");
label.setForeground(Color.WHITE);
System.out.println(field.getText());
field.setText("");
field.addActionListener(this);
field.requestFocus();
panel.add(label);
panel.add(field);
frame.getContentPane().add(panel);
frame.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent event) {
String s;
s = field.getText();
field.selectAll();
a = Integer.valueOf(s);
JFrame window = new JFrame();
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setResizable(false);
window.setTitle("2D Adventure");
GamePanel gamePanel = new GamePanel();
window.add(gamePanel);
window.pack();
window.setLocationRelativeTo(null);
window.setVisible(true);
gamePanel.startGameThread();
}
public static int randomm() {
SecureRandom random = new SecureRandom();
int randInt = random.nextInt(3);
if (randInt == 0)
return 3;
if (randInt == 2)
return 4;
return 6;
}
}