FINALS
FINALS
Color;
import java.awt.Font;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
panel.setBackground(lightred);
frame.setSize(500, 400);
frame.setVisible(true);
panel.setLayout(null);
li.setFont(new Font("Arial",Font.BOLD,18));
l1.setFont(new Font("Arial",Font.BOLD,18));
l2.setFont(new Font("Arial",Font.BOLD,18));
l3.setFont(new Font("Arial",Font.BOLD,18));
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(panel);
panel.add(f1);
panel.add(li);
panel.add(l1);
panel.add(l2);
panel.add(f2);
panel.add(l3);
panel.add(f3);
panel.add(fid);
panel.add(btn1);
panel.add(btn2);
panel.add(btn3);
panel.add(btn4);
panel.add(btn5);
btn1.addActionListener(new ActionListener(){
try {
psmt.setString(2, Lastname);
psmt.setString(3, Address);
psmt.executeUpdate();
});
btn2.addActionListener(new ActionListener(){
f1.setText(null);
f2.setText(null);
f3.setText(null);
});
btn3.addActionListener(new ActionListener(){
});
btn5.addActionListener(new ActionListener(){
String id = fid.getText();
try {
ResultSet rs = psmt.executeQuery();
if(rs.next()){
f1.setText(rs.getString("Firstname"));
f2.setText(rs.getString("Lastname"));
f3.setText(rs.getString("Address"));
});
btn4.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ex){
String id = fid.getText();
try {
psmt.executeUpdate();
fid.setText(null);
f1.setText(null);
f2.setText(null);
f3.setText(null);
});
}
DB CONNECT
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
/*
*/
/**
* @author Diaz
*/
try{
Class.forName("com.mysql.jdbc.Driver");
Mysql = DriverManager.getConnection("jdbc:mysql://localhost:3306/rama_record","root","");
}catch(ClassNotFoundException ex) {
ex.printStackTrace();
return Mysql;