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



Home Answers Viewqa Swing-AWT swings:how to link from one form to another form

Have Programming Question? Ask it here!
 
 
 


sureshkumar
swings:how to link from one form to another form
2 Answer(s)      3 years and 9 months ago
Posted in : Swing AWT


how to link from one form to another form ...


Advertisement
View Answers

November 12, 2010 at 11:46 AM


Hello Friend,

You can try the following code:

1)LoginDemo.java:

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

class LoginDemo{
 JButton SUBMIT,NEWUSER;
 JFrame f;
 JLabel label1,label2;
 final JTextField  text1;
 final JPasswordField text2;
    LoginDemo(){
        f=new JFrame();
        f.getContentPane().setLayout(null);
        label1 = new JLabel();
        label1.setText("UserName:");
        label1.setBounds(400,50,100,20);
        text1 = new JTextField(25);
        text1.setBounds(500,50,100,20);
        label2 = new JLabel();
        label2.setText("Password:");
        label2.setBounds(400,80,100,20);
        text2 = new JPasswordField(25);
        text2.setBounds(500,80,100,20);
        SUBMIT=new JButton("Login");
        SUBMIT.setBounds(400,110,100,20);

        NEWUSER=new JButton("Create Account");
        NEWUSER.setBounds(500,110,200,20);

        f.add(label1);
        f.add(text1);
        f.add(label2);
        f.add(text2);
        f.add(SUBMIT);
        f.add(NEWUSER);
        f.setSize(1024,768);
        f.setVisible(true);
        SUBMIT.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent ae){
        String value1=text1.getText();
        String value2=text2.getText();
        String user1="";
        String pass1="";
        try{
                  Class.forName("com.mysql.jdbc.Driver").newInstance();
            Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql", "root", "root");
                 Statement st = con.createStatement();
                 ResultSet res = st.executeQuery("SELECT * FROM  login where username='"+value1+"' and password='"+value2+"'");
                 while (res.next()) {
                 user1 = res.getString("username");
                 pass1 = res.getString("password");
        }
        if(value1.equals(user1) && value2.equals(pass1)) {
        JOptionPane.showMessageDialog(null,"Welcome");
        }
        else{
        JOptionPane.showMessageDialog(null,"Incorrect login or password","Error",JOptionPane.ERROR_MESSAGE);
                }
        }
                catch(Exception e){
        System.out.println(e.getMessage());
                }
        }
        });
        NEWUSER.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent ae){
        CreateAccount acc=new CreateAccount();
        }
        });
    }
        public static void main(String arg[])   {
        LoginDemo frame=new LoginDemo();
            }
}


November 12, 2010 at 11:46 AM


continue..

2)CreateAccount.java:

import javax.swing.*;
import java.awt.*;
 import java.sql.*;
 import java.awt.event.*;
class CreateAccount extends JFrame{
    JTextField text1,text2,text3,text4,text5;
    JPasswordField pass1;
    JLabel label1,label2,label3,label4,label5,label6;
    JPanel panel;
    JButton button;
    CreateAccount()  {
    text1=new JTextField(15);
    text2=new JTextField(15);
    text3=new JTextField(15);
    pass1=new JPasswordField(15);
    text4=new JTextField(15);
    text5=new JTextField(15);
    label1=new JLabel("Name");
    label2=new JLabel("Address");
    label3=new JLabel("Contact No");
    label4=new JLabel("Email");
    label5=new JLabel("City");
    label6=new JLabel("State");
    button=new JButton("Save");
    panel=new JPanel(new GridLayout(7,2));
    panel.add(label1);
    panel.add(text1);
    panel.add(label2);
    panel.add(text2);
    panel.add(label3);
    panel.add(text3);
    panel.add(label4);
    panel.add(pass1);
    panel.add(label5);
    panel.add(text4);
    panel.add(label6);
    panel.add(text5);
    panel.add(button);
    button.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent ae){
                String value1=text1.getText();
                String value2=text2.getText();
                String value3=text3.getText();
                String value4=pass1.getText();
                String value5=text4.getText();
                String value6=text5.getText();
    try{
                 Class.forName("com.mysql.jdbc.Driver");
                 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
                 Statement st = con.createStatement();
                  int k=st.executeUpdate("insert into employee(name,address,contactNo,email,city,state) values('"+value1+"','"+value2+"','"+value3+"','"+value4+"','"+value5+"','"+value6+"')");
                 JOptionPane.showMessageDialog(null,"Data is successfully inserted");
                 }
            catch(Exception e){
            System.out.println(e);
            }
            }
            });
            add(panel);
            setSize(300,400);
            setVisible(true);
      }
      public static void main(String args[]){
          CreateAccount acc=new CreateAccount();
      }   
}

Thanks



Related Tutorials/Questions & Answers:
swings:how to link from one form to another form
swings:how to link from one form to another form  how to link from one form to another form
how to use one form out of multiple form from one jsp to another jsp
how to use one form out of multiple form from one jsp to another jsp  Hi All. please give me your valuable advise for below requirement.. I have... one form from abc.jsp as it is to another .jsp(say def.jsp).Your advise
Advertisements
Return Value from One Form
Return Value from One Form  I have two buttons in main form client... is there.when i click dedupe button another form will open. i want to get a field value of dedupe form and use in bank form..how to do
Javascript coding for link a website to another upon verify the form - Java Beginners
Javascript coding for link a website to another upon verify the form  Pls tell me javascript coding for " open a website when we click the verify button in the form? ( after verifying the form go to the desired website). 
Pass values from form to form
Pass values from form to form       Java program to pass values from one form to another form... values from one page to another consecutive page which is being called then we can
form
form   Can I prevent a form from being submitted again
displaying data from ms excel in form.
some logic on how to link this image from my folder to the image.jpg mentioned...displaying data from ms excel in form.  Hi all, I have a requirement.... In one of the column i am also storing the name of a pic file.. say image.jpg
calling one jsp from another jsp page
calling one jsp from another jsp page  need coding for calling one jsp from another jsp including the xml file.Its urgent
How to navigate from one jsf to another in eclipse
How to navigate from one jsf to another in eclipse  Hi there is my...; <h:outputText value="USER DETAILS FORM"> </h:outputText> </b> <p> <h:messages style="color: blue"/> </p> <h:form
Displatying java script form submitted elements in another page
Displatying java script form submitted elements in another page   hi... after submitting the registration form. I want to get the values after submitting the form
File copy from one directory to another in java
File copy from one directory to another in java  I am trying to find very good code example for copying a file from one directory to another... from a directory to another directory. How to achieve this? Is there any API
update one table from another table
update one table from another table  hello, i need to update one table fields by using another table fields. I have to tables Products.... for example TotalQuantity field from Products table should be updated if i
to bring checked data from one page to another
to bring checked data from one page to another  thanks for your help... there is one jsp page , on it there is a link, on click of which it is opening second... fetching data from the database on second jsp page with checkbox corresponding each
How to forward the control from one jsp to another?
How to forward the control from one jsp to another?  Hi! This is Prasad Jandrajupalli. I have the 3 JSP's, but I want communicate with each... is not communicate with the Third JSP. I want forward the control from first jsp to second
copying data from one table to another
copying data from one table to another  i need to copy data from one table to another table.. i.e the 1st eid of employee table must be copied to the 1st eid in appusers table, 2nd eid of employee to the 2nd eid of appusers
image upload with jsp from form
image upload with jsp from form  hi i used the code specified in your following post http://www.roseindia.net/answers/viewqa/JSP-Servlet/9749-image-upload-and-stored-in-database.html but i am getting following error
how to pass a string from one class to another
how to pass a string from one class to another  hi all, Good morning... string from one class to another. import java.util.*; class A{ static String... string from one class to another. import java.io.*; class Class1 { public
passing data from one jframe to another
passing data from one jframe to another  I have two JFrame,built by using the GUI Editor netbeans 6.9.i have to pass a data from a Jtextfield in the first Jframe to another JLabel in the other JFrame.Can you please help me,how
Exception during parsing a parameter from the form in JSP
Exception during parsing a parameter from the form in JSP  Exception during parsing params from a form? I get parameters from a html form. I parse the integer one in the JSP file, but I get exception. Is there anyway I can get
Display tow dimensional array by matrix form using one for loop in java
Display tow dimensional array by matrix form using one for loop in java  Display tow dimensional array by matrix form using one for loop in java
one frame update another frame
one frame update another frame  How do I make a link or form in one frame update another frame
value in div from php, reloading form
value in div from php, reloading form  I am having one form with name... have taken two forms login.php in which i am building form and login2.php... getting two forms visible on the same page, i want to omit the first one when i go
PHP form
not getting How to read these Multiple textfield with the same name values in another form and update them to respective coloumn... Please any one help mo out please...PHP form  Hi Sir/Madam, I am developing an attendance form using php
JSP to add details to a database from a HTML form.
JSP to add details to a database from a HTML form.  Hi I'm a second year CS student who has to use JSP to validate a HTML form and add the details... from form and stores it in User--%> String Pword = request.getParameter
how to copy file from one directory to another in java with examples
how to copy file from one directory to another in java with examples  how to copy file from one directory to another in java with examples? I want... copy from one directory to another in java. Thanks
Pass cookie from one site to another within the same domain
Pass cookie from one site to another within the same domain  Hi, I want to pass a cookie from one website to another within the same domain. This is just to identify whether the same user is logged in or not. Can anyone help me
File copy from one drive to another. - Java Beginners
File copy from one drive to another.  I want to copy a .mp3 file from one drive(let d: drive)to another drive(let e: drive) in my Windows XP. How can I do
how to pass an array from one jsp to another jsp - JSP-Servlet
how to pass an array from one jsp to another jsp  hi friedns, can any One tell me how to send an array from one jsp to another jsp,pls any one send the code for this.also porvid the code how to retrive the arry in another jsp
problem in sending data from one ip to another ip in JAVA
problem in sending data from one ip to another ip in JAVA  Hi guys . this is naveen kumar...i need a help. i want to connect one ip to another ip... device in JAVA. i know how to ping but don't how to send the msg's to another IP
take data from one table and insert same in another
take data from one table and insert same in another  I want to know when a new field update in table and the same data has to update in another table
how to write function of copy from one to another location in this code
how to write function of copy from one to another location in this code  I need to write a code to copy a file from one location to another using...(); System.out.println(fileName); } } }   hi friend, Please visit the link, may
How to pass variable from one class to another in java
How to pass variable from one class to another in java  How to pass variable from one class to another in java?   Example: public class...; } } //Another class Class2. public class Class2 { public static void main(String
Retrieve value of radio button from database to form
Retrieve value of radio button from database to form  var gn=document.getElementsByName("empg"); //empg is name of radio input type. for(var i=0;i
Fetch the data from mysql and display it on php form
Fetch the data from mysql and display it on php form  when i press on login button, after succesful login the related data of that person should be display in other textbox
Uploading file in servlet from a html form
Uploading file in servlet from a html form  Sir, I want to upload a picture from my html file and save it to my database as BLOB,but what JAR should i use for this purpose i am really confused about.And also is it possible to do
Moving file or directory from one directory to another
Moving file or directory from one directory to another... directory is moved from one directory to another directory. This program... from one directory to another. In this section an example is given
retrieve the records from one table to another table by using cursors
retrieve the records from one table to another table by using cursors  ... from one table to another table by using cursors.The following is my procedure and tables.After execution it insert one extra record to another table. empproc
jsp form
jsp form  hi sir, one got one got in jsp form after entering the data into the form the data is not saving in the database i will send you code of two forms if dnt understand my problem
Copy data from one JTextField to another JTextField
, you will learn how to copy the data from one JTextField into another... Copy data from one JTextField to another JTextField... and then paste into another JTextField. JTextField is used in the swing
dynamic form
dynamic form  I need to make a dynamic form using php, for example, i will need a list of items which when we select one option another list is modified ( like 2 lists of countries and citys from a dtabase ), and also a radio
Problem passing a value from one jsp to another using href
Problem passing a value from one jsp to another using href  first page.jsp <a href="common.jsp?param=<%l.get(k).parentname%>"> common.jsp <%String attr=request.getAttribute("param"); out.print(attr
Problem passing a value from one jsp to another using href
Problem passing a value from one jsp to another using href  first page.jsp <a href="common.jsp?param=<%l.get(k).parentname%>"> common.jsp <%String attr=request.getAttribute("param"); out.print(attr
Multipage form
Multipage form  I have a multipage form in php with 2 pages wnhen i submit the form data from both the pages should go in database how should i pass teh data from 1st page to 2nd page and then put the entire form data in mysql
retrieving of data from one jsp to another jsp - JSP-Servlet
retrieving of data from one jsp to another jsp  using jsp i m displaying a table ,in table i m displaying a radio button then values like id,name etc ,if i click on an radio button i have to get a corresponding id value
jsp form
jsp form  hai... GoodEvening I have one doubt on jsp.please wil u clarify it. how to move one jsp form to another jsp form with out using forward...)form1.jsp: <html> <form method="post" action="form2.jsp"> <table>
how to go from one frame to another frame in swings - Java Beginners
how to go from one frame to another frame in swings  Hi, My task is to go from one frame to another.......... let us think that iam having two... this task in swings or applet......... i have gone through one example of login
calling one jsp from another jsp - JSP-Servlet
calling one jsp from another jsp  Hi All, In my web application... in two.jsp by using jsp declarative tag. Now from one.jsp file I want to call... start from where we call this two.jsp files method. i.e. in one.jsp file at line
form validation
form validation  how the form validation is done in jsf form using javaScript
how to fill up a form automaically from database and print it
how to fill up a form automaically from database and print it  sir,i am designing a medical license website.i need to fillup a license form atuomatically from details stored in database.ex:if there are details of a person like
how to fill up a form automaically from database and print it
how to fill up a form automaically from database and print it  sir,i am designing a medical license website.i need to fillup a license form atuomatically from details stored in database.ex:if there are details of a person like
Advertisements
 

 

 

DMCA.com