-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUIController.java
More file actions
117 lines (95 loc) · 3.1 KB
/
UIController.java
File metadata and controls
117 lines (95 loc) · 3.1 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
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
import java.awt.EventQueue;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JTextPane;
import javax.swing.KeyStroke;
import java.awt.Component;
import javax.swing.JTextArea;
import javax.swing.JLabel;
import java.awt.Dimension;
import javax.swing.JCheckBox;
import pattern1.P1controller;
import pattern2.Controller;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
public class UIController {
private JFrame frame;
private final JLabel lblCommand = new JLabel("Command:");
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIController window = new UIController();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public UIController() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
@SuppressWarnings("serial")
private void initialize() {
frame = new JFrame();
frame.getContentPane().setSize(new Dimension(10, 10));
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JTextPane Command = new JTextPane();
Command.setBounds(64, 51, 362, 40);
final JTextArea textArea = new JTextArea();
textArea.setBounds(0, 101, 426, 152);
frame.getContentPane().setLayout(null);
frame.getContentPane().add(Command);
frame.getContentPane().add(textArea);
final JCheckBox chckbxSharedSolution = new JCheckBox("Shared Solution");
chckbxSharedSolution.setBounds(84, 4, 150, 36);
frame.getContentPane().add(chckbxSharedSolution);
final JCheckBox chckbxNewCheckBox = new JCheckBox("Implicit Invocation");
chckbxNewCheckBox.setBounds(230, 11, 150, 23);
frame.getContentPane().add(chckbxNewCheckBox);
JLabel lblPattern = new JLabel("Architecture:");
lblPattern.setBounds(3, 6, 103, 34);
frame.getContentPane().add(lblPattern);
lblCommand.setAlignmentX(Component.CENTER_ALIGNMENT);
lblCommand.setBounds(0, 51, 76, 40);
frame.getContentPane().add(lblCommand);
int condition = JComponent.WHEN_FOCUSED;
InputMap iMap = Command.getInputMap(condition);
ActionMap aMap = Command.getActionMap();
Controller.run("help");
String enter = "enter";
iMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), enter);
//when enter pressed react
aMap.put(enter, new AbstractAction() {
P1controller p1 = new P1controller();
@Override
public void actionPerformed(ActionEvent arg0) {
if(chckbxSharedSolution.isSelected()&&!chckbxNewCheckBox.isSelected()){
try {
textArea.setText(p1.runUIController(Command.getText()));
} catch (Exception e) {
e.printStackTrace();
}
} else if(chckbxNewCheckBox.isSelected()&&!chckbxSharedSolution.isSelected()){
textArea.setText(Controller.run(Command.getText()));
} else
textArea.setText("PLEASE TICK ONE PATTERN ONLY!!!");
}
}
);
}
}