-
Notifications
You must be signed in to change notification settings - Fork 1
/
PhysicsLab.java
107 lines (81 loc) · 2.65 KB
/
PhysicsLab.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
import javax.swing.JFrame;
import javax.swing.*;
import java.awt.Container;
import javax.swing.KeyStroke;
import java.awt.event.*;
public class PhysicsLab extends JApplet implements PhysicsLabClass{
// Application
public static void main(String[] args) {
PhysicsLab_GUI lab_gui = new PhysicsLab_GUI();
lab_gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
lab_gui.setVisible(true);
}
public void beepcol() {}
public void resetPlotPL(DynamicData plot) {}
public boolean isApplet() {
return false;
}
}
//------------------------------------------------------------------------------------------
class PhysicsLab_GUI extends JFrame {
MyWorld world = new MyWorld();
public PhysicsLab_GUI() {
setTitle("My Small and Nice Physics Laboratory");
setSize(MyWorldView.WIDTH, MyWorldView.HEIGHT+50); // height+50 to account for menu height
MyWorldView worldView = new MyWorldView(world);
world.setView(worldView);
add(worldView);
LabMenuListener menuListener = new LabMenuListener(world);
this.setJMenuBar(this.createLabMenuBar(menuListener));
/* ... */
}
public JMenuBar createLabMenuBar(LabMenuListener menu_l) {
JMenuBar mb = new JMenuBar();
JMenu menu = new JMenu ("Configuration");
mb.add(menu);
JMenu subMenu = new JMenu("Insert");
menu.add(subMenu);
JMenuItem menuItem = new JMenuItem("Ball");
menuItem.addActionListener(menu_l);
subMenu.add(menuItem);
menuItem = new JMenuItem("Spring");
menuItem.addActionListener(menu_l);
subMenu.add(menuItem);
menuItem = new JMenuItem("Fixed Hook");
menuItem.addActionListener(menu_l);
subMenu.add(menuItem);
menuItem = new JMenuItem("Block");
menuItem.addActionListener(menu_l);
subMenu.add(menuItem);
menuItem = new JMenuItem("Rubber");
menuItem.addActionListener(menu_l);
subMenu.add(menuItem);
menuItem = new JMenuItem("Oscillator");
menuItem.addActionListener(menu_l);
subMenu.add(menuItem);
menuItem = new JMenuItem("My scenario");
menuItem.addActionListener(menu_l);
subMenu.add(menuItem);
menu = new JMenu("MyWorld");
mb.add(menu);
menuItem = new JMenuItem("Start");
menuItem.addActionListener(menu_l);
menu.add(menuItem);
menuItem = new JMenuItem("Stop");
menuItem.addActionListener(menu_l);
menu.add(menuItem);
JMenu submenu = new JMenu("Simulator");
menuItem = new JMenuItem("Delta time");
menuItem.addActionListener(menu_l);
submenu.add(menuItem);
menuItem = new JMenuItem("View refresh time");
menuItem.addActionListener(menu_l);
submenu.add(menuItem);
menuItem = new JMenuItem("Set gravity");
menuItem.addActionListener(menu_l);
submenu.add(menuItem);
menu.add(submenu);
/* ...*/
return mb;
}
}