Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package parQr;
- import java.awt.Color;
- import java.awt.Dimension;
- import java.awt.Toolkit;
- import java.sql.Connection;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import javax.swing.JOptionPane;
- /**
- *
- * @author EZHAKOVA1687
- */
- public class fLogin extends javax.swing.JFrame {
- koneksi konek = new koneksi();
- /**
- * Creates new form fLogin
- */
- public fLogin() {
- initComponents();
- konek.koneksi();
- //rata kanan kiri
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- Dimension frameSize = getSize();
- setLocation ((screenSize.width - frameSize.width)/2,
- (screenSize.height - frameSize.height)/3);
- }
- /**
- * 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.
- */
- private void btnLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoginActionPerformed
- // TODO add your handling code here:
- try {
- String sql = "SELECT * FROM tb_pengelola WHERE username = '" + txtUsername.getText() + "' AND password = '" + passwordField.getText() + "'";
- konek.st = konek.conn.createStatement();
- konek.rs = konek.st.executeQuery(sql);
- konek.rs.next();
- konek.rs.last(); //mengecek jumlah baris pada hasil query
- if (konek.rs.getRow()==1){
- JOptionPane.showMessageDialog(null, "Unlock Succes!");
- new fParkir().setVisible(true); //<-- BILA MAU DIARAHKAN KE Frame Menu Utama
- this.dispose();
- } else {
- JOptionPane.showMessageDialog(null, "Sorry,Failed please try again!");
- passwordField.setText("");
- passwordField.requestFocus();
- }
- } catch (SQLException e) {
- }
- }//GEN-LAST:event_btnLoginActionPerformed
- private void txtUsernameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtUsernameActionPerformed
- // TODO add your handling code here:
- }//GEN-LAST:event_txtUsernameActionPerformed
- private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
- // TODO add your handling code here:
- int selectedOption = JOptionPane.showConfirmDialog(null,
- " Ready To Close System?", "Close Program ParQrest", JOptionPane.YES_NO_OPTION);
- if (selectedOption == JOptionPane.YES_OPTION) {
- System.exit(0);
- }
- }//GEN-LAST:event_btnCancelActionPerformed
- /**
- * @param args the command line arguments
- */
- public static void main(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 http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(fLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(fLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(fLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(fLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new fLogin().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton btnCancel;
- private javax.swing.JButton btnLogin;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JLabel jLabel5;
- private javax.swing.JLabel jLabel6;
- private javax.swing.JLabel jLabel7;
- private javax.swing.JLabel jLabel8;
- private javax.swing.JLabel jLabel9;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JPanel jPanel2;
- private javax.swing.JPanel jPanel3;
- private javax.swing.JPasswordField passwordField;
- private javax.swing.JTextField txtUsername;
- // End of variables declaration//GEN-END:variables
- }
Advertisement
Add Comment
Please, Sign In to add comment