Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Grupp25;
- import java.awt.BorderLayout;
- import java.awt.EventQueue;
- import java.awt.Font;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.KeyAdapter;
- import java.awt.event.KeyEvent;
- import java.sql.SQLException;
- import java.util.ArrayList;
- import javax.swing.JButton;
- import javax.swing.JComboBox;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JOptionPane;
- import javax.swing.JPanel;
- import javax.swing.JScrollPane;
- import javax.swing.JSeparator;
- import javax.swing.JTabbedPane;
- import javax.swing.JTable;
- import javax.swing.JTextField;
- import javax.swing.UIManager;
- import javax.swing.event.ListSelectionEvent;
- import javax.swing.event.ListSelectionListener;
- import javax.swing.table.DefaultTableModel;
- public class MainView {
- private Controller controller;
- private JFrame frmStudentAdministration;
- private JTextField textFieldSsid;
- private JTextField textFieldSname;
- private JTextField textFieldSaddress;
- private JTextField textFieldRegSsid;
- private JTextField textFieldRegCcode;
- private JTextField textFieldGradeSsid;
- private JTextField textFieldGradeCcode;
- private JTextField textFieldSearchSsid;
- private JTextField textFieldSearchSname;
- private JTextField textFieldSearchAddress;
- private JTextField textFieldSearchCcode;
- private JTextField textFieldSearchCname;
- private JTextField textFieldSearchCpoints;
- private JTextField textFieldSearchListCcode;
- private JTextField textFieldAdvCcode_1;
- private JTextField textFieldAdvProcent;
- private JTextField textFieldStudentFlow;
- private JTextField textFieldSearchGradeSsid;
- private JTextField textFieldSearchGradeCcode;
- private JTextField textFieldCcode;
- private JTextField textFieldCname;
- private JTextField textFieldCpoints;
- private JTextField textFieldGradeSemester;
- private DefaultTableModel dataModel;
- private DefaultTableModel dataModel_1;
- private DefaultTableModel dataModel_2;
- private DefaultTableModel dataModel_3;
- private DefaultTableModel dataModel_4;
- private JTable table;
- private JTable table_1;
- private JTable table_2;
- private JTable table_3;
- private JScrollPane scrollPane;
- private JScrollPane scrollPane_1;
- private JScrollPane scrollPane_2;
- private JScrollPane scrollPane_3;
- /**
- * Launch app.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- MainView window = new MainView();
- window.frmStudentAdministration.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the app.
- */
- public MainView() {
- initialize();
- this.controller = new Controller();
- }
- /**
- .
- */
- private void initialize() {
- frmStudentAdministration = new JFrame();
- frmStudentAdministration.setTitle("Student administration");
- frmStudentAdministration.setBounds(100, 100, 877, 731);
- frmStudentAdministration.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
- frmStudentAdministration.getContentPane().add(tabbedPane, BorderLayout.CENTER);
- dataModel_1 = new DefaultTableModel();
- String[] headersReg = { "Course code", "Course name", "Course points" };
- dataModel_1.setColumnIdentifiers(headersReg);
- dataModel_2 = new DefaultTableModel();
- String[] headersCourses = { "Course code", "Course name", "Semester" };
- dataModel_2.setColumnIdentifiers(headersCourses);
- JPanel panel = new JPanel();
- tabbedPane.addTab("Start", null, panel, null);
- panel.setLayout(null);
- textFieldSsid = new JTextField();
- textFieldSsid.setBounds(134, 42, 175, 20);
- panel.add(textFieldSsid);
- textFieldSsid.setColumns(10);
- textFieldSname = new JTextField();
- textFieldSname.setBounds(134, 73, 175, 20);
- panel.add(textFieldSname);
- textFieldSname.setColumns(10);
- textFieldSaddress = new JTextField();
- textFieldSaddress.setBounds(134, 104, 175, 20);
- panel.add(textFieldSaddress);
- textFieldSaddress.setColumns(10);
- JLabel lblNewLabel = new JLabel("Student ID:");
- lblNewLabel.setBounds(41, 45, 83, 14);
- panel.add(lblNewLabel);
- JLabel lblNewLabel_1 = new JLabel("Name:");
- lblNewLabel_1.setBounds(41, 76, 83, 14);
- panel.add(lblNewLabel_1);
- JLabel lblNewLabel_2 = new JLabel("Address:");
- lblNewLabel_2.setBounds(41, 107, 83, 14);
- panel.add(lblNewLabel_2);
- JLabel lblMessageStudent = new JLabel("Message: ");
- lblMessageStudent.setFont(new Font("Tahoma", Font.PLAIN, 9));
- lblMessageStudent.setBounds(41, 179, 274, 14);
- panel.add(lblMessageStudent);
- JButton btnAddStudent = new JButton("Add student");
- btnAddStudent.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- String sSid = textFieldSsid.getText();
- String sName = textFieldSname.getText();
- String sAddress = textFieldSaddress.getText();
- try {
- if (textFieldSsid.getText().equals("") || textFieldSname.getText().equals("")) {
- lblMessageStudent.setText("Message: Could not add student.");
- } else {
- controller.addStudent(sSid, sName, sAddress);
- lblMessageStudent.setText("Message: Student added.");
- textFieldSsid.setText(null);
- textFieldSname.setText(null);
- textFieldSaddress.setText(null);
- }
- } catch (Exception e1) {
- lblMessageStudent.setText("Message: Could not add student. Already exists.");
- }
- }
- });
- btnAddStudent.setBounds(41, 145, 128, 23);
- panel.add(btnAddStudent);
- JButton btnRemoveStudent = new JButton("Remove student");
- btnRemoveStudent.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- String sSid = textFieldSsid.getText();
- try {
- if (textFieldSsid.getText().equals("")) {
- lblMessageStudent.setText("Message: Could not delete Student.");
- } else {
- controller.removeStudent(sSid);
- lblMessageStudent.setText("Message: Student removed.");
- textFieldSsid.setText(null);
- textFieldSname.setText(null);
- textFieldSaddress.setText(null);
- }
- } catch (Exception e1) {
- lblMessageStudent.setText("Message: Could not remove student.");
- }
- }
- });
- btnRemoveStudent.setBounds(181, 145, 128, 23);
- panel.add(btnRemoveStudent);
- JLabel lblAddDelete = new JLabel("add / remove student");
- lblAddDelete.setFont(new Font("Tahoma", Font.BOLD, 14));
- lblAddDelete.setBounds(41, 11, 167, 20);
- panel.add(lblAddDelete);
- JLabel lblAddDelete_1 = new JLabel("add / remove course");
- lblAddDelete_1.setFont(new Font("Tahoma", Font.BOLD, 14));
- lblAddDelete_1.setBounds(41, 250, 203, 20);
- panel.add(lblAddDelete_1);
- textFieldCcode = new JTextField();
- textFieldCcode.setBounds(127, 278, 175, 20);
- panel.add(textFieldCcode);
- textFieldCcode.setColumns(10);
- JLabel lblCourseCode = new JLabel("Course code:");
- lblCourseCode.setBounds(41, 281, 97, 14);
- panel.add(lblCourseCode);
- JLabel lblCourseName = new JLabel("Course name:");
- lblCourseName.setBounds(41, 318, 97, 14);
- panel.add(lblCourseName);
- textFieldCname = new JTextField();
- textFieldCname.setBounds(127, 315, 175, 20);
- panel.add(textFieldCname);
- textFieldCname.setColumns(10);
- textFieldCpoints = new JTextField();
- textFieldCpoints.setBounds(127, 346, 175, 20);
- panel.add(textFieldCpoints);
- textFieldCpoints.setColumns(10);
- JLabel lblCoursePoints = new JLabel("Course points:");
- lblCoursePoints.setBounds(41, 349, 86, 14);
- panel.add(lblCoursePoints);
- JLabel lblMessage_1 = new JLabel("Message:");
- lblMessage_1.setFont(new Font("Tahoma", Font.PLAIN, 9));
- lblMessage_1.setBounds(41, 428, 282, 14);
- panel.add(lblMessage_1);
- textFieldCpoints.addKeyListener(new KeyAdapter() {
- public void keyTyped(KeyEvent e) {
- char c = e.getKeyChar();
- if (!(Character.isDigit(c) || c == KeyEvent.VK_BACK_SPACE || c == KeyEvent.VK_DELETE)) {
- e.consume();
- }
- }
- });
- JButton btnAddCourse = new JButton("Add course");
- btnAddCourse.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- String cCode = textFieldCcode.getText();
- String cName = textFieldCname.getText();
- String cPoints = textFieldCpoints.getText();
- int cCp = 0;
- if (!cPoints.equals("")) {
- cCp = Integer.parseInt(cPoints);
- }
- try {
- if (textFieldCcode.getText().equals("") || textFieldCpoints.getText().equals("")) {
- lblMessage_1.setText("Message: Could not add course.");
- } else {
- controller.addCourse(cCode, cName, cCp);
- lblMessage_1.setText("Message: Course added.");
- textFieldCcode.setText(null);
- textFieldCname.setText(null);
- textFieldCpoints.setText(null);
- }
- } catch (Exception e1) {
- lblMessage_1.setText("Message: Could not add course. Course already exsist.");
- }
- }
- });
- btnAddCourse.setBounds(41, 391, 128, 23);
- panel.add(btnAddCourse);
- JButton btnDeleteCurse = new JButton("Remove course");
- btnDeleteCurse.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- String cCode = textFieldCcode.getText();
- try {
- if (textFieldCcode.getText().equals("")) {
- lblMessage_1.setText("Message: Could not remove.");
- } else {
- controller.removeCourse(cCode);
- lblMessage_1.setText("Message: Remove course.");
- textFieldCcode.setText(null);
- textFieldCname.setText(null);
- textFieldCpoints.setText(null);
- }
- } catch (Exception e1) {
- lblMessage_1.setText("Message: Could not remove course.");
- }
- }
- });
- btnDeleteCurse.setBounds(181, 391, 128, 23);
- panel.add(btnDeleteCurse);
- panel.setLayout(null);
- textFieldRegSsid = new JTextField();
- textFieldRegSsid.setBounds(410, 39, 97, 20);
- panel.add(textFieldRegSsid);
- textFieldRegSsid.setColumns(10);
- textFieldRegCcode = new JTextField();
- textFieldRegCcode.setEditable(false);
- textFieldRegCcode.setBounds(748, 86, 86, 20);
- panel.add(textFieldRegCcode);
- textFieldRegCcode.setColumns(10);
- JLabel lblNewLabel_3 = new JLabel("Student ID:");
- lblNewLabel_3.setBounds(348, 42, 84, 14);
- panel.add(lblNewLabel_3);
- JLabel lblCourseCode_1 = new JLabel("Course code:");
- lblCourseCode_1.setBounds(677, 89, 84, 14);
- panel.add(lblCourseCode_1);
- JLabel lblSemester = new JLabel("Semester:");
- lblSemester.setBounds(677, 121, 84, 14);
- panel.add(lblSemester);
- JComboBox<String> comboBoxRegSemester = new JComboBox<String>();
- comboBoxRegSemester.addItem("HT13");
- comboBoxRegSemester.addItem("VT14");
- comboBoxRegSemester.addItem("HT14");
- comboBoxRegSemester.addItem("VT15");
- comboBoxRegSemester.addItem("HT15");
- comboBoxRegSemester.setBounds(748, 118, 86, 20);
- panel.add(comboBoxRegSemester);
- JLabel lblNewLabelInteraction = new JLabel("Message:");
- lblNewLabelInteraction.setFont(new Font("Tahoma", Font.PLAIN, 9));
- lblNewLabelInteraction.setBounds(679, 191, 376, 14);
- panel.add(lblNewLabelInteraction);
- JButton btnNewButtonRegStudying = new JButton("Apply");
- btnNewButtonRegStudying.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- String sSid = textFieldRegSsid.getText();
- String cCode = textFieldRegCcode.getText();
- String semester = comboBoxRegSemester.getSelectedItem().toString();
- try {
- if( textFieldRegSsid.getText().equals("")){
- lblNewLabelInteraction.setText("no student ID entered");
- }
- else{
- controller.addStudentStudying(sSid, cCode, semester);
- lblNewLabelInteraction.setText("stundent successfully added to course");
- }
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- }
- });
- btnNewButtonRegStudying.setBounds(748, 158, 86, 22);
- panel.add(btnNewButtonRegStudying);
- JLabel lblAddingStudentTo = new JLabel("Add student to course");
- lblAddingStudentTo.setFont(new Font("Tahoma", Font.BOLD, 14));
- lblAddingStudentTo.setBounds(348, 11, 318, 20);
- panel.add(lblAddingStudentTo);
- table_1 = new JTable(dataModel_1);
- scrollPane_1 = new JScrollPane(table_1);
- scrollPane_1.setBounds(348, 88, 319, 138);
- panel.add(scrollPane_1);
- JButton btnPopulateCourse = new JButton("Fill list");
- btnPopulateCourse.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- try {
- dataModel_1.setRowCount(0);
- ArrayList<Course> courseList = controller.getAllCourse();
- for (Course c : courseList) {
- String[] col = new String[3];
- col[0] = c.getCcode();
- col[1] = c.getCname();
- String cPoints = Integer.toString(c.getCcp());
- col[2] = cPoints;
- dataModel_1.addRow(col);
- }
- } catch (SQLException e1) {
- JOptionPane.showMessageDialog(null, "Could not populate list \n Error: " + e1);
- }
- }
- });
- btnPopulateCourse.setBounds(517, 38, 116, 23);
- panel.add(btnPopulateCourse);
- JLabel lblSelectACourse = new JLabel("Vβ°lj en kurs frΓn listan:");
- lblSelectACourse.setBounds(348, 70, 212, 14);
- panel.add(lblSelectACourse);
- JSeparator separator = new JSeparator();
- separator.setBounds(10, 237, 836, 2);
- panel.add(separator);
- table_1.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
- public void valueChanged(ListSelectionEvent event) {
- if (table_1.getSelectedRow() >= 0) {
- try {
- textFieldRegCcode.setText(table_1.getValueAt(table_1.getSelectedRow(), 0).toString());
- } catch (Exception e1) {
- JOptionPane.showMessageDialog(null, "Something went wrong!");
- }
- }
- }
- });
- textFieldGradeSsid = new JTextField();
- textFieldGradeSsid.setBounds(424, 278, 97, 20);
- panel.add(textFieldGradeSsid);
- textFieldGradeSsid.setColumns(10);
- JLabel lblStudentId = new JLabel("Student ID:");
- lblStudentId.setBounds(348, 281, 85, 14);
- panel.add(lblStudentId);
- JLabel lblCourseCode_2 = new JLabel("Course code:");
- lblCourseCode_2.setBounds(676, 349, 85, 14);
- panel.add(lblCourseCode_2);
- textFieldGradeCcode = new JTextField();
- textFieldGradeCcode.setEditable(false);
- textFieldGradeCcode.setBounds(748, 346, 86, 20);
- panel.add(textFieldGradeCcode);
- textFieldGradeCcode.setColumns(10);
- JLabel lblGrade = new JLabel("Grade:");
- lblGrade.setBounds(677, 442, 46, 14);
- panel.add(lblGrade);
- JComboBox<String> comboBoxGrade = new JComboBox<String>();
- comboBoxGrade.addItem("A");
- comboBoxGrade.addItem("B");
- comboBoxGrade.addItem("C");
- comboBoxGrade.addItem("D");
- comboBoxGrade.addItem("E");
- comboBoxGrade.addItem("U");
- comboBoxGrade.setBounds(748, 439, 68, 20);
- panel.add(comboBoxGrade);
- JLabel lblMessageGrade = new JLabel("Message:");
- lblMessageGrade.setFont(new Font("Tahoma", Font.PLAIN, 9));
- lblMessageGrade.setBounds(348, 500, 351, 14);
- panel.add(lblMessageGrade);
- JButton btnApply = new JButton("Add grade");
- btnApply.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- String sSid = textFieldGradeSsid.getText();
- String cCode = textFieldGradeCcode.getText();
- String semester = textFieldGradeSemester.getText();
- String grade = comboBoxGrade.getSelectedItem().toString();
- try {
- if( textFieldGradeSsid.getText().equals("")){
- lblMessageGrade.setText("no student ID entered");
- }
- else{
- controller.addStudentStudied(sSid, cCode, semester,grade);
- lblMessageGrade.setText("Grade successfully added to student");
- }
- } catch (SQLException e1) {
- e1.printStackTrace();
- }}
- });
- btnApply.setBounds(677, 483, 153, 23);
- panel.add(btnApply);
- JLabel lblSemester_1 = new JLabel("Semester:");
- lblSemester_1.setBounds(677, 395, 85, 14);
- panel.add(lblSemester_1);
- table_2 = new JTable(dataModel_2);
- scrollPane_2 = new JScrollPane(table_2);
- scrollPane_2.setBounds(348, 348, 318, 138);
- panel.add(scrollPane_2);
- JButton btnPoulateCourses = new JButton("SΛk/hitta kurs");
- btnPoulateCourses.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- try {
- dataModel_2.setRowCount(0);
- textFieldGradeCcode.setText("");
- textFieldGradeSemester.setText("");
- String sSid = textFieldGradeSsid.getText();
- ArrayList<Studying> courseList = controller.getStudentsCourse(sSid);
- for (Studying c : courseList) {
- String[] col = new String[3];
- col[0] = c.getssid();
- col[1] = c.getccode();
- col[2] = c.getsemester();
- dataModel_2.addRow(col);
- }
- } catch (SQLException e1) {
- e1.printStackTrace();
- JOptionPane.showMessageDialog(null, "Could not find course" + e1);
- }
- }
- });
- btnPoulateCourses.setBounds(538, 277, 128, 23);
- panel.add(btnPoulateCourses);
- table_2.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
- public void valueChanged(ListSelectionEvent event) {
- if (table_2.getSelectedRow() >= 0) {
- try {
- textFieldGradeCcode.setText(table_2.getValueAt(table_2.getSelectedRow(), 0).toString());
- textFieldGradeSemester.setText(table_2.getValueAt(table_2.getSelectedRow(), 2).toString());
- } catch (Exception e1) {
- JOptionPane.showMessageDialog(null, "Something went wrong!");
- }
- }
- }
- });
- textFieldGradeSemester = new JTextField();
- textFieldGradeSemester.setEditable(false);
- textFieldGradeSemester.setBounds(748, 392, 86, 20);
- panel.add(textFieldGradeSemester);
- textFieldGradeSemester.setColumns(10);
- JLabel lblGiveStudentA = new JLabel("Manage student's courses");
- lblGiveStudentA.setFont(new Font("Tahoma", Font.BOLD, 14));
- lblGiveStudentA.setBounds(348, 250, 217, 20);
- panel.add(lblGiveStudentA);
- JButton btnRemoveFromCourse = new JButton("Remove from course");
- btnRemoveFromCourse.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- String sSid = textFieldGradeSsid.getText();
- String cCode = textFieldGradeCcode.getText();
- try {
- if (textFieldGradeSsid.getText().equals("") || textFieldGradeCcode.getText().equals("")) {
- lblMessageGrade
- .setText("Message: Student not removed since student ID or course code missing.");
- } else {
- controller.removeStudentFromStudying(sSid, cCode);
- lblMessageGrade.setText("Message: Student removed from course.");
- textFieldGradeCcode.setText(null);
- textFieldGradeSemester.setText(null);
- dataModel_2.setRowCount(0);
- }
- } catch (Exception e1) {
- lblMessageGrade.setText("Message: No grade has been added.");
- }
- }
- });
- btnRemoveFromCourse.setBounds(677, 525, 153, 23);
- panel.add(btnRemoveFromCourse);
- JLabel lblSelectCourseFrom = new JLabel("Choose a course lis below please:");
- lblSelectCourseFrom.setBounds(348, 318, 181, 14);
- panel.add(lblSelectCourseFrom);
- JPanel panel_4 = new JPanel();
- tabbedPane.addTab("Search1", null, panel_4, null);
- panel_4.setLayout(null);
- JLabel lblStudentId_1 = new JLabel("Student ID:");
- lblStudentId_1.setBounds(40, 67, 78, 14);
- panel_4.add(lblStudentId_1);
- textFieldSearchSsid = new JTextField();
- textFieldSearchSsid.setBounds(148, 64, 175, 20);
- panel_4.add(textFieldSearchSsid);
- textFieldSearchSsid.setColumns(10);
- textFieldSearchSname = new JTextField();
- textFieldSearchSname.setEditable(false);
- textFieldSearchSname.setBounds(148, 92, 175, 20);
- panel_4.add(textFieldSearchSname);
- textFieldSearchSname.setColumns(10);
- textFieldSearchAddress = new JTextField();
- textFieldSearchAddress.setEditable(false);
- textFieldSearchAddress.setBounds(148, 120, 175, 20);
- panel_4.add(textFieldSearchAddress);
- textFieldSearchAddress.setColumns(10);
- JLabel lblName = new JLabel("Name:");
- lblName.setBounds(40, 95, 65, 14);
- panel_4.add(lblName);
- JLabel lblAddress = new JLabel("Address:");
- lblAddress.setBounds(40, 123, 78, 14);
- panel_4.add(lblAddress);
- JLabel lblInfoSearch_1 = new JLabel("Message:");
- lblInfoSearch_1.setFont(new Font("Tahoma", Font.PLAIN, 9));
- lblInfoSearch_1.setBounds(40, 181, 360, 14);
- panel_4.add(lblInfoSearch_1);
- JButton btnSearchStudent = new JButton("Search");
- btnSearchStudent.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- String sSid = textFieldSearchSsid.getText();
- try {
- if (textFieldSearchSsid.getText().equals("")) {
- lblInfoSearch_1.setText("Message: No student ID entered.");
- } else {
- textFieldSearchSname.setText(controller.findStudent(sSid).getSname());
- textFieldSearchAddress.setText(controller.findStudent(sSid).getSaddress());
- lblInfoSearch_1.setText("Message: Showing student information.");
- }
- } catch (Exception e1) {
- lblInfoSearch_1.setText("Message: Could not find student.");
- }
- }
- });
- btnSearchStudent.setBounds(40, 147, 128, 23);
- panel_4.add(btnSearchStudent);
- JLabel lblSearchStudentInfo = new JLabel("Search student");
- lblSearchStudentInfo.setFont(new Font("Tahoma", Font.BOLD, 14));
- lblSearchStudentInfo.setBounds(40, 31, 181, 20);
- panel_4.add(lblSearchStudentInfo);
- JLabel lblSearchCourseInfo = new JLabel("Search course");
- lblSearchCourseInfo.setFont(new Font("Tahoma", Font.BOLD, 14));
- lblSearchCourseInfo.setBounds(465, 31, 175, 20);
- panel_4.add(lblSearchCourseInfo);
- JLabel lblCourseCode_3 = new JLabel("Course code:");
- lblCourseCode_3.setBounds(465, 67, 92, 14);
- panel_4.add(lblCourseCode_3);
- JLabel lblCourseName_1 = new JLabel("Course name:");
- lblCourseName_1.setBounds(465, 95, 105, 14);
- panel_4.add(lblCourseName_1);
- JLabel lblCoursePoints_1 = new JLabel("Course points:");
- lblCoursePoints_1.setBounds(465, 123, 92, 14);
- panel_4.add(lblCoursePoints_1);
- textFieldSearchCcode = new JTextField();
- textFieldSearchCcode.setBounds(573, 64, 175, 20);
- panel_4.add(textFieldSearchCcode);
- textFieldSearchCcode.setColumns(10);
- textFieldSearchCname = new JTextField();
- textFieldSearchCname.setEditable(false);
- textFieldSearchCname.setBounds(573, 92, 175, 20);
- panel_4.add(textFieldSearchCname);
- textFieldSearchCname.setColumns(10);
- textFieldSearchCpoints = new JTextField();
- textFieldSearchCpoints.setEditable(false);
- textFieldSearchCpoints.setBounds(573, 120, 175, 20);
- panel_4.add(textFieldSearchCpoints);
- textFieldSearchCpoints.setColumns(10);
- JLabel lblInfoSearch_2 = new JLabel("Message:");
- lblInfoSearch_2.setFont(new Font("Tahoma", Font.PLAIN, 9));
- lblInfoSearch_2.setBounds(465, 181, 351, 14);
- panel_4.add(lblInfoSearch_2);
- JButton btnSearchCourse = new JButton("Search");
- btnSearchCourse.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- String cCode = textFieldSearchCcode.getText();
- try {
- if (textFieldSearchCcode.getText().equals("")) {
- lblInfoSearch_2.setText("Message: No course code entered.");
- } else {
- textFieldSearchCname.setText(controller.findCourse(cCode).getCname());
- String cPoints = Integer.toString(controller.findCourse(cCode).getCcp());
- textFieldSearchCpoints.setText(cPoints);
- lblInfoSearch_2.setText("Message: Showing course information.");
- }
- } catch (Exception e1) {
- lblInfoSearch_2.setText("Message: Could not find course.");
- }
- }
- });
- btnSearchCourse.setBounds(465, 147, 128, 23);
- panel_4.add(btnSearchCourse);
- JLabel lblShowStudentResult = new JLabel("Search overall results for courses");
- lblShowStudentResult.setFont(new Font("Tahoma", Font.BOLD, 14));
- lblShowStudentResult.setBounds(464, 285, 340, 20);
- panel_4.add(lblShowStudentResult);
- JLabel lblNewLabel_4 = new JLabel("Course code:");
- lblNewLabel_4.setBounds(464, 327, 93, 14);
- panel_4.add(lblNewLabel_4);
- JLabel lblNewLabel_5 = new JLabel("Semester:");
- lblNewLabel_5.setBounds(465, 354, 64, 14);
- panel_4.add(lblNewLabel_5);
- textFieldSearchListCcode = new JTextField();
- textFieldSearchListCcode.setBounds(573, 324, 86, 20);
- panel_4.add(textFieldSearchListCcode);
- textFieldSearchListCcode.setColumns(10);
- JComboBox<String> comboBoxSearchList = new JComboBox<String>();
- comboBoxSearchList.addItem("HT13");
- comboBoxSearchList.addItem("VT14");
- comboBoxSearchList.addItem("HT14");
- comboBoxSearchList.addItem("VT15");
- comboBoxSearchList.addItem("HT15");
- comboBoxSearchList.setBounds(573, 351, 86, 20);
- panel_4.add(comboBoxSearchList);
- JLabel lblMessageInteractCcode = new JLabel("Message:");
- lblMessageInteractCcode.setFont(new Font("Tahoma", Font.PLAIN, 9));
- lblMessageInteractCcode.setBounds(464, 379, 352, 14);
- panel_4.add(lblMessageInteractCcode);
- dataModel = new DefaultTableModel();
- table = new JTable(dataModel);
- scrollPane = new JScrollPane(table);
- scrollPane.setBounds(465, 419, 351, 156);
- panel_4.add(scrollPane);
- String[] headers = { "Student ID", "Name", "Grade" };
- dataModel.setColumnIdentifiers(headers);
- JButton btnSearchList = new JButton("Search");
- btnSearchList.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- dataModel.setRowCount(0);
- String cCode = textFieldSearchListCcode.getText();
- String semester = comboBoxSearchList.getSelectedItem().toString();
- try {
- System.out.println("rΛv");
- ArrayList<Studied> gradeList = controller.getGradeList(cCode, semester);
- System.out.println(gradeList.size());
- for (Studied s : gradeList) {
- System.out.println("12s" + s.getSname());
- String[] col = new String[3];
- col[0] = s.getSsid();
- col[1] = s.getSname();
- col[2] = s.getGrade();
- dataModel.addRow(col);
- lblMessageInteractCcode.setText("Message: Showing result.");
- }
- } catch (SQLException e1) {
- lblMessageInteractCcode.setText("Message: Could not find course code.");
- }
- }
- });
- btnSearchList.setBounds(727, 350, 89, 23);
- panel_4.add(btnSearchList);
- textFieldSearchGradeSsid = new JTextField();
- textFieldSearchGradeSsid.setBounds(151, 331, 86, 20);
- panel_4.add(textFieldSearchGradeSsid);
- textFieldSearchGradeSsid.setColumns(10);
- textFieldSearchGradeCcode = new JTextField();
- textFieldSearchGradeCcode.setBounds(151, 356, 86, 20);
- panel_4.add(textFieldSearchGradeCcode);
- textFieldSearchGradeCcode.setColumns(10);
- // SΛker
- JLabel lblSearchGradeFor = new JLabel("Search student's grade");
- lblSearchGradeFor.setFont(new Font("Tahoma", Font.BOLD, 14));
- lblSearchGradeFor.setBounds(43, 285, 181, 20);
- panel_4.add(lblSearchGradeFor);
- JLabel lblStudentId_2 = new JLabel("Student ID:");
- lblStudentId_2.setBounds(43, 334, 92, 14);
- panel_4.add(lblStudentId_2);
- JLabel lblCourseCode_4 = new JLabel("Course code:");
- lblCourseCode_4.setBounds(43, 359, 92, 14);
- panel_4.add(lblCourseCode_4);
- JLabel lblMessageInteractionSearchGrade = new JLabel("Message:");
- lblMessageInteractionSearchGrade.setFont(new Font("Tahoma", Font.PLAIN, 9));
- lblMessageInteractionSearchGrade.setBounds(43, 381, 351, 14);
- panel_4.add(lblMessageInteractionSearchGrade);
- dataModel_3 = new DefaultTableModel();
- table_3 = new JTable(dataModel_3);
- scrollPane_3 = new JScrollPane(table_3);
- scrollPane_3.setBounds(55, 419, 357, 156);
- panel_4.add(scrollPane_3);
- String[] headersSearch = { "Student ID", "Course code", "Grade", "Semester" };
- dataModel_3.setColumnIdentifiers(headersSearch);
- JButton btnSearch = new JButton("Search");
- btnSearch.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- String sSid = textFieldSearchGradeSsid.getText();
- String cCode = textFieldSearchGradeCcode.getText();
- try {
- if (textFieldSearchGradeSsid.getText().equals("")
- || textFieldSearchGradeCcode.getText().equals("")) {
- lblMessageInteractionSearchGrade.setText("Message: No student ID or Course code entered.");
- } else {
- dataModel_3.setRowCount(0);
- ArrayList<Studied> courseList = controller.findGrade(sSid, cCode);
- for (Studied c : courseList) {
- String[] col = new String[4];
- col[0] = c.getSsid();
- col[1] = c.getSname();
- col[2] = c.getGrade();
- col[3] = c.getSemester();
- dataModel_3.addRow(col);
- }
- lblMessageInteractionSearchGrade.setText("Message: Showing result.");
- }
- } catch (SQLException e1) {
- lblMessageInteractionSearchGrade.setText("Message: Could not find grade.");
- }
- }
- });
- btnSearch.setBounds(305, 353, 89, 23);
- panel_4.add(btnSearch);
- JButton btnClear = new JButton("Clear");
- btnClear.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- textFieldSearchSsid.setText(null);
- textFieldSearchSname.setText(null);
- textFieldSearchAddress.setText(null);
- lblInfoSearch_1.setText("Message:");
- }
- });
- btnClear.setBounds(195, 147, 128, 23);
- panel_4.add(btnClear);
- JButton btnClear_1 = new JButton("Clear");
- btnClear_1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- textFieldSearchCcode.setText(null);
- textFieldSearchCname.setText(null);
- textFieldSearchCpoints.setText(null);
- lblInfoSearch_2.setText("Message:");
- }
- });
- btnClear_1.setBounds(620, 147, 128, 23);
- panel_4.add(btnClear_1);
- JButton btnClear_2 = new JButton("Clear");
- btnClear_2.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- textFieldSearchGradeSsid.setText(null);
- textFieldSearchGradeCcode.setText(null);
- dataModel_3.setRowCount(0);
- lblMessageInteractionSearchGrade.setText("Message:");
- }
- });
- btnClear_2.setBounds(329, 325, 65, 23);
- panel_4.add(btnClear_2);
- JSeparator separator_1 = new JSeparator();
- separator_1.setBounds(40, 247, 776, 2);
- panel_4.add(separator_1);
- JButton btnClear_3 = new JButton("Clear");
- btnClear_3.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- textFieldSearchListCcode.setText(null);
- dataModel.setRowCount(0);
- lblMessageInteractCcode.setText("Message:");
- }
- });
- btnClear_3.setBounds(751, 323, 65, 23);
- panel_4.add(btnClear_3);
- JPanel panel_1 = new JPanel();
- tabbedPane.addTab("Search2", null, panel_1, null);
- panel_1.setLayout(null);
- dataModel_4 = new DefaultTableModel();
- String[] headersAdvSearch = { "Student ID", "Student name", "Address" };
- dataModel_4.setColumnIdentifiers(headersAdvSearch);
- JLabel lblGetProcentageOf = new JLabel("Procentage with grade 'A'");
- lblGetProcentageOf.setFont(new Font("Tahoma", Font.BOLD, 14));
- lblGetProcentageOf.setBounds(49, 25, 317, 20);
- panel_1.add(lblGetProcentageOf);
- JLabel lblCourseCode_6 = new JLabel("Course code:");
- lblCourseCode_6.setBounds(49, 69, 97, 14);
- panel_1.add(lblCourseCode_6);
- textFieldAdvCcode_1 = new JTextField();
- textFieldAdvCcode_1.setBounds(158, 66, 86, 20);
- panel_1.add(textFieldAdvCcode_1);
- textFieldAdvCcode_1.setColumns(10);
- JLabel lblProcentage = new JLabel("Procentage: (%)");
- lblProcentage.setBounds(48, 152, 98, 14);
- panel_1.add(lblProcentage);
- textFieldAdvProcent = new JTextField();
- textFieldAdvProcent.setEditable(false);
- textFieldAdvProcent.setBounds(158, 150, 86, 20);
- panel_1.add(textFieldAdvProcent);
- textFieldAdvProcent.setColumns(10);
- JComboBox<String> comboBoxAdvSemester_1 = new JComboBox<String>();
- comboBoxAdvSemester_1.addItem("HT13");
- comboBoxAdvSemester_1.addItem("VT14");
- comboBoxAdvSemester_1.addItem("HT14");
- comboBoxAdvSemester_1.addItem("VT15");
- comboBoxAdvSemester_1.addItem("HT15");
- comboBoxAdvSemester_1.setBounds(158, 94, 86, 20);
- panel_1.add(comboBoxAdvSemester_1);
- JLabel lblNewLabelInteractionProcentage = new JLabel("Message:");
- lblNewLabelInteractionProcentage.setFont(new Font("Tahoma", Font.PLAIN, 9));
- lblNewLabelInteractionProcentage.setBounds(47, 126, 296, 14);
- panel_1.add(lblNewLabelInteractionProcentage);
- JButton btnSearch_1 = new JButton("Search");
- btnSearch_1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- String cCode = textFieldAdvCcode_1.getText();
- String semester = comboBoxAdvSemester_1.getSelectedItem().toString();
- try {
- if (textFieldAdvCcode_1.getText().equals("")) {
- lblNewLabelInteractionProcentage.setText("Message: No course code enterd.");
- } else {
- textFieldAdvProcent.setText(controller.getPercentageGradeA(cCode, semester));
- lblNewLabelInteractionProcentage.setText("Message: Showing result");
- }
- } catch (SQLException e1) {
- lblNewLabelInteractionProcentage.setText("Message: Could not find the procentage.");
- }
- }
- });
- btnSearch_1.setBounds(254, 93, 89, 23);
- panel_1.add(btnSearch_1);
- JLabel lblGetCourseWith = new JLabel("Find course with highest passing rate");
- lblGetCourseWith.setFont(new Font("Tahoma", Font.BOLD, 14));
- lblGetCourseWith.setBounds(472, 25, 317, 20);
- panel_1.add(lblGetCourseWith);
- textFieldStudentFlow = new JTextField();
- textFieldStudentFlow.setEditable(false);
- textFieldStudentFlow.setBounds(581, 72, 86, 20);
- panel_1.add(textFieldStudentFlow);
- textFieldStudentFlow.setColumns(10);
- JLabel lblCourseCode_7 = new JLabel("Course code:");
- lblCourseCode_7.setBounds(472, 75, 97, 14);
- panel_1.add(lblCourseCode_7);
- JLabel lblNewLabelInteractionBestFlow = new JLabel("Message:");
- lblNewLabelInteractionBestFlow.setFont(new Font("Tahoma", Font.PLAIN, 9));
- lblNewLabelInteractionBestFlow.setBounds(472, 100, 294, 14);
- panel_1.add(lblNewLabelInteractionBestFlow);
- JButton btnSearchStudentsFlow = new JButton("Search");
- btnSearchStudentsFlow.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- try {
- textFieldStudentFlow.setText(controller.getStudentFlow().toString());
- lblNewLabelInteractionBestFlow.setText("Showing result.");
- } catch (SQLException e1) {
- lblNewLabelInteractionBestFlow.setText("Could not find best student flow.");
- }
- }
- });
- btnSearchStudentsFlow.setBounds(677, 71, 89, 23);
- panel_1.add(btnSearchStudentsFlow);
- JSeparator separator_2 = new JSeparator();
- separator_2.setBounds(25, 193, 792, 2);
- panel_1.add(separator_2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement