-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDisplayWindow.java
71 lines (65 loc) · 1.77 KB
/
DisplayWindow.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
package Projects;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import javax.swing.*;
import javax.swing.event.MenuKeyEvent;
import javax.swing.event.MenuKeyListener;
/**
* A class that puts a graphics window on your display
*/
public class DisplayWindow extends JFrame implements ActionListener {
int xSize;
int ySize;
JMenuBar bar = new JMenuBar();
JMenu file = new JMenu("File");
JMenuItem exit = new JMenuItem("Exit");
JMenuItem reset = new JMenuItem("Reset");
/**
* Content pane that will hold the added Jpanel
*/
private Container c;
/**
* DisplayWindow constructor - no parameters
*/
public DisplayWindow(int x, int y){
super("Cell Activity Simulator Alpha");
c = this.getContentPane();
xSize = x;ySize = y;
setPreferredSize(new Dimension(xSize,ySize));
exit.addActionListener(this);
reset.addActionListener(this);
file.add(reset);file.add(exit);
bar.add(file);add(bar);
setJMenuBar(bar);
//setResizable(false);
}
/**
* Adds panel to content pane
* @parameter the panel to be added
*/
public void addPanel(JPanel p){
c.add(p);
}
/**
* consolidates the frame, makes it visible,
* causes program termination when window is closed manually
*/
public void showFrame(){
this.setLocation(350,50);
this.pack();
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
@Override
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == exit) {
System.exit(0);
}
if (arg0.getSource() == reset)
System.out.println("Reset Menu Item Pressed");
//Need to send a message to MainScreen to reset or CLEAN() the screen.
}
}