-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVector2.java
More file actions
72 lines (58 loc) · 1.84 KB
/
Copy pathVector2.java
File metadata and controls
72 lines (58 loc) · 1.84 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
package com.components;
import com.javagamemaker.javagameengine.msc.Debug;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Vector2 extends JPanel {
public com.javagamemaker.javagameengine.msc.Vector2 vector2 = com.javagamemaker.javagameengine.msc.Vector2.zero;
JTextField x;
JTextField y;
public Vector2(){
init();
}
public Vector2(com.javagamemaker.javagameengine.msc.Vector2 value){
vector2 = value;
init();
}
public void init(){
setMaximumSize(new Dimension(1000,20));
setLayout(new BoxLayout(this,BoxLayout.X_AXIS));
x = new JTextField();
x.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
vector2.setX(Float.parseFloat(x.getText()));
update();
}
});
y = new JTextField();
y.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
vector2.setY(Float.parseFloat(y.getText()));
update();
}
});
if(vector2 != null){
x.setText(String.valueOf(vector2.getX()));
y.setText(String.valueOf(vector2.getY()));
}
add(new JLabel("X: "));
add(x);
add(new JLabel("Y: "));
add(y);
}
public void update(){
x.setText(String.valueOf(vector2.getX()));
y.setText(String.valueOf(vector2.getY()));
repaint();
validate();
}
public com.javagamemaker.javagameengine.msc.Vector2 getVector2() {
return vector2;
}
public void setVector2(com.javagamemaker.javagameengine.msc.Vector2 vector2) {
this.vector2 = vector2;
}
}