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



Home Answers Viewqa Swing-AWT Swing Program

Have Programming Question? Ask it here!
 
 
 


Kaushlendra
Swing Program
1 Answer(s)      3 years and 3 months ago
Posted in : Swing AWT


write a java swing program to get username and password. The name contains only characters while password is masked with the characters "*". Apply checks for all validation.


Advertisement
View Answers

May 9, 2011 at 12:38 PM


import javax.swing.*;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;

class LoginDemo extends JFrame{
 JButton SUBMIT;
 JLabel label1,label2;
 final JTextField  text1,text2;
  LoginDemo(){
    setTitle("Login Form");
    setLayout(null);
    label1 = new JLabel();
    label1.setText("Username:");
    text1 = new JTextField(15);

    label2 = new JLabel();
    label2.setText("Password:");
    text2 = new JPasswordField(15);

    SUBMIT=new JButton("SUBMIT");
    label1.setBounds(350,100,100,20);
    text1.setBounds(450,100,200,20);
    label2.setBounds(350,130,100,20);
    text2.setBounds(450,130,200,20);
    SUBMIT.setBounds(450,160,100,20);
   add(label1);
   add(text1);
   add(label2);
   add(text2);
   add(SUBMIT);

   setVisible(true);
   setSize(1024,768);

 SUBMIT.addActionListener(new ActionListener(){
   public void actionPerformed(ActionEvent ae){
    String value1=text1.getText();
    String value2=text2.getText();
    try{
    Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from login where username='"+value1+"' and password='"+value2+"'");
           int count=0;
           while(rs.next()){
               count++;
           }
 if(count>0) {
       JOptionPane.showMessageDialog(null,"Welcome: "+value1);

    }
 else {

     JOptionPane.showMessageDialog(null,"Error!");
     text1.setText("");
     text2.setText("");
     }
    }
    catch(Exception e){}
}
 });
  }
  public static void main(String arg[]){
  new LoginDemo();
}
}


Related Tutorials/Questions & Answers:
Swing Program
Swing Program  Write a java swing program to calculate the age from given date of birth
swing program
swing program  Write a java swing program to getname and email id. Display the message if email id contains the name of theuser
Advertisements
Swing Program
Swing Program  write a java swing program to get user name and password. The name contains only characters while password is masked with the character "*". Apply checks for all validation
Swing Program
Swing Program  Write a java swing program that takes name and marks as input with all validation. The name and marks will be displayed in message box when user clicks on a button
Swing Program
Swing Program  Write a java swing program to search the details of the students. Searching is performed on student's first name. The details of all those students having same name as in given in searching criterion
Swing program
Swing program  Write a java swing program to get name and email id. Display the error message if email id is not in xxxxx@xxxx.xxx format.   import java.awt.*; import java.sql.*; import javax.swing.*; import
Swing Program
Swing Program  write a java swing program to get username and password. The name contains only characters while password is masked with the characters "*". Apply checks for all validation.   import javax.swing.*; import
swing program
swing program  Iam using one JFrame and 4 JPanels one JTabbedPane. my problem is next, previous buttons. when click next button visible some JPanels,again press visble another JPanels. also previous button. how to write the logic
swing program for decimal to binary
swing program for decimal to binary  swing program for decimal to binary
Program for Calculator - Swing AWT
Program for Calculator  write a program for calculator?  Hi Friend, Please visit the following link: http://www.roseindia.net/java/example/java/swing/calculator-in-swing.shtml Hope that it will be helpful
Java Program - Swing AWT
Java Program  A program to create a simple game using swings.  Hi Friend, Please visit the following link: http://www.roseindia.net/tutorial/java/swing/guessNumber.html Thanks
swing chatt program
swing chatt program  how to invoke the code from JTextArea to Socket   package magesh; import java.net.Socket; import java.io.DataInputStream; import java.io.PrintStream; public class Client { public Client
Java Program - Swing AWT
Java Program  A Java Program to send message from one computer to another
Java Program - Swing AWT
Java Program  A Java Program that display image on ImageIcon after selecting an image from the JFileChooser
Java Program - Swing AWT
Java Program  A java Program that send message from one computer to another and what are the requirements
Java Program - Swing AWT
Java Program  Write a Program that display JFileChooser that open a JPG Image and After Loading it Saves that Image using JFileChooser  Hi Friend, Try the following code: import java.io.*; import java.sql.
swing program plz urgent sir - Java Beginners
swing program plz urgent sir   hi sir,i waan a jtable swings program table having column names "itemid","price".Initially table having single empty row.whenever we click the "enter" button automatically new row will be insert
opening internet browser in java program - Swing AWT
opening internet browser in java program  i want a code to open the internet browser in swing program using JFrame.  Hi Omkar, Use the following code: 1) 'OpenBrowser.java' import javax.swing.*; import
swing
swing  Write a java swing program to delete a selected record from a table
problem in swing program for opening two windows with same login credentials
problem in swing program for opening two windows with same login credentials  I Face two problems while writing the code in swing program 1.i developed one application using swings that has username,password when i login
Swing
Swing  Write a java swing program to search the details of the students. Searching is performed on studentā??s first name. The details of all those students having same name as in given in searching criterion will be displayed
Swing
Swing  Write a java swing program to search the details of the students. Searching is performed on studentā??s first name. The details of all those students having same name as in given in searching criterion will be displayed
SWING
SWING  A JAVA CODE OF MOVING TRAIN IN SWING
swing
swing  How to make swing component auto-resizable when JFrame resize
java program for Denial of Service (DoS) attacks detection - Swing AWT
java program for Denial of Service (DoS) attacks detection  i want a simple program to generate and detect a Denial of Service (DoS) attacks. using java program
Writing Calculator Program in Swing
Writing Calculator Program in Swing   ... illustrates you how to a create calculator in Swing with the source code and screen shot. For developing a small calculator program in swing we need two different
Swing
Swing  Hi, I need a program to read text from a text file to Jframe directly without browsing. Thank u   Please visit the following link: Extract file data to JTable
Java swing
Java swing  Write a java swing program to calculate the age from given date of birth
Java - Swing AWT
Java  write a swing program to display the contents of a database in a JTable
swing-awt - Swing AWT
swing-awt  Hi, Thanks for replying to my question...I'm getting some confusion to add action events in my application(Rich Text Editor).How to add action events? Thank U
java swing - Swing AWT
java swing  how i can insert multiple cive me exampleolumn and row in one JList in swing?plz g  Hi Friend, Please clarify your question. Thanks
swing/awt - Swing AWT
swing/awt  How to create richtexteditor using swings...?I'm very much new to swings....It's urgent.....Thank u...   hello read this book you get idea; JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second
Java Swing Tutorials
and you can use it in your program. Java Swing tutorials first gives you brief...; This program shows you how to create a frame in Java Swing Application. The frame...; Writing Calculator program in Swing In this tutorial we
Swing paint - Swing AWT
Swing paint  hi, i want to print something on window using swing applet.. m doing dis.. protected void paintComponent(Graphics g... the Swing Applet, use html file with the following code: Java Applet Demo
SWING FRMES
SWING FRMES  hai SIR? HOW TO DESIGN swing Frames send source code
swing sms
swing sms  HOW TO SEND SMS MESSAGE FROM SWING USING SQL DATABASE
SWING FRMES
SWING FRMES  hai SIR? HOW TO DESIGN swing Frames send source code
java swing - Swing AWT
java swing  how to add image in JPanel in Swing?  Hi Friend, Try the following code: import java.awt.*; import java.awt.image....: http://www.roseindia.net/java/example/java/swing/ Thanks
java swing - Swing AWT
java swing   how i can insert in JFrame in swing?  Hi Friend, Try the following code: import java.awt.*; import javax.swing.*; import java.awt.event.*; class FormDemo extends JFrame { JButton ADD; JPanel
Java - Swing AWT
Java  program to read,add,update,delete the database using swing and servlet
java swing - Swing AWT
java swing   Iam developing a java web browser.Actually my code works fine ie. i can load a web page without proxy.But in my place i have only proxy servers through which i should visit any web site.So, i want my browser also
SWING - Swing AWT
SWING  how can i insert image in Jpanel by extending class with JFrame in swing?  Hi Friend, Try the following code: import java.awt.*; import java.awt.image.*; import java.io.*; import javax.imageio.*; import
tree - Swing AWT
tree  example of tree java program   Hi Friend, Please visit the following code: http://www.roseindia.net/java/example/java/swing/TreeComponent.shtml http://www.roseindia.net/java/example/java/swing
Jva swing
Jva swing   How to create the model form like "Notepad
printing in swing
printing in swing  How can i print payslip in swing
java swing
java swing  view the book details using swing
AWT & SWING
AWT & SWING  What is diffennce between AWT & SWING
Java swing
Java swing  Does Swing contains any heavy weight component
Java swing
Java swing  what are the root classes of all classes in swing
Swing question - Swing AWT
Swing question  I want to move a string in JFrame similarily as done by marquee tag in HTML.The string should move from right to left. How can I do this?  Hi Friend, Try the following code: import java.awt.
 

 

 

DMCA.com