Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Login Form in Java

Have Programming Question? Ask it here!
 
 
 


Prashant Kadam
Login Form in Java
3 Answer(s)      5 years ago
Posted in : Java Beginners



Advertisement
View Answers

September 8, 2009 at 4:38 PM


Hi Friend,

Try the following code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
class Form extends JFrame implements ActionListener{
JButton SUBMIT;
JPanel panel;
JLabel label1,label2;
final JTextField text1;
final JPasswordField text2;
Form(){
label1 = new JLabel();
label1.setText("UserName:");
text1 = new JTextField(15);

label2 = new JLabel();
label2.setText("Password:");
text2 = new JPasswordField(15);
SUBMIT=new JButton("Login");
panel=new JPanel(new GridLayout(3,1));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(SUBMIT);
add(panel,BorderLayout.CENTER);
SUBMIT.addActionListener(this);
setTitle("FORM");
}
public void actionPerformed(ActionEvent ae){
String value1=text1.getText();
String value2=text2.getText();
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";;
String db = "test";
String driver = "com.mysql.jdbc.Driver";
String user = "root";
String pass = "root";
String user1="";
String pass1="";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db, user, pass);
Statement st = con.createStatement();
ResultSet res = st.executeQuery("SELECT * FROM login where username='"+value1+"' && password='"+value2+"'");
while (res.next()) {
user1 = res.getString("username");
pass1 = res.getString("password");
}
if (value1.equals(user1) && value2.equals(pass1)) {
JOptionPane.showMessageDialog(this,"correct");
}
else{
JOptionPane.showMessageDialog(this,"Incorrect login or password","Error",JOptionPane.ERROR_MESSAGE);
}
}
catch(Exception e){
System.out.println(e.getMessage());
}
}
}
class LoginDemo{
public static void main(String arg[]) {
try {
Form frame=new Form();
frame.setSize(300,100);
frame.setVisible(true);
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.getMessage());
}
}
}

Thanks


June 7, 2012 at 10:17 PM


I am doind this for the first time.Not sure I am doind it correctly

Error: Could not find or load main class Login.BLA



June 7, 2012 at 10:18 PM


Can u please help



Related Tutorials/Questions & Answers:
standart login form for messenger in java
standart login form for messenger in java  hi i need login from for chating messenger in java. but its structure would like this Home Register Login User ID Password   Hi Friend
standart login form for messenger in java
standart login form for messenger in java  hi i need login from for chating messenger in java. but its structure would like this Home Register Login User ID Password   Hi Friend
Advertisements
Login Form in Java - Java Beginners
Login Form in Java  Hi, In my Project, I am using Java-JDBC-Mysql...) How to create frontage form in java to validate it. regards, Prashant...*; import java.awt.*; import java.awt.event.*; import java.sql.*; class Form
login form using java bean in eclipse
login form using java bean in eclipse  I have made a college community website but i need to implement beans to my login and contact us page. how can i do
login form
login form  sir my next form consists logout button when i click on it it showing login form but next form window is not closing but the components...; LoginDemo() { setTitle("Login Form"); setLayout(null); label1 = new
Login Form
of +,on clicking which a login form appears. Only the middle column is different for each of the page. How to write a code for login authentication so...Login Form  I have 8 jsp pages.Each of them has three columns:Left
Login Form
of +,on clicking which a login form appears. Only the middle column is different for each of the page. How to write a code for login authentication so...Login Form  I have 8 jsp pages.Each of them has three columns:Left
login form
login form  sir my next form consists logout button when i click on it it showing login form but next form window is not closing but the components...() { setTitle("Login Form"); setLayout(null); label1 = new JLabel
Login Form with Java GUI using Netbeans
Login Form with Java GUI using Netbeans  Hi there! I'm a beginner in Java. I've created 2 class files: 1) TestAssign.java 2) NewFrame.java How can I have different user to login? Now that I've only administrator who is able
Database driven login form - Java Server Faces Questions
Database driven login form  Dear sir,madam, Greetings!! well, am a new user of java and i am programming using the netbeans IDE, what i need is code that; will create a database driven login form where users are authenticated
Login form and registration
Login form and registration  I need a complete code for ligin and new user registration form and validation
administrator login form
administrator login form   Hi iam using struts frame work backend as oracle .i want code for administrator login form thanks in advance
Spring login form application
Spring login form application  Hi Please give me the Spring login form application so that i can understand its flow ?   Hi please find the link of the tutorial Spring Applications
Using java script do login form having fields with condition.
Using java script do login form having fields with condition.  Need a login form with username, password, phone no, email id, date fields. We should specify the conditions for each field and if we press the submit button
login form - JSP-Servlet
login form  Q no.1:- Creat a login form in servlets?  Hi...*; import javax.servlet.http.*; public class Login extends HttpServlet...(); pw.println(""); pw.println("Login"); pw.println(""); pw.println
login form validation - JSP-Servlet
login form validation  hi, how to validate the login form that contains user name and password using post method . the validation should not allow user to login in the address bar thanks regards, anand
Login form in jscript
Login form in jscript  For example the html script is <...; charset=utf-8" /> <title>:: validation form::</title> <script...;td align="center" valign="top"> <form name="form1" onsubmit
Struts 2.1.8 Login Form
Struts 2.1.8 Login Form      ... to validate the login form using Struts 2 validator framework. About the example: This example will display the login form to the user. If user enters Login Name
Spring alternative to Form Based Login
Spring alternative to Form Based Login  print("code sample");how can we make a server to listen to login event i.e. Authenticate a user not using jsp. Using a login form we can use the jspringsecurity_check. How can we do
Login Form
Login Form       Login form in struts: Whenever you goes to access data from... for a login form using struts. UserLoginAction Class: When you download Login
Login form
Login Form with jsp      ... of login form will really help to understand jsp page. In this  example we... are going to insert the data in the login form which will be displayed onto
SWT login form - Swing AWT
SWT login form  Hi, I want code to create a login form in SWT. My...(2, false)); shell.setText("Login form"); label1=new Label(shell...|SWT.CANCEL); messageBox.setText("Login Form"); messageBox.setMessage
Example of login form validation in struts2.2.1framework.
Example of login form validation in struts2.2.1 framework. In this example, we will introduce you to about the login form validation in struts2.2.1 framework. Our login form validation example does not validate the user against
How to put the image in footer in login form ?
How to put the image in footer in login form ?  Hi, how to put the image in footer in login form ?   Here is an example that shows image on footer along with Login Form in Java Swing. import javax.swing.*; import
how to login form through spring dao module
how to login form through spring dao module  here i want to chek user details in database through form by using spring dao module.please give me some reference example to me
getting error in your login form code
getting error in your login form code  i tried your code for login form but i am getting an error.the error is undefined index userid...   hi friend, your form's input must have following : <input type
Login form using Jsp in hibernate - Hibernate
Login form using Jsp in hibernate   Hai Friend, As I new To hibernate, I'm facing problem in My project(JSP with hibernate).. My login form... and entering into Menu Form.. plz can any one help for my problem... Thanks
Login Form using Ajax
Login Form using Ajax       This section provides you an easy and complete implementation of login form...;/action> Develop a Login Form Using Ajax : The GUI of the application
PHP MySQL Login Form
Login Form using PHP and MySQL: In any website generally it is mandatory to have a login form to keep your data secure. In this regard we need to have... will study how to create a login form, connect with the database server and login
Struts 2 Login Form Example
Struts 2 Login Form Example tutorial - Learn how to develop Login form... you can create Login form in Struts 2 and validate the login action.... Let's start developing the Struts 2 Login Form Example Step 1
Login Form in SWT
Login Form in SWT       This section illustrates you how to create Login Form. To create a login... GridLayout(2, false)) sets the layout of the login form. The method setTextLimit(30
redirecting a login authenticated form to a form to be displayed on the same page from where the login authentication has taken place.
redirecting a login authenticated form to a form to be displayed on the same page from where the login authentication has taken place.  I am successfully able to create a session on successful login, but I want to display
How to put the logo in login form using swings/awt?
that will display logo along with login form in Java Swing. import javax.swing.... How to put the logo in login form using swings/awt?  Hi, How to put the logo in login form using swings/awt? I write the login form is working
For my website,As soon as the user is able to succesfully login, a Testimonial form appears.
For my website,As soon as the user is able to succesfully login, a Testimonial form appears.  For my website,As soon as the user is able to succesfully login, a Testimonial FORM appears in the same page. How to do. Please Help
Spring 3 MVC Login Form Example with Database MySql
Spring 3 MVC Login Form Example with Database MySql  Sir i have checked your project of Spring 3 MVC Login Form Example But Sir Not able to do It with database Mysql. Can you Provide code for login with database. Thanks
add cookies to login form in jsp by using struts2.0 framework
add cookies to login form in jsp by using struts2.0 framework  hi sir... struts2.0 and hibernate3.0 and mysql database for login .jsp now i want to add cookies to above form please help me
Login Box - Java Beginners
Login Box   Hi, I am new to Java and I am in the process of developing a small application which needs a login page. I am planning to have my database... it with the corresponding password tosee if the login details match.I've
how to genrate login id and password after submitting the sign up form?
how to genrate login id and password after submitting the sign up form?  i m working on a online voting project in that i have a user sign up form so i want 2 knw that after user submit all the details i that sign up form than
login-password - Java Beginners
login-password  complete code of login-password form then how to connect the bank simulation project?   Hi friend, login...; } Login Application in JSP
How to Create Login/ Registration Form using PHP and MYSQL
How to Create Login/ Registration Form using PHP and MYSQL  Hi, I am learning PHP. I have some dilemma how to create a Login Form and make connectivity with HTML page using PHP and MYSQL. Is there any body can guide me
login page - Java Beginners
login page  I have one login page in jsp that is login.jsp. Now i have validate user from database by another page validate.jsp. but if the user...://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml
Swing login form example
Swing login form example In this example we have described swing login form. We have created one text field "textField" and one jPasswordField and we have set text for username and password. We create one submit button and perform
login and registration form using servlet and authentication through mysql
login and registration form using servlet and authentication through mysql  i made a simple login and rgistration form using servlet... help here is my code...plz chk the web.xml file also index.jsp(login form) <
Display Logo on login form using swing
Display Logo on login form using swing In this tutorial, you will learn how to display a logo in login form using swing components. Here is an example where... a logo for this login form, we have used ImageIcon class that accepts the image
login authentication - Java Beginners
login authentication  i 've problem in authenticating users thru jsp and java bean. cud u pls help me. here is the bean and jsp code samples. after... to successloging java bean code -------------- public void
login authentication - Java Beginners
login authentication  i 've designed the jsp page for login. now i need to connect it with the bean and do authentication for the login for the "register" table in mysql. can anybody help me with the code immediately
login and register - Java Beginners
login and register  pls send me the code for login and register immediately  Hi friend, Please specify the technology you want code for login and register. For example : JSP,Servlet,Struts,JSF etc
login screen - Java Beginners
login screen  how can code a login screen please send me the code...(500,80,100,20); SUBMIT=new JButton("Login"); SUBMIT.setBounds... * FROM login where username='"+value1+"' and password='"+value2
need a login applet in java
need a login applet in java  i'm java beginner. Can some java master teach me how to write a login applet? combine with my coding import javax.swing.*; import java.applet.*; import java.awt.*; import java.util.*; import
need a login applet in java
need a login applet in java  i'm java beginner. Can some java master teach me how to write a login applet? combine with my coding import javax.swing.*; import java.applet.*; import java.awt.*; import java.util.*; import
 

 

 

DMCA.com