-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestion.java
More file actions
222 lines (190 loc) · 7.23 KB
/
Copy pathQuestion.java
File metadata and controls
222 lines (190 loc) · 7.23 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
package fyp;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.xml.sax.SAXException;
import net.sf.extjwnl.JWNLException;
import java.awt.Color;
public class Question extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Question frame = new Question();
frame.setExtendedState(6);
frame.setResizable(true);
frame.setVisible(true);
//frame.setUndecorated(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Question() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBackground(new Color(30, 144, 255));
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblNewLabel = new JLabel("Give me a Question");
lblNewLabel.setFont(new Font("Calibri", Font.PLAIN, 42));
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel.setForeground(UIManager.getColor("EditorPane.background"));
lblNewLabel.setBounds(93, 121, 495, 66);
contentPane.add(lblNewLabel);
final JTextArea textArea = new JTextArea();
textArea.setBackground(UIManager.getColor("Button.highlight"));
textArea.setFont(new Font("Lucida Bright", Font.PLAIN, 16));
textArea.setBounds(103, 200 , 450, 100);
contentPane.add(textArea);
JButton btnNewButton = new JButton("Answer");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent n) {
FileWriter write=null;
try{
write = new FileWriter ("C:/Users/Sadhana/workspace/System/src/fyp/questionFile.txt");
textArea.write(write);
//nextframe
}
catch (Exception e){
e.printStackTrace();
}
finally{
if(write != null)
try {
//trigger to start executing the main modules.
//trigger -> qts module.
RunSystem rs = new RunSystem("inputFile.txt", true);
rs.RunQuestionModule();
write.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} /*catch (JWNLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/ catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TransformerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JWNLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Answer a = new Answer();
a.setVisible(true);
a.setExtendedState(6);
a.setTitle("S.T.A.R.");
dispose();
}
}
});
btnNewButton.setBackground(new Color(50, 205, 50));
btnNewButton.setForeground(new Color(255, 255, 255));
btnNewButton.setFont(new Font("Calibri", Font.PLAIN, 20));
btnNewButton.setBounds(283, 350, 110, 35);
contentPane.add(btnNewButton);
/*
JLabel lblNewLabel1 = new JLabel("Answer");
lblNewLabel1.setBackground(UIManager.getColor("TextField.selectionForeground"));
lblNewLabel1.setForeground(UIManager.getColor("EditorPane.background"));
lblNewLabel1.setFont(new Font("Calibri", Font.PLAIN, 40));
lblNewLabel1.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel1.setBounds(190, 420, 271, 50);
contentPane.add(lblNewLabel1);
final JTextArea textArea1 = new JTextArea();
textArea1.setBackground(UIManager.getColor("Button.highlight"));
textArea1.setEditable(false);
textArea1.setFont(new Font("Lucida Bright", Font.PLAIN, 16));
textArea1.setBounds(103, 480, 450, 100);
textArea1.setLineWrap(true);
textArea1.setWrapStyleWord(true);
contentPane.add(textArea1);
textArea1.setColumns(10);
*/
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(750, 180, 450, 450);
contentPane.add(scrollPane);
JTextArea textArea2 = new JTextArea();
textArea2.setEditable(false);
scrollPane.setViewportView(textArea2);
textArea2.setFont(new Font("Lucida Bright", Font.PLAIN, 16));
textArea2.setBounds(750, 180, 450, 450);
//contentPane.add(textArea2);
try{
FileReader fr = new FileReader("C:/Users/Sadhana/workspace/System/src/fyp/inputFile.txt");
BufferedReader br = new BufferedReader(fr);
textArea2.read(br, null);
//fr.reset();
fr.close();
}
catch(Exception e)
{
}
JLabel lblNewLabel2 = new JLabel("Input Text");
lblNewLabel2.setFont(new Font("Calibri", Font.PLAIN, 42));
lblNewLabel2.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel2.setForeground(UIManager.getColor("EditorPane.background"));
lblNewLabel2.setBounds(830, 120, 250, 70);
contentPane.add(lblNewLabel2);
JLabel lblNewLabel3 = new JLabel("STAR accepts form based questions.");
lblNewLabel3.setFont(new Font("Calibri", Font.PLAIN, 28));
lblNewLabel3.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel3.setForeground(UIManager.getColor("EditorPane.background"));
lblNewLabel3.setBounds(80, 350, 535, 200);
contentPane.add(lblNewLabel3);
JLabel lblNewLabel4 = new JLabel("For example, if your question is");
lblNewLabel4.setFont(new Font("Calibri", Font.PLAIN, 28));
lblNewLabel4.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel4.setForeground(UIManager.getColor("EditorPane.background"));
lblNewLabel4.setBounds(70, 380, 550, 200);
contentPane.add(lblNewLabel4);
JLabel lblNewLabel5 = new JLabel("'Who caught the theif?' ask");
lblNewLabel5.setFont(new Font("Calibri", Font.PLAIN, 28));
lblNewLabel5.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel5.setForeground(UIManager.getColor("EditorPane.background"));
lblNewLabel5.setBounds(70, 410, 500, 200);
contentPane.add(lblNewLabel5);
JLabel lblNewLabel6 = new JLabel("'X caught the theif'");
lblNewLabel6.setFont(new Font("Calibri", Font.PLAIN, 28));
lblNewLabel6.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel6.setForeground(UIManager.getColor("EditorPane.background"));
lblNewLabel6.setBounds(70, 440, 500, 200);
contentPane.add(lblNewLabel6);
}
}