-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEquationEnter.java
More file actions
55 lines (48 loc) · 1.83 KB
/
EquationEnter.java
File metadata and controls
55 lines (48 loc) · 1.83 KB
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
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.*;
public class EquationEnter extends JPanel{
private int x = 0;
private int y = 0;
private int w;
private int h;
JButton submitButton;
JTextField textfield;
CircuitDisplay circuitDisplay;
BinaryTree tree;
public EquationEnter(CircuitDisplay circuitDisplay){
this.circuitDisplay = circuitDisplay;
w = GUI.getWIDTH();
h = GUI.getHEIGHT() / 6;
setBounds(x, y, w, h);
setBackground(GUI.getLightPurple());
textfield = new JTextField(25);
textfield.setFont(GUI.getNormalFont());
textfield.setBounds(w/10, h/10, w/2, h/3);
add(textfield);
submitButton = new JButton("Submit");
submitButton.setFont(GUI.getNormalFont());
submitButton.addActionListener(actions);
add(submitButton);
}
public BinaryTree getTree(){
return tree;
}
private ActionListener actions = new ActionListener(){
public void actionPerformed(ActionEvent e){
if(e.getSource() == submitButton){
tree = Translator.translate(textfield.getText());
//AndNode dot = new AndNode();
//LetterNode A = new LetterNode('A');
//LetterNode B = new LetterNode('B');
//LetterNode C = new LetterNode('C');
//BinaryTree tree1 = new BinaryTree(dot, new BinaryTree(dot, new BinaryTree(A, null, null), new BinaryTree(B, null, null)), new BinaryTree(C, null, null));
System.out.println(BinaryTree.printTree(tree));
//System.out.println(BinaryTree.printRight(tree));
//circuitDisplay.drawTree(tree, 500, 500);
circuitDisplay.setTree(tree);
}
}
};
}