-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestSwing.java
238 lines (208 loc) · 7.57 KB
/
TestSwing.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
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
package fyp;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JComboBox;
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;
public class TestSwing extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel contentPane;
public String wholetext;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
TestSwing frame = new TestSwing();
//frame.setSize(1000, 700);
frame.setExtendedState(6);
frame.setResizable(true);
frame.setVisible(true);
frame.setTitle("S.T.A.R.");
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public TestSwing() {
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 label1 = new JLabel("What shall I learn today?");
label1.setForeground(UIManager.getColor("EditorPane.background"));
label1.setHorizontalAlignment(SwingConstants.CENTER);
label1.setFont(new Font("Calibri", Font.PLAIN, 45));
label1.setBounds(450, 100, 500, 75);
contentPane.add(label1);
JLabel label2 = new JLabel("(Give me a Text)");
label2.setForeground(UIManager.getColor("EditorPane.background"));
label2.setFont(new Font("Calibri", Font.PLAIN, 26));
label2.setHorizontalAlignment(SwingConstants.CENTER);
label2.setBounds(600, 188, 180, 20);
contentPane.add(label2);
/*final JTextPane textPane = new JTextPane();
textPane.setBackground(UIManager.getColor("Button.highlight"));
textPane.setFont(new Font("Lucida Bright", Font.PLAIN, 14));
textPane.setBounds(500, 275, 400, 150);
contentPane.add(textPane);*/
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(400, 250, 600, 120);
contentPane.add(scrollPane);
final JTextArea textArea = new JTextArea();
scrollPane.setViewportView(textArea);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setBackground(UIManager.getColor("Button.highlight"));
textArea.setFont(new Font("Lucida Bright", Font.PLAIN, 14));
textArea.setBounds(400, 250, 600, 120);
String Story[] = {"Boyandthewolf" , "Belle"};
final JComboBox comboBox = new JComboBox(Story);
comboBox.setEditable(true);
comboBox.setBounds(600, 540, 200, 25);
contentPane.add(comboBox);
final JButton btnNewButton = new JButton("LEARN");
btnNewButton.setBorderPainted(false);
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a) {
//System.out.println("I am here...");
FileWriter writeToFile=null;
try{
writeToFile = new FileWriter ("C:/Users/Sadhana/workspace/System/src/fyp/inputFile.txt");
// SwingWorker worker = new SwingWork();
//textPane.write(write);
textArea.write(writeToFile);
//nextframe
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
if(writeToFile != null)
try {
//trigger to start executing the main modules.
//trigger -> text simplification module.
RunSystem rs = new RunSystem("inputFile.txt", false);
rs.RunTextSimplifier();
writeToFile.close();
} catch (IOException 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();
}
Question q = new Question();
q.setVisible(true);
q.setExtendedState(6);
//System.out.println("I am here also...");
q.setTitle("S.T.A.R.");
dispose();
}
}
});
//btnNewButton.setForeground(new Color(0, 0, 0));
btnNewButton.setBackground(new Color(50, 205, 50));
btnNewButton.setForeground(new Color(255, 255, 255));
btnNewButton.setFont(new Font("Calibri", Font.PLAIN, 20));
btnNewButton.setBounds(652, 390, 100, 35);
contentPane.add(btnNewButton);
JLabel lblNewLabel = new JLabel("(Give me a file)");
lblNewLabel.setForeground(UIManager.getColor("EditorPane.background"));
lblNewLabel.setFont(new Font("Calibri", Font.PLAIN, 26));
lblNewLabel.setBounds(615, 460, 300, 40);
contentPane.add(lblNewLabel);
JButton fileButton = new JButton("LEARN FILE");
fileButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent a) {
// TODO Auto-generated method stub
String selectStory = (String) comboBox.getItemAt(comboBox.getSelectedIndex());
//label.setText(selectStory);
try {
FileReader fr=new FileReader("C:/Users/Sadhana/workspace/System/src/fyp/"+selectStory+".txt");
FileWriter fw=new FileWriter("C:/Users/Sadhana/workspace/System/src/fyp/inputFile.txt");
int c = fr.read();
while(c!=-1) {
fw.write(c);
c = fr.read();
}
fr.close();
fw.close();
}
catch(IOException e) {
System.out.println(e);
}
//send String selectStory to runSystem
try {
RunSystem rs = new RunSystem(selectStory+".txt",true);
rs.RunTextSimplifier();
} catch (FileNotFoundException | JWNLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException 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();
}
Question q = new Question();
q.setVisible(true);
q.setExtendedState(6);
//System.out.println("I am here also...");
q.setTitle("S.T.A.R.");
dispose();
}
});
fileButton.setBackground(new Color(50, 205, 50));
fileButton.setForeground(new Color(255, 255, 255));
fileButton.setFont(new Font("Calibri", Font.PLAIN, 20));
fileButton.setBounds(652, 610, 130, 35);
contentPane.add(fileButton);
}
}