Login Page Code Overview
Login Page Code Overview
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
*
* @author latifahdrupadi
*/
public class loginpage extends [Link] {
/**
* Creates new form loginpage
*/
public loginpage() {
initComponents();
}
public void close(){
WindowEvent closeWindow=new
WindowEvent(this,WindowEvent.WINDOW_CLOSING);
[Link]().getSystemEventQueue().postEvent(closeWindow);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation([Link].EXIT_ON_CLOSE);
[Link](new
[Link](getClass().getResource("/childrenform/java/newpackage/mom (1)
(1).png"))); // NOI18N
.addGroup([Link]([Link]
NG)
.addComponent(jButton3)
.addGroup([Link]()
.addGroup([Link]([Link]
NG)
.addComponent(jLabel3)
.addComponent(jLabel2))
.addGap(71, 71, 71)
.addGroup([Link]([Link]
NG)
.addComponent(password, [Link].PREFERRED_SIZE,
150, [Link].PREFERRED_SIZE)
.addComponent(user, [Link].PREFERRED_SIZE, 150,
[Link].PREFERRED_SIZE)))
.addComponent(showpass)
.addGroup([Link]()
.addComponent(jButton2)
.addGap(145, 145, 145)
.addComponent(jButton1)))
.addGap(77, 77, 77))
.addGroup([Link],
[Link]()
.addContainerGap([Link].DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jLabel4)
.addGap(62, 62, 62))
.addGroup([Link]()
.addGap(247, 247, 247)
.addComponent(jLabel5)
.addContainerGap([Link].DEFAULT_SIZE,
Short.MAX_VALUE))
);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addComponent(jLabel4)
.addPreferredGap([Link])
.addComponent(jLabel5)
.addGap(24, 24, 24)
.addGroup([Link]([Link]
NG)
.addComponent(jLabel1)
.addGroup([Link]()
.addGroup([Link]([Link]
INE)
.addComponent(jLabel2)
.addComponent(user, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE,
[Link].PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup([Link]([Link]
INE)
.addComponent(jLabel3)
.addComponent(password, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE,
[Link].PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(showpass)
.addGap(18, 18, 18)
.addGroup([Link]([Link]
INE)
.addComponent(jButton1)
.addComponent(jButton2))))
.addGap(18, 18, 18)
.addComponent(jButton3)
.addContainerGap(30, Short.MAX_VALUE))
);
pack();
setLocationRelativeTo(null);
}// </editor-fold>
ResultSet rs = [Link](query);
while([Link]()){
passDb = [Link]("Password");
usr = [Link]("Username");
notFound = 1;
}
if(notFound == 1 && [Link](passDb)){
[Link]();
homepage home=new homepage([Link]());
[Link](true);
}else{
[Link](new JFrame(), "Incorrect username or
password", "Error",
JOptionPane.ERROR_MESSAGE);
}
[Link]("");
}
}catch(Exception e){
[Link]("Error!" + [Link]());
}
}
/**
* @param args the command line arguments
*/
public static void loginpage(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
[Link]
*/
try {
for ([Link] info :
[Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}
}
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link].S
EVERE, null, ex);
} catch (InstantiationException ex) {
[Link]([Link]()).log([Link].S
EVERE, null, ex);
} catch (IllegalAccessException ex) {
[Link]([Link]()).log([Link].S
EVERE, null, ex);
} catch ([Link] ex) {
[Link]([Link]()).log([Link].S
EVERE, null, ex);
}
//</editor-fold>
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import static [Link];
/**
*
* @author latifahdrupadi
*/
public class registpage extends [Link] {
/**
* Creates new form registpage
*/
public registpage() {
initComponents();
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation([Link].EXIT_ON_CLOSE);
[Link](new
[Link](getClass().getResource("/childrenform/java/newpackage/mom (1)
(1).png"))); // NOI18N
[Link] jPanel1Layout = new [Link](jPanel1);
[Link](jPanel1Layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addGroup([Link]([Link]
NG, false)
.addGroup([Link]()
.addGap(39, 39, 39)
.addComponent(jLabel5)
.addGap(20, 20, 20)
.addGroup([Link]([Link]
NG)
.addComponent(showpass)
.addGroup([Link]()
.addGroup([Link]([Link]
NG)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addGap(62, 62, 62)
.addGroup([Link]([Link]
NG, false)
.addComponent(user, [Link].DEFAULT_SIZE,
150, Short.MAX_VALUE)
.addComponent(password)))))
.addGroup([Link]()
.addGap(97, 97, 97)
.addComponent(jButton2)
.addPreferredGap([Link],
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(create)
.addGap(21, 21, 21)))
.addContainerGap([Link].DEFAULT_SIZE,
Short.MAX_VALUE))
.addGroup([Link],
[Link]()
.addGap(0, 53, Short.MAX_VALUE)
.addGroup([Link]([Link]
NG)
.addGroup([Link],
[Link]()
.addComponent(jLabel3)
.addGap(53, 53, 53))
.addGroup([Link],
[Link]()
.addComponent(jLabel4)
.addGap(216, 216, 216))))
);
[Link](
[Link]([Link])
.addGroup([Link],
[Link]()
.addContainerGap([Link].DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jLabel3)
.addPreferredGap([Link])
.addComponent(jLabel4)
.addGap(18, 18, 18)
.addGroup([Link]([Link]
NG)
.addComponent(jLabel5)
.addGroup([Link]()
.addGroup([Link]([Link]
INE)
.addComponent(user, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap([Link])
.addGroup([Link]([Link]
INE)
.addComponent(password, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap([Link])
.addComponent(showpass)))
.addGap(29, 29, 29)
.addGroup([Link]([Link]
INE)
.addComponent(create)
.addComponent(jButton2))
.addGap(40, 40, 40))
);
pack();
setLocationRelativeTo(null);
}// </editor-fold>
pass = [Link]();
[Link](password);
String checkQuery = "SELECT * FROM userpass WHERE Username = '" + usr + "'";
try (ResultSet resultSet = [Link](checkQuery)) {
if ([Link]()) {
[Link](new JFrame(), "Username already exists",
"Error",
JOptionPane.ERROR_MESSAGE);
} else {
query = "INSERT INTO userpass (Username, Password)"+
"VALUES('"+usr+"', '"+pass+"')";
[Link](query);
[Link]("");
[Link]("");
showMessageDialog(null, "New account has been CREATED successfully!");
}}}
}catch(Exception e){
[Link]("Error!" + [Link]());
}
}
/**
* @param args the command line arguments
*/
public static void registpage(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
[Link]
*/
try {
for ([Link] info :
[Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}
}
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link].S
EVERE, null, ex);
} catch (InstantiationException ex) {
[Link]([Link]()).log([Link].S
EVERE, null, ex);
} catch (IllegalAccessException ex) {
[Link]([Link]()).log([Link].S
EVERE, null, ex);
} catch ([Link] ex) {
[Link]([Link]()).log([Link].S
EVERE, null, ex);
}
//</editor-fold>
/**
*
* @author latifahdrupadi
*/
public class homepage extends [Link] {
/**
* Creates new form homepage
*/
public homepage(String name) {
initComponents();
[Link](name);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation([Link].EXIT_ON_CLOSE);
.addGroup([Link]([Link]
NG)
.addComponent(jLabel4)
.addComponent(jLabel3)
.addComponent(jLabel2)
.addGroup([Link]()
.addComponent(jLabel1)
.addPreferredGap([Link])
.addComponent(user, [Link].PREFERRED_SIZE, 50,
[Link].PREFERRED_SIZE))
.addGroup([Link],
[Link]()
.addComponent(jButton1)
.addGap(51, 51, 51)))
.addContainerGap([Link].DEFAULT_SIZE,
Short.MAX_VALUE))
);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addComponent(jLabel5)
.addGap(39, 39, 39)
.addGroup([Link]([Link]
NG, false)
.addComponent(user, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addComponent(jLabel2)
.addPreferredGap([Link])
.addComponent(jLabel3)
.addPreferredGap([Link])
.addComponent(jLabel4)
.addGap(18, 18, 18)
.addComponent(jButton1)
.addContainerGap(36, Short.MAX_VALUE))
);
pack();
setLocationRelativeTo(null);
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void homepage(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
[Link]
*/
try {
for ([Link] info :
[Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}
}
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link].S
EVERE, null, ex);
} catch (InstantiationException ex) {
[Link]([Link]()).log([Link].S
EVERE, null, ex);
} catch (IllegalAccessException ex) {
[Link]([Link]()).log([Link].S
EVERE, null, ex);
} catch ([Link] ex) {
[Link]([Link]()).log([Link].S
EVERE, null, ex);
}
//</editor-fold>
}
});
}
/**
*
* @author latifahdrupadi
*/
public class mainpage extends [Link] {
/**
* Creates new form mainpage
*/
public mainpage() {
initComponents();
[Link]().setEnabled(false);
}
public void close(){
WindowEvent closeWindow=new
WindowEvent(this,WindowEvent.WINDOW_CLOSING);
[Link]().getSystemEventQueue().postEvent(closeWindow);
}
public void addData(){
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation([Link].EXIT_ON_CLOSE);
tbl_add_data.setModel(new [Link](
new Object [][] {
{null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null}
},
new String [] {
"Name", "ID", "Date of Birth", "Blood Type", "Weight (kg)", "Height (cm)", "Head
Circumference (cm)", "Delivery of Birth", "Father's Name", "Mother's Name", "Address"
}
){
Class[] types = new Class [] {
[Link], [Link], [Link],
[Link], [Link], [Link], [Link],
[Link], [Link], [Link], [Link]
};
boolean[] canEdit = new boolean [] {
false, false, false, false, false, false, false, false, false, false, false
};
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
idActionPerformed(evt);
}
});
[Link]("YYYY-MM-dd");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
weightActionPerformed(evt);
}
});
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
heightActionPerformed(evt);
}
});
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
fatherActionPerformed(evt);
}
});
.addGroup([Link]([Link]
NG)
.addGroup([Link]()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jLabel2)
.addGap(493, 493, 493)
.addComponent(refresh))
.addGroup([Link],
[Link]()
.addGroup([Link]([Link]
NG)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel3)
.addComponent(jLabel6)
.addComponent(jLabel7)
.addComponent(jLabel8)
.addComponent(jLabel9)
.addComponent(jLabel10)
.addComponent(jLabel11)
.addComponent(jLabel12)
.addComponent(jLabel13))
.addGap(43, 43, 43)
.addGroup([Link]([Link]
NG)
.addComponent(id)
.addComponent(dob, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(blood, 0, [Link].DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(wob, 0, [Link].DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(weight)
.addComponent(height, [Link])
.addComponent(head, [Link])
.addComponent(father, [Link])
.addComponent(mother, [Link])
.addComponent(address, [Link])
.addComponent(name, [Link]))
.addGap(18, 18, 18)
.addComponent(jScrollPane1, [Link].PREFERRED_SIZE,
864, [Link].PREFERRED_SIZE))
.addGroup([Link],
[Link]()
.addComponent(add)
.addPreferredGap([Link])
.addComponent(delete)
.addPreferredGap([Link])
.addComponent(update)
.addPreferredGap([Link])
.addComponent(recap)
.addPreferredGap([Link],
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton4)))
.addGap(34, 34, 34))
.addGroup([Link],
[Link]()
.addContainerGap(536, Short.MAX_VALUE)
.addComponent(jLabel1)
.addGap(536, 536, 536))
);
[Link](
[Link]([Link])
.addGroup([Link]()
.addGroup([Link]([Link]
NG)
.addGroup([Link]()
.addGap(74, 74, 74)
.addComponent(refresh))
.addGroup([Link]()
.addContainerGap()
.addComponent(jLabel1)
.addGap(12, 12, 12)
.addComponent(jLabel2)))
.addGap(30, 30, 30)
.addGroup([Link]([Link]
NG)
.addGroup([Link]()
.addGroup([Link]([Link]
NG)
.addGroup([Link]()
.addComponent(name, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addPreferredGap([Link])
.addGroup([Link]([Link]
INE)
.addComponent(id, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel4))
.addPreferredGap([Link])
.addGroup([Link]([Link]
NG)
.addComponent(dob, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel5))
.addPreferredGap([Link])
.addGroup([Link]([Link]
INE)
.addComponent(blood,
[Link].PREFERRED_SIZE, [Link].DEFAULT_SIZE,
[Link].PREFERRED_SIZE)
.addComponent(jLabel6)))
.addComponent(jLabel3))
.addPreferredGap([Link])
.addGroup([Link]([Link]
NG)
.addComponent(weight, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel7))
.addPreferredGap([Link])
.addGroup([Link]([Link]
INE)
.addComponent(height, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel8))
.addPreferredGap([Link])
.addGroup([Link]([Link]
INE)
.addComponent(head, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel9))
.addPreferredGap([Link])
.addGroup([Link]([Link]
INE)
.addComponent(wob, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel10))
.addPreferredGap([Link])
.addGroup([Link]([Link]
INE)
.addComponent(father, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel11))
.addPreferredGap([Link])
.addGroup([Link]([Link]
INE)
.addComponent(mother, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel12))
.addPreferredGap([Link])
.addGroup([Link]([Link]
INE)
.addComponent(address, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel13)))
.addGroup([Link]()
.addComponent(jScrollPane1, [Link].PREFERRED_SIZE,
470, [Link].PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup([Link]([Link]
INE)
.addComponent(jButton4)
.addComponent(add)
.addComponent(delete)
.addComponent(update)
.addComponent(recap))))
.addContainerGap(21, Short.MAX_VALUE))
);
pack();
setLocationRelativeTo(null);
}// </editor-fold>
public boolean containsOnlyLetters(String str) {
for (int i = 0; i < [Link](); i++) {
char c = [Link](i);
if () {
return false;
}
}
return true;
}
public boolean containsOnlyNumbers(String str) {
for (int i = 0; i < [Link](); i++) {
char c = [Link](i);
if () {
return false;
}
}
return true;
}
private void addActionPerformed([Link] evt) {
DefaultTableModel model;
try {
[Link]("[Link]");
Connection conn = [Link]("jdbc:mysql://localhost:3306/test",
"root", "");
if("".equals([Link]())){
[Link](new JFrame(), "Name is required", "Error",
JOptionPane.ERROR_MESSAGE);
return;
}
if ("".equals([Link]())) {
[Link](new JFrame(), "ID is required", "Error",
JOptionPane.ERROR_MESSAGE);
return;
} else {
String idText = [Link]().trim();
if ([Link]() > 10) {
isSuccess = false;
[Link](new JFrame(), "ID can only be a maximum of
10 numbers", "Error", JOptionPane.ERROR_MESSAGE);
}
}
if (!isSuccess) {
return;
}
if ("".equals(((JTextField) [Link]().getUiComponent()).getText())) {
[Link](new JFrame(), "Date of Birth is required", "Error",
JOptionPane.ERROR_MESSAGE);
return;
}
if ([Link]() == -1) {
[Link](new JFrame(), "Blood Type is required", "Error",
JOptionPane.ERROR_MESSAGE);
return;
}
if ("".equals([Link]())) {
[Link](new JFrame(), "Weight is required", "Error",
JOptionPane.ERROR_MESSAGE);
return;
}
if ("".equals([Link]())) {
[Link](new JFrame(), "Height is required", "Error",
JOptionPane.ERROR_MESSAGE);
return;
}
if ("".equals([Link]())) {
[Link](new JFrame(), "Head Circumference is required",
"Error", JOptionPane.ERROR_MESSAGE);
return;
}
if ([Link]().trim().isEmpty()) {
[Link](new JFrame(), "Father's Name is required",
"Error", JOptionPane.ERROR_MESSAGE);
return;
}
if ([Link]().trim().isEmpty()) {
[Link](new JFrame(), "Mother's Name is required",
"Error", JOptionPane.ERROR_MESSAGE);
return;
}
if ([Link]().trim().isEmpty()) {
[Link](new JFrame(), "Address is required", "Error",
JOptionPane.ERROR_MESSAGE);
return;
}
if ([Link]() == -1) {
[Link](new JFrame(), "Delivery of Birth is required",
"Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (!containsOnlyLetters([Link]().trim())) {
isSuccess = false;
[Link](new JFrame(), "Name must contain only letters",
"Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (!containsOnlyNumbers([Link]().trim())) {
isSuccess = false;
[Link](new JFrame(), "ID must contain only numbers",
"Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (!containsOnlyNumbers([Link]().trim())) {
isSuccess = false;
[Link](new JFrame(), "Weight must contain only
numbers", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (!containsOnlyNumbers([Link]().trim())) {
isSuccess = false;
[Link](new JFrame(), "Height must contain only
numbers", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (!containsOnlyNumbers([Link]().trim())) {
isSuccess = false;
[Link](new JFrame(), "Head Circumference must contain
only numbers", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (!containsOnlyLetters([Link]().trim())) {
isSuccess = false;
[Link](new JFrame(), "Father's name must contain only
letters", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (!containsOnlyLetters([Link]().trim())) {
isSuccess = false;
[Link](new JFrame(), "Mother's name must contain only
letters", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
try {
[Link]();
[Link](null, "Data Saved!");
} catch (Exception e) {
[Link](null, "ID must be unique.", "Error",
JOptionPane.ERROR_MESSAGE);
}
String selectSql = "SELECT * FROM inputdata";
try (Statement st = [Link](); ResultSet rs =
[Link](selectSql)) {
String[] columnNames = {"Name", "ID", "Date of Birth", "Blood Type",
"Weight (kg)", "Height (cm)", "Head Circumference (cm)", "Delivery of Birth", "Father's
Name", "Mother's Name", "Address"};
model = new DefaultTableModel(columnNames, 0);
while ([Link]()) {
Object[] obj = {
[Link]("Name"),
[Link]("ID"),
[Link]("Day"),
[Link]("Blood"),
[Link]("Weight"),
[Link]("Height"),
[Link]("Head"),
[Link]("Way"),
[Link]("Father"),
[Link]("Mother"),
[Link]("Address")
};
[Link](obj);
}
tbl_add_data.setModel(model);
tbl_add_data.setDefaultEditor([Link], null);
tbl_add_data.setRowSelectionAllowed(true);
tbl_add_data.setColumnSelectionAllowed(false);
}
[Link]("");
[Link]("");
[Link](null);
[Link](-1);
[Link]("");
[Link]("");
[Link]("");
[Link]("");
[Link]("");
[Link]("");
[Link](-1);
if (selectedRow != -1) {
// Get the ID of the selected row
String selectedIDString = [Link](selectedRow, 1).toString();
try {
[Link]("[Link]");
try (Connection conn =
[Link]("jdbc:mysql://localhost:3306/test", "root", "")) {
// Delete data from the database
String sql = "DELETE FROM inputdata WHERE ID=?";
try (PreparedStatement ps = [Link](sql)) {
[Link](1, selectedIDString);
int affectedRows = [Link]();
if (affectedRows > 0) {
// Remove the selected row from the table
[Link](selectedRow);
}
private void updateActionPerformed([Link] evt) {
DefaultTableModel tblModel = (DefaultTableModel) tbl_add_data.getModel();
int selectedRow = tbl_add_data.getSelectedRow();
if (selectedRow == -1) {
[Link](this, "Please select a single row", "Error",
JOptionPane.ERROR_MESSAGE);
return;
}
String n = [Link]();
String a = (String) [Link]();
String ad = [Link]();
String hea = [Link]();
String hei = [Link]();
String wei = [Link]();
String fa = [Link]();
String mo = [Link]();
String iid = [Link]();
String wobb = (String) [Link]();
String dobb = ((JTextField) [Link]().getUiComponent()).getText();
try {
// Check if weight, height, and head circumference are numeric
double weightValue = [Link](wei);
double heightValue = [Link](hei);
double headValue = [Link](hea);
// Execute SQL update query to update only the selected row in the database
String updateQuery = "UPDATE inputdata SET Name=?, ID=?, Day=?, Blood=?,
Weight=?, Height=?, Head=?, Way=?, Father=?, Mother=?, Address=? WHERE ID=?";
try (Connection conn =
[Link]("jdbc:mysql://localhost:3306/test", "root", "");
PreparedStatement ps = [Link](updateQuery)) {
[Link](1, n);
[Link](2, iid);
[Link](3, dobb);
[Link](4, a);
[Link](5, [Link](wei));
[Link](6, [Link](hei));
[Link](7, [Link](hea));
[Link](8, wobb);
[Link](9, fa);
[Link](10, mo);
[Link](11, ad);
[Link](12, selectedID); // Use ID to identify the record to update
if (rowsAffected == 1) {
// Update the table model with the new values for the selected row
[Link](n, selectedRow, 0);
[Link](iid, selectedRow, 1);
[Link](dobb, selectedRow, 2);
[Link](a, selectedRow, 3);
[Link](wei, selectedRow, 4);
[Link](hei, selectedRow, 5);
[Link](hea, selectedRow, 6);
[Link](wobb, selectedRow, 7);
[Link](fa, selectedRow, 8);
[Link](mo, selectedRow, 9);
[Link](ad, selectedRow, 10);
[Link]("");
[Link]("");
[Link](null);
[Link](-1);
[Link]("");
[Link]("");
[Link]("");
[Link]("");
[Link]("");
[Link]("");
[Link](-1);
}
} catch (NumberFormatException e) {
[Link](this, "Please enter valid numeric values for weight,
height, and head circumference", "Error", JOptionPane.ERROR_MESSAGE);
} catch (SQLException e) {
[Link](this, "Error updating data: " + [Link](),
"Error", JOptionPane.ERROR_MESSAGE);
}
}
private void jButton4ActionPerformed([Link] evt) {
close();
}
/**
* @param args the command line arguments
*/
public static void mainpage(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
[Link]
*/
try {
for ([Link] info :
[Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}
}
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link].S
EVERE, null, ex);
} catch (InstantiationException ex) {
[Link]([Link]()).log([Link].S
EVERE, null, ex);
} catch (IllegalAccessException ex) {
[Link]([Link]()).log([Link].S
EVERE, null, ex);
} catch ([Link] ex) {
[Link]([Link]()).log([Link].S
EVERE, null, ex);
}
//</editor-fold>
}
End Page Code
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/[Link] to change
this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/[Link] to edit this
template
*/
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
*
* @author latifahdrupadi
*/
public class endpage extends [Link] {
/**
* Creates new form endpage
*/
public endpage() {
initComponents();
}
public void close(){
WindowEvent closeWindow=new
WindowEvent(this,WindowEvent.WINDOW_CLOSING);
[Link]().getSystemEventQueue().postEvent(closeWindow);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
tbl_add_data.setModel(new [Link](
new Object [][] {
{null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null}
},
new String [] {
"Name", "ID", "Date of Birth", "Blood Type", "Weight (kg)", "Height (cm)", "Head
Circumference", "Delivery of Birth", "Father's Name", "Mother's Name", "Address"
}
){
boolean[] canEdit = new boolean [] {
false, false, false, false, false, false, false, false, false, false, false
};
[Link](new [Link]() {
public void keyReleased([Link] evt) {
searchKeyReleased(evt);
}
});
.addGroup([Link]([Link]
NG)
.addGroup([Link]()
.addComponent(jButton1)
.addGap(44, 44, 44)
.addComponent(pdf)
.addPreferredGap([Link],
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton4)
.addGap(34, 34, 34)
.addComponent(close))
.addComponent(jScrollPane1, [Link])
.addGroup([Link],
[Link]()
.addComponent(jButton3)
.addPreferredGap([Link],
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(search, [Link].PREFERRED_SIZE, 176,
[Link].PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel1)))
.addGap(65, 65, 65))
.addGroup([Link]()
.addGap(416, 416, 416)
.addComponent(jLabel2)
.addContainerGap(416, Short.MAX_VALUE))
);
[Link](
[Link]([Link])
.addGroup([Link],
[Link]()
.addContainerGap()
.addComponent(jLabel2)
.addGap(48, 48, 48)
.addGroup([Link]([Link]
INE)
.addComponent(jButton3)
.addComponent(search, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel1))
.addGap(18, 18, 18)
.addComponent(jScrollPane1, [Link].DEFAULT_SIZE, 487,
Short.MAX_VALUE)
.addGap(18, 18, 18)
.addGroup([Link]([Link]
INE)
.addComponent(jButton1)
.addComponent(pdf)
.addComponent(close)
.addComponent(jButton4))
.addGap(27, 27, 27))
);
pack();
setLocationRelativeTo(null);
}// </editor-fold>
try {
[Link](document, new FileOutputStream("Children [Link]"));
[Link]();
[Link](filter);
} catch (NumberFormatException e) {
// If the input is not a number, use [Link] for text
[Link]([Link]("(?i)" + text)); // (?i) for case-insensitive
matching
}
}
/**
* @param args the command line arguments
*/
public static void endpage(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
[Link]
*/
try {
for ([Link] info :
[Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}
}
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link]
VERE, null, ex);
} catch (InstantiationException ex) {
[Link]([Link]()).log([Link]
VERE, null, ex);
} catch (IllegalAccessException ex) {
[Link]([Link]()).log([Link]
VERE, null, ex);
} catch ([Link] ex) {
[Link]([Link]()).log([Link]
VERE, null, ex);
}
//</editor-fold>