-
Notifications
You must be signed in to change notification settings - Fork 0
/
GUI.java
144 lines (128 loc) · 4.41 KB
/
GUI.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
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
/**
* Class GUI
* @author Carlos Gallardo Polanco
*/
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.SwingConstants;
public class GUI{
private JFrame frame;
public static void main(String[] args){
EventQueue.invokeLater(new Runnable(){
public void run(){
try{
GUI window = new GUI();
window.frame.setVisible(true);
}catch(Exception e){
e.printStackTrace();
}
}
});
}
public GUI(){
initialize();
}
public void initialize(){
frame = new JFrame();
frame.setBounds(100, 100, 204, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
frame.setResizable(false);
JButton btnCA1DSimulator = new JButton("CA1D Simulator");
JButton btnCA2DSimulator = new JButton("CA2D Simulator");
JButton btnMandelbrotSet = new JButton("Mandelbrot Set");
JButton btnGameOfLife = new JButton("Game Of Life");
JButton btnChemicalReaction = new JButton("BZ Reaction");
JButton btnTumorGrowth = new JButton("Tumor Growth");
JButton btnBack = new JButton("< Back");
JLabel lbtca2d = new JLabel("Cellular Automaton 2D Simulator");
btnCA1DSimulator.setBounds(10, 31, 184, 43);
frame.getContentPane().add(btnCA1DSimulator);
btnCA1DSimulator.setVisible(true);
btnCA1DSimulator.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
GUIca1ds g = new GUIca1ds();
g.setVisible();
}
});
btnCA2DSimulator.setBounds(10, 104, 184, 43);
frame.getContentPane().add(btnCA2DSimulator);
btnCA2DSimulator.setVisible(true);
btnCA2DSimulator.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
btnCA1DSimulator.setVisible(false);
btnMandelbrotSet.setVisible(false);
btnCA2DSimulator.setVisible(false);
btnGameOfLife.setVisible(true);
btnChemicalReaction.setVisible(true);
btnTumorGrowth.setVisible(true);
btnBack.setVisible(true);
lbtca2d.setVisible(true);
}
});
btnMandelbrotSet.setBounds(10, 177, 184, 43);
frame.getContentPane().add(btnMandelbrotSet);
btnMandelbrotSet.setVisible(true);
btnMandelbrotSet.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
GUIMandelbrot g = new GUIMandelbrot();
g.setVisible();
}
});
lbtca2d.setVerticalAlignment(SwingConstants.TOP);
lbtca2d.setHorizontalAlignment(SwingConstants.LEFT);
lbtca2d.setFont(new Font("Dialog", Font.BOLD, 10));
lbtca2d.setBounds(10, 10, 184, 43);
frame.getContentPane().add(lbtca2d);
lbtca2d.setVisible(false);
btnGameOfLife.setBounds(10, 31, 184, 43);
frame.getContentPane().add(btnGameOfLife);
btnGameOfLife.setVisible(false);
btnGameOfLife.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
GUIgol g = new GUIgol();
g.setVisible();
}
});
btnChemicalReaction.setBounds(10, 104, 184, 43);
frame.getContentPane().add(btnChemicalReaction);
btnChemicalReaction.setVisible(false);
btnChemicalReaction.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
GUIBelZab g = new GUIBelZab();
g.setVisible();
}
});
btnTumorGrowth.setBounds(10, 177, 184, 43);
frame.getContentPane().add(btnTumorGrowth);
btnTumorGrowth.setVisible(false);
btnTumorGrowth.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
GUITumorG g = new GUITumorG();
g.setVisible();
}
});
btnBack.setBounds(10, 240, 184, 20);
frame.getContentPane().add(btnBack);
btnBack.setVisible(false);
btnBack.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
btnCA1DSimulator.setVisible(true);
btnMandelbrotSet.setVisible(true);
btnCA2DSimulator.setVisible(true);
btnGameOfLife.setVisible(false);
btnChemicalReaction.setVisible(false);
btnTumorGrowth.setVisible(false);
btnBack.setVisible(false);
lbtca2d.setVisible(false);
}
});
}
}