Case Study - Ipt Maznur F2002, Akmal F2022
Case Study - Ipt Maznur F2002, Akmal F2022
INTEGRATIVE
PROGRAMMING &
TECHNOLOGY
(DFC50273)
CASE STUDY
Prepared by:
MAZNUR FIRDAUS BIN MAZLAN (17DDT21F2002)
30/11/2023
QUESTION
CODING
javax.swing.JPanel; import
javax.swing.border.EmptyBorder; import
javax.swing.JButton; import
javax.swing.JTable; import
javax.swing.JScrollPane; import
javax.swing.JLabel; import
javax.swing.JOptionPane; import
javax.swing.border.TitledBorder; import
javax.swing.filechooser.FileSystemView; import
javax.swing.table.DefaultTableModel; import
java.awt.Color; import
javax.swing.border.EtchedBorder; import
java.sql.DriverManager; import
java.sql.PreparedStatement; import
java.sql.ResultSet; import
java.sql.SQLException; import
javax.swing.JTextField;
import javax.swing.JComboBox; import
javax.swing.JFileChooser; import
javax.swing.JCheckBox; import
java.awt.event.ActionListener; import
JTextField textField_4;
selectedFile;
/**
e.printStackTrace();
});
/**
*/ public Course_Registration() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
5, 5, 5)); setContentPane(contentPane);
JPanel(); panel.setBackground(Color.ORANGE);
panel.setBorder(new TitledBorder(new
EtchedBorder(EtchedBorder.LOWERED, new Color(255, 255, 255), new
Color(160, 160, 160)), "Registered Course", TitledBorder.LEADING,
TitledBorder.TOP, null, new Color(0, 0, 0)));
panel.setBounds(28, 79, 925, 172);
contentPane.add(panel); panel.setLayout(null);
JTable(model); table.setEnabled(false);
scrollPane.setViewportView(table);
model.addColumn("Bilangan");
model.addColumn("Course code");
model.addColumn("Course name");
model.addColumn("Lecturer");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost/dbregistration",
"root", "");
} catch (Exception e) {
System.out.println(e.getMessage());
panel_1.setBorder(new TitledBorder(new
EtchedBorder(EtchedBorder.LOWERED, new Color(255, 255, 255), new
Color(160, 160, 160)), "ADD COURSE", TitledBorder.LEADING,
contentPane.add(panel_1); panel_1.setLayout(null);
20); panel_1.add(textField_1);
textField_1.setColumns(10);
panel_1.add(lblNewLabel_3);
panel_1.add(lblNewLabel_6);
20); panel_1.add(textField_2);
= new JComboBox();
try
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost/dbregistration",
"root", "");
cHours = Rs.getString("credit_hours");
textField_4.setText(lectName);
textField_3.setText(cName);
textField_5.setText(cHours);
System.out.println(e1.getMessage());
} catch (Exception e) {
System.out.println(e.getMessage());
panel_1.add(textField_3);
textField_3.setColumns(10); textField_4 =
new JTextField();
panel_1.add(textField_4);
textField_4.setColumns(10);
textField_2.getText(); courseCode =
comboBox.getSelectedItem().toString(); courseName =
Integer.parseInt(creditHours); try {
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/dbregistrat
ion", "root", "");
+
"(student_name,matrix_number,course_code,course_name,lecturer_name,c
redit_hours)"
+ "values(?,?,?,?,?,?)");
st.setString(1, studentName);
st.setString(2, matricNo);
st.setString(3, courseCode);
st.setString(4, courseName);
st.setString(5, lecturerName);
st.setInt(6, temp); int rowInserted =
st.executeUpdate(); if (rowInserted >
0) {
JOptionPane.showMessageDialog(null, "Record Added!!!!!");
}else {
} con.close();
} catch (SQLException
e1)
{ e1.printStackTrace();
} }); btnNewButton_1.setEnabled(false);
panel_1.add(btnNewButton_1);
chckbxNewCheckBox.addActionListener(new ActionListener() {
(chckbxNewCheckBox.isSelected()) {
btnNewButton_1.setEnabled(true);
} else { btnNewButton_1.setEnabled(false);
});
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost/dbregistration",
"root", "");
btnNewButton_4.addActionListener(new ActionListener() {
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost/dbregistration",
"root", "");
contentPane.add(textField); textField.setColumns(10);
contentPane.add(btnNewButton);
contentPane.add(lblNewLabel_9);
btnNewButton) {
JFileChooser j = new
JFileChooser(FileSystemView.getFileSystemView().getHomeDirectory());
JFileChooser.APPROVE_OPTION)
textField.setText(j.getSelectedFile().getAbsolutePath()); }
} }); btnNewButton_3.addActionListener(new
actionPerformed(ActionEvent e) { textField.setText("");
textField_1.setText(""); textField_2.setText("");
textField_3.setText(""); textField_4.setText("");
textField_5.setText("");
chckbxNewCheckBox.setSelected(false);
comboBox.setSelectedIndex(0);
});
}
DESIGN
OUTPUT
RUBRIC