Source code program
makes Login system with Netbeans
Login
system makes the keypad / button that can not access / click can be activated
and can be accessed / click .
1. Design main display form as in the picture below
#Sub menu Login will be changed automatically be Logout when Login was successful.
#all key / button is not active ( enabled = false ) .
2. Create a database ( I'm using MySQL ) , following the example of the database structure to table his admin
3. Do not forget Add Library MySQL JDBC drivers , how to stay right-click on Libraries > Select the Add Library to display the following
4. If the MySQL JDBC Driver has not any , click the Import button and locate the file its MySQL JDBC Driver and then select the file and press Ok .After successfully import , select the file again its MySQL JDBC Driver and then click the Add Library
5. For the system source code Login Login Button Right click > Events > Action > actionPerformed then type the following code
try
{
Connection
koneksi=DriverManager.getConnection("jdbc:mysql://localhost:3306/medica","root","");
Statement stat= koneksi.createStatement();
ResultSet rs=stat.executeQuery("select count(id_admin) from admin where
id_admin='"+jPasswordUser.getText()+"' and
password='"+jPasswordPass.getText()+"'" );
if(rs.next()){
int id_admin=rs.getInt(1);
if(id_admin>0){
TbObat.setEnabled(true);
TbTindakan.setEnabled(true);
TbDokter.setEnabled(true);
TbPasien.setEnabled(true);
TbPetugas.setEnabled(true);
Login.setText("Logout"); //merubah sub menu
Login menjadi Logout
PanelLogin.setVisible(false);
jPasswordPass.setText("");
jPasswordUser.setText("");
}else {
TbObat.setEnabled(false);
TbTindakan.setEnabled(false);
TbDokter.setEnabled(false);
TbPasien.setEnabled(false);
TbPetugas.setEnabled(false);
Login.setText("Login");
JOptionPane.showMessageDialog(null,"Maaf, Username atau Password
SALAH,Silahkan ulangi Login...!");
jPasswordUser.setFocusable(true);
jPasswordPass.setText("");
jPasswordUser.setText("");
}
}
} catch (SQLException ex) {
System.out.println(ex);
}
#Description: The name of the database , table , field , button , TextField , form Login adjust to have each of you .
6. Later on also click the Right Button Cancel > Events > Action > actionPerformed then type the following code :
jPasswordPass.setText("");
jPasswordUser.setText("");
PanelLogin.setVisible(false);
7. Try the program in the Run and see the results !
- The initial view when the sub menu Log in clicks , all the key / button is not active as yet Login
- Display when Button click Login and Login successful , turned into a sub menu Login Logout automatic and all key / button is active
- Display as Username and Password are entered incorrectly , the textfield will return empty . When the Cancel button is clicked Login form will disappear
that interest project / source code please download
if you want e -book please download e-book
good luck and HAPPY CODING : D
Comments
Post a Comment