-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain
404 lines (322 loc) · 13.8 KB
/
Main
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
import java.awt.*;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ItemListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.swing.JPasswordField;
import javax.swing.border.BevelBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import org.jfree.chart.*;
import org.jfree.chart.plot.PiePlot;
import org.jfree.*;
import org.jfree.data.*;
import org.jfree.data.general.DefaultPieDataset;
public class Main {
private static JTextField textField;
private static JPasswordField textField_1;
private static JTextField txtEnterAKey;
public static void main(String[] args) {
//Starting the frame window.
JFrame frame = new JFrame("Sentiment Analysis");
frame.setSize(600, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
//Font
Font font_1 = new Font("Tahoma", Font.BOLD, 20);
Font font_2 = new Font("Comic Sans Ms", Font.BOLD, 15);
//Components
JPanel panel_1 = new JPanel();
JPanel panel_2 = new JPanel();
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.LEFT, JTabbedPane.WRAP_TAB_LAYOUT);
//frame.getContentPane().add(tabbedPane, BorderLayout.NORTH);
tabbedPane.setFont(font_2);
tabbedPane.setBounds(30, 30, 550, 500);
tabbedPane.add("HomeView", panel_1);
//Panel_1
//group and organize.
//panel_1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createBevelBorder(15),"Sign-in/Log-in Window"));
//panel_1.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
panel_1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED),"Sign-in/Login Window", TitledBorder.LEFT, TitledBorder.ABOVE_TOP, font_2, Color.white));
GroupLayout groupLayout = new GroupLayout(panel_1);
panel_1.setLayout(groupLayout);
groupLayout.setAutoCreateContainerGaps(true);
groupLayout.setAutoCreateContainerGaps(true);
//groupLayout.preferredLayoutSize(container);
JLabel lblName = new JLabel("Name : ");
lblName.setForeground(new Color(255, 255, 255));
panel_1.add(lblName);
lblName.setFont(font_1);
textField = new JTextField();
panel_1.add(textField);
textField.setColumns(15);
JLabel lblPassword = new JLabel("PassWord:");
lblPassword.setForeground(new Color(255, 255, 255));
lblPassword.setFont(font_1);
panel_1.add(lblPassword);
textField_1 = new JPasswordField();
panel_1.add(textField_1);
textField_1.setColumns(15);
//Appear the characters.
JCheckBox pwCheckBox = new JCheckBox("Show PassWord");
panel_1.add(pwCheckBox);
pwCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if(pwCheckBox.isSelected())
textField_1.setEchoChar('\0');
else
textField_1.setEchoChar('•');
}
});
pwCheckBox.setFont(font_2);
JButton btnRegister = new JButton("Register");
btnRegister.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
btnRegister.setBackground(new Color(255, 255, 255));
panel_1.add(btnRegister);
btnRegister.setFont(font_2);
JButton btnSignin = new JButton("Log-In");
btnSignin.setBackground(new Color(255, 255, 255));
panel_1.add(btnSignin);
btnSignin.setFont(font_2);
JButton ForgetPW = new JButton("Forget Password");
ForgetPW.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
}
});
panel_1.add(ForgetPW);
ForgetPW.setFont(font_2);
groupLayout.setHorizontalGroup(groupLayout.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(lblName).addComponent(lblPassword))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,GroupLayout.DEFAULT_SIZE, 20)
.addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(textField, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(textField_1, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(groupLayout.createSequentialGroup()
.addComponent(btnRegister, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE,20)
.addComponent(btnSignin, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
//.addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(ForgetPW).addComponent(pwCheckBox))
)
.addGroup(groupLayout.createSequentialGroup()
.addComponent(ForgetPW, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, 20)
.addComponent(pwCheckBox, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
)
)
);
groupLayout.setVerticalGroup(groupLayout.createSequentialGroup()
.addGap(60)
.addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(lblName)
.addComponent(textField)
)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,GroupLayout.DEFAULT_SIZE, 20)
.addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(lblPassword)
.addComponent(textField_1)
)
.addGap(30)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,GroupLayout.DEFAULT_SIZE, 20)
.addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(btnRegister)
.addComponent(btnSignin)
)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,GroupLayout.DEFAULT_SIZE, 20)
.addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(ForgetPW)
.addComponent(pwCheckBox)
)
);
/*groupLayout.setHorizontalGroup(groupLayout.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(lblName).addComponent(lblPassword))
.addGap(20)
.addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(textField, GroupLayout.PREFERRED_SIZE, 150, GroupLayout.PREFERRED_SIZE)
.addComponent(textField_1, GroupLayout.PREFERRED_SIZE, 150, GroupLayout.PREFERRED_SIZE)
.addGroup(groupLayout.createSequentialGroup()
.addComponent(btnRegister, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
.addGap(2)
.addComponent(btnSignin, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
.addGroup(groupLayout.createSequentialGroup().addComponent(ForgetPW, GroupLayout.PREFERRED_SIZE, 200, GroupLayout.PREFERRED_SIZE))
)
)
);
groupLayout.setVerticalGroup(groupLayout.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(lblName)
.addComponent(textField, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
)
.addGap(15)
.addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(lblPassword)
.addComponent(textField_1, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
)
.addGap(15)
.addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(btnRegister, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
.addComponent(btnSignin, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
)
.addGap(15)
.addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(ForgetPW, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
)
);*/
//Panel_2
tabbedPane.add("Details", panel_2);
panel_2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED),"Searching Window", TitledBorder.LEFT, TitledBorder.ABOVE_TOP, font_2, Color.white));
String userSAWord = "";
String userZipCode = "";
txtEnterAKey = new JTextField();
txtEnterAKey.setBackground(new Color(255, 255, 255));
txtEnterAKey.setText("Enter a Key Word");
panel_2.add(txtEnterAKey);
txtEnterAKey.setColumns(15);
JTextField zipCode = new JTextField("Enter a zipCode");
zipCode.setBackground(new Color(255, 255, 255));
panel_2.add(zipCode);
zipCode.setColumns(15);
JLabel labelResult = new JLabel();
JSlider TweetSlide = new JSlider (JSlider.HORIZONTAL, 20, 1000, 490);
JLabel tweetLabel = new JLabel("Selected Tweets number");
JTextField tweetNum = new JTextField();
tweetNum.setHorizontalAlignment(SwingConstants.CENTER);
tweetNum.setText(String.valueOf(TweetSlide.getValue()));
//showing lines and values in the slider.
TweetSlide.setMinorTickSpacing(50);
TweetSlide.setMajorTickSpacing(100);
TweetSlide.setPaintTicks(true);
TweetSlide.setPaintLabels(true);
panel_2.add(TweetSlide);
panel_2.add(tweetLabel);
panel_2.add(tweetNum);
//An action when we change the value of the slider
/*TweetSlide.addChangeListener(changeEvent e){
@Override
public void stateChanged(ChangeEvent e) {
tweetNum.setText(String.valueOf(TweetSlide.getValue()));
}
};*/
JButton btnSystemAnalysis = new JButton("System Analysis");
btnSystemAnalysis.setBackground(new Color(255, 255, 255));
btnSystemAnalysis.setFont(new Font("Arial", Font.BOLD, 15));
//Actions.
btnSystemAnalysis.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
panel_2.add(btnSystemAnalysis);
JButton btnClear = new JButton("Clear");
btnClear.setBackground(new Color(255, 255, 255));
btnClear.setFont(font_2);
btnClear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
panel_2.add(btnClear);
userSAWord = txtEnterAKey.getText();
userZipCode = zipCode.getText();
//group and organize.
GroupLayout groupLayout1 = new GroupLayout(panel_2);
panel_2.setLayout(groupLayout1);
groupLayout1.setAutoCreateContainerGaps(true);
groupLayout1.setAutoCreateContainerGaps(true);
groupLayout1.setHorizontalGroup(groupLayout1.createSequentialGroup()
.addGroup(groupLayout1.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(txtEnterAKey)
.addComponent(zipCode)
.addGap(10)
.addGroup(groupLayout1.createSequentialGroup()
.addComponent(btnSystemAnalysis, GroupLayout.PREFERRED_SIZE, 150, GroupLayout.PREFERRED_SIZE)
.addGap(10)
.addComponent(btnClear, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
)
.addGap(10)
.addGroup(groupLayout1.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(TweetSlide)
.addComponent(tweetLabel)
)
.addGap(10)
.addGroup(groupLayout1.createSequentialGroup()
.addComponent(tweetNum, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
)
)
);
groupLayout1.setVerticalGroup(groupLayout1.createSequentialGroup()
.addGroup(groupLayout1.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(txtEnterAKey, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
)
.addGap(15)
.addGroup(groupLayout1.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(zipCode, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
)
.addGap(15)
.addGroup(groupLayout1.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(btnSystemAnalysis, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
.addComponent(btnClear, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
)
.addGap(15)
.addGroup(groupLayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(TweetSlide, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
)
.addGap(15)
.addGroup(groupLayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(tweetLabel, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
)
.addGap(15)
.addGroup(groupLayout1.createParallelGroup(GroupLayout.Alignment.CENTER).addComponent(tweetNum, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
)
);
/*zipCode.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public voud keyPressed(KeyEvent e) {
if(e.getKeyCode() = KeyEvent.VK_ENTER)
labelResult.setText(zipCode.getText());
}
@Override
public void keyReleased(KeyEvent e) {}
});*/
//Panel_3
JPanel panel_3 = new JPanel();
tabbedPane.addTab("Graphs", panel_3);
//Components
JButton btnData = new JButton("Loaded Data");
btnData.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent argO) {
}
});
JScrollPane scrollPane = new JScrollPane();
JTable table = new JTable();
scrollPane.setViewportView(table);
panel_3.add(btnData);
panel_3.add(scrollPane);
//Font Editing
//Color Editing
panel_1.setBackground(Color.DARK_GRAY);
panel_2.setBackground(Color.DARK_GRAY);
panel_3.setBackground(Color.DARK_GRAY);
//MenuBar.
JMenuBar menuBar = new JMenuBar();
frame.setJMenuBar(menuBar);
JMenu mnNewMenu = new JMenu("File");
menuBar.add(mnNewMenu);
JMenuItem mntmNewMenuItem = new JMenuItem("Quit");
mnNewMenu.add(mntmNewMenuItem);
JMenu mnNewMenu_1 = new JMenu("Settings");
menuBar.add(mnNewMenu_1);
JMenuItem mntmNewMenuItem_2 = new JMenuItem("About");
mnNewMenu_1.add(mntmNewMenuItem_2);
JMenuItem mntmNewMenuItem_1 = new JMenuItem("Edit API Key");
mnNewMenu_1.add(mntmNewMenuItem_1);
frame.setVisible(true);
}
}