1 package jrre.gui;
2
3 import jrre.*;
4 import jrre.event.*;
5
6 import javax.swing.*;
7 import java.awt.*;
8 import java.awt.event.*;
9 import java.beans.*;
10
11 public class JRREGUI extends JFrame implements VMEventListener, ActionListener, Runnable {
12
13 private ControlGui controlGui = new ControlGui();
14 private StackFrameGUI stackFrameGUI;
15 private VMEventDispatcher eventDispatcher = new VMEventDispatcher();
16 private Timer clockCycle;
17
18 public JRREGUI(){
19 super("Java Research Runtime Environment");
20 addWindowListener(new WindowDestroyer());
21 initLayout();
22 initPanels();
23
24 setVisible(true);
25
26 controlGui.addActionListener(this);
27 clockCycle = new Timer(300, this);
28 }
29
30 private void initLayout(){
31 setSize(800,600);
32 getContentPane().setLayout(new GraphPaperLayout(new Dimension(2,3)));//new GridLayout(2,2));
33 }
34
35 private void initPanels(){
36 stackFrameGUI = new StackFrameGUI(400,300);
37
38 //propertyChange.addPropertyChangeListener(stackFrameGUI);
39
40 eventDispatcher.addEventListener(stackFrameGUI);
41
42 getContentPane().add(stackFrameGUI,new Rectangle(0,0,1,2));
43 }
44
45 public void receiveEvent(VMEvent event){
46 //System.out.println("JRREGUI received event");
47
48 eventDispatcher.fireEvent(event);
49 //repaint();
50 }
51
52 public void actionPerformed(ActionEvent event){
53
54 String action = event.getActionCommand();
55
56 //System.out.println(action);
57
58 if(event.getSource() == clockCycle){
59 JRRE.step(1);
60 }
61 //else if(action == null){
62 // clockCycle.stop();
63 //}
64 else if(action.equals("Run")){
65 clockCycle.start();
66 //JRRE.beginExecution();
67 }
68 else if(action.equals("Pause")){
69 clockCycle.stop();
70 JRRE.pause();
71 }
72 else if(action.equals("Halt")){
73 clockCycle.stop();
74 JRRE.halt();
75 }
76 else if(action.equals("Step")){
77 JRRE.step(((ControlGui)event.getSource()).getStepCount());
78 }
79 }
80
81 public void run(){}
82
83
84 }
This page was automatically generated by Maven