-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuserPanel.java
More file actions
93 lines (83 loc) · 3.22 KB
/
Copy pathuserPanel.java
File metadata and controls
93 lines (83 loc) · 3.22 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
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
public class userPanel extends JFrame {
private JPanel userPanel;
private JButton survey1Button;
private JButton survey2Button;
private JButton backToMainPageButton;
public userPanel(String SSN){
survey1Button.setText(getSurveyName().get(0)+"("+getSurveyDes().get(0)+")");
survey2Button.setText(getSurveyName().get(1)+"("+getSurveyDes().get(1)+")");
setContentPane(userPanel);
setTitle("User Panel");
setSize(500,500);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setVisible(true);
backToMainPageButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
mainPanel mainPanel = new mainPanel();
mainPanel.setVisible(true);
setVisible(false);
}
});
survey1Button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
surveyPage1 surveyPage1 = new surveyPage1(SSN);
surveyPage1.setVisible(true);
setVisible(false);
}
});
survey2Button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
surveyPage2 surveyPage2 = new surveyPage2(SSN);
surveyPage2.setVisible(true);
setVisible(false);
}
});
}
public List<String> getSurveyName(){
List<String> list=new ArrayList<String>();
try {
//connection with database
Class.forName("org.sqlite.JDBC");
java.sql.Connection connection = DriverManager.getConnection("jdbc:sqlite:data.sqlite");
java.sql.Statement statement = connection.createStatement();
//survey name query
ResultSet resultSet = statement.executeQuery("SELECT * FROM surveyy");
while (resultSet.next()){
list.add(resultSet.getString("Survey_name"));
}
}
catch (Exception ioException){
ioException.printStackTrace();
}
return list;
}
public List<String> getSurveyDes(){
List<String> list=new ArrayList<String>();
try {
Class.forName("org.sqlite.JDBC");
java.sql.Connection connection = DriverManager.getConnection("jdbc:sqlite:data.sqlite");
java.sql.Statement statement = connection.createStatement();
//survey description query
ResultSet resultSet = statement.executeQuery("SELECT * FROM surveyy");
while (resultSet.next()){
list.add(resultSet.getString("Survey_des"));
}
}
catch (Exception ioException){
ioException.printStackTrace();
}
return list;
}
}