-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathController.java
61 lines (52 loc) · 2.02 KB
/
Controller.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
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
public class Controller {
int width = 400;
int height = 400;
JFrame frame = new JFrame("Plane Simulation");
public Controller() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
frame.add(new MenuPane());
frame.setSize(width, height);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
}
public class MenuPane extends JPanel {
public MenuPane() {
setBorder(new EmptyBorder(10, 10, 10, 10));
setLayout(new GridBagLayout());
setSize(300, 400);
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.anchor = GridBagConstraints.NORTH;
setBackground(new Color(66, 199, 255));
JLabel label = new JLabel(
"<html><h1><strong><i>Airplane Simulation <br> <center>With Java2d</center></i></strong></h1><hr></html>");
label.setForeground(Color.white);
label.setFont(new Font("Verdana", Font.BOLD + Font.ITALIC, 26));
add(label, gbc);
gbc.anchor = GridBagConstraints.CENTER;
gbc.fill = GridBagConstraints.HORIZONTAL;
JPanel buttons = new JPanel(new GridBagLayout());
buttons.setBackground(new Color(66, 199, 255));
JButton button = new JButton("Start");
buttons.add(button, gbc);
gbc.weighty = 1;
add(buttons, gbc);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
frame.setVisible(false);
new View();
}
});
}
}
}