-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathController.java
51 lines (42 loc) · 1.18 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
import java.awt.event.*;
/*
* Fall 2023 COSC 20203
* Lab 2: ARM, Binary, and Hex
* @author: Rahul Shrestha
* @credit: Some codes are taken from Dr Sanchez.
* @version JDK 18.0.1.1
*/
public class Controller extends Viewer implements ActionListener {
Module m;
/**
* @param args[]
*/
public static void main(String args[]) {
new Controller();
}
public Controller() {
m = new Module(this);
setButtons();
}
/**
* Add action listener for button
*/
public void setButtons() {
encode.addActionListener(this);
decodeBi.addActionListener(this);
decodeHex.addActionListener(this);
}
/**
* Add action performed for button
*/
public void actionPerformed(ActionEvent e) {
String whichWidget = e.getActionCommand();
System.out.println("calling action perform " + whichWidget + " ");
if (whichWidget.equals("Encode"))
m.armToBinaryAndHex(arm.getText());
if (whichWidget.equals("Decode Binary"))
m.binaryToArmAndHex(bi.getText());
if (whichWidget.equals("Decode Hex"))
m.hexToBinaryAndARM(hex.getText());
}
}