0% found this document useful (0 votes)
17 views5 pages

Java Swing Login Form Code

The document is a Java Swing application for a login form that connects to a MySQL database. It includes components for user ID and password input, buttons for login, registration, and exit, and handles user authentication. Upon successful login, it transitions to a main menu, while incorrect credentials prompt an error message.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views5 pages

Java Swing Login Form Code

The document is a Java Swing application for a login form that connects to a MySQL database. It includes components for user ID and password input, buttons for login, registration, and exit, and handles user authentication. Upon successful login, it transitions to a main menu, while incorrect credentials prompt an error message.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import [Link].

JOptionPane;

import [Link].* ;

public class login extends [Link] {

Connection con = null ;

Statement stmt = null ;

ResultSet rs = null;

public login() {

initComponents();

@SuppressWarnings("unchecked")

private void initComponents() {

jPanel1 = new [Link]();

jLabel2 = new [Link]();

jLabel3 = new [Link]();


jLabel4 = new [Link]();

jLabel5 = new [Link]();

BtnRegt = new [Link]();

Btnexit = new [Link]();

Btnlogin = new [Link]();

txtuesrid = new [Link]();

txtpswd = new [Link]();

jLabel1 = new [Link]();

setDefaultCloseOperation([Link].EXIT_ON_CLOSE);

[Link](new [Link]());

[Link](new [Link]("Tahoma", 3, 26)); // NOI18N

[Link]("Login Form");

[Link](jLabel2, new [Link](220, 10, 160, -1));

[Link](new [Link]("Tahoma", 3, 14)); // NOI18N

[Link]("Password");

[Link](jLabel3, new [Link](160, 130, 80, -1));

[Link](new [Link]("Tahoma", 1, 11)); // NOI18N

[Link]("new user click here for register");

[Link](jLabel4, new [Link](140, 310, -1, 20));

[Link](new [Link]("Tahoma", 3, 14)); // NOI18N

[Link]("Uesr ID");

[Link](jLabel5, new [Link](160, 80, 60, -1));

[Link]("Register");

[Link](new [Link]() {

public void actionPerformed([Link] evt) {


BtnRegtActionPerformed(evt);

});

[Link](BtnRegt, new [Link](180, 270, -1, -1));

[Link]("Exit");

[Link](new [Link]() {

public void actionPerformed([Link] evt) {

BtnexitActionPerformed(evt);

});

[Link](Btnexit, new [Link](440, 270, -1, -1));

[Link]("Login");

[Link](new [Link]() {

public void actionPerformed([Link] evt) {

BtnloginActionPerformed(evt);

});

[Link](Btnlogin, new [Link](280, 200, 90, 30));

[Link](txtuesrid, new [Link](250, 80, 210, 30));

[Link](txtpswd, new [Link](250, 130, 210, 30));

[Link](new [Link](getClass().getResource("/image/[Link]"))); // NOI18N

[Link](jLabel1, new [Link](0, 0, 640, 380));

[Link] layout = new [Link](getContentPane());

getContentPane().setLayout(layout);

[Link](
[Link]([Link])

.addComponent(jPanel1, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)

);

[Link](

[Link]([Link])

.addComponent(jPanel1, [Link].DEFAULT_SIZE, 382, Short.MAX_VALUE)

); pack();

private void BtnloginActionPerformed([Link] evt) {

String email = [Link]();

String password = new String([Link]());

try{

[Link]("[Link]");

con = [Link]("jdbc:mysql://localhost/sports","root","");

stmt= [Link]();

rs = [Link]("select * from RegForm where Email_ID='"+email +"' ;"); // for emilID

while([Link]()){

String p = [Link]("password"); // for password

if([Link](password)){

[Link](null,"You Have Signed In Successfully");

[Link](false);

new MainMenu().setVisible(true);

else { [Link](null,"Username Or Password Is Incorrect!",null,-1,0);}

}
[Link]();

[Link]();

[Link]();

catch(Exception e)

{[Link](null,[Link]());}

private void BtnRegtActionPerformed([Link] evt) {

[Link](false);

new ShopINUI().setVisible(true);

private void BtnexitActionPerformed([Link] evt) {

[Link](0);

public static void main(String args[]) {

[Link](new Runnable() {

public void run() {

new login().setVisible(true);

});

You might also like