Saturday, 1 December 2012

Insert Data into Database using Swings,Applets part-2

// siddhu vydyabhushana // 18 comments
Good evening guys just now i described all functions of java in part 1 .In part-2  am going to give u front end code and explaination..
follow below steps

 PART-1

http://javatyro.blogspot.in/2012/12/insert-data-into-database-using.html


SCREEN SHOT OF MY PROJECT



DOWNLOAD FULL CODING
                                   download



PACKAGES


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

JText Field component in swings used for input fileds

JTextField jt1=new JTextField(20);
JTextField jt2=new JTextField(20);
JTextField jt3=new JTextField(20);
JTextField jt4=new JTextField(20);

JLabel

JLabel jlb1=new JLabel("Username:");
JLabel jlb1=new JLabel("password:");
JLabel jlb1=new JLabel("confirm password:");
JLabel jlb1=new JLabel("email:");

JRadioButton



JRadioButton m, f;
ButtonGroup radio=new ButtonGroup();

 m=new JRadioButton("male");
radio.add(m);//adding item into JFrame

f=new JRadioButton("female");
radio.add(f);//adding item into JFrame

JButton


JButton button=new JButton("Submit");

Adjust  OBJECTS positions in JFrame

name.setBounds(int x,int y,int height,int width);

jlb1.setBounds(40,50,70,30);//adjust label to co-ordinates
jlb2.setBounds(40,90,70,30);//adjust label to co-ordinates
jlb3.setBounds(40,130,70,30);//adjust label to co-ordinates
jlb4.setBounds(40,170,70,30);//adjust label to co-ordinates

jt1.setBounds(130,50,100,30);//adjust JText Field to co-ordinates
jt2.setBounds(130,90,100,30);//adjust JText Field to co-ordinates
jt3.setBounds(130,130,100,30);//adjust JText Field to co-ordinates
jt4.setBounds(130,170,100,30);//adjust JText Field to co-ordinates

m.setBounds(40,210,100,30);//adjust JRadioButton to co-ordinates
f.setBounds(140,210,100,30);//adjust JRadioButton to co-ordinates

button.setBounds(80,250,100,30);//adjust JButton to co-ordinates

ADD OBJECTS TO JFrame

j.add(img1);
j.add(jlb1);
j.add(jt1);
j.add(jlb2);
j.add(jt2);
j.add(jlb3);
j.add(jt3);
j.add(jlb4);
j.add(jt4);
j.add(m);
j.add(f);
j.add(button);
j.add(text);

EVENT HANDLING

button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
//data here
}
});

VALIDATIONS

String name=jt1.getText();
String pass=jt2.getText();
String cpass=jt3.getText();
String email=jt4.getText();
String g=text.getText();

if((name.length()<6)||(name.length()>=15))
{
JOptionPane.showMessageDialog(null,"name field lessthan 15 and greaterthan 6 ");
jt1.setText("");
}
else if(!pass.equals(cpass))
{
JOptionPane.showMessageDialog(null,"password didn't matched");
}
else if(email.length()<10)
{
JOptionPane.showMessageDialog(null,"enter your correct id");
}
else if((m.isSelected()==false)&&(f.isSelected()==false)){
JOptionPane.showMessageDialog(null,"Please select radio button");
}
}

HOW TO POP UP DIALOG


JOptionPane.showMessageDialog(null,"Please select radio button");

18 comments:

  1. packers and movers noida sector 12 @ http://www.noidapackers.co.in/
    packers and movers noida sector 53 @ http://www.noidapackers.co.in/
    packers and movers noida sector 51 @ http://www.noidapackers.co.in/
    packers and movers noida sector 50 @ http://www.noidapackers.co.in/
    packers and movers noida sector 49 @ http://www.noidapackers.co.in/
    packers and movers noida sector 41 @ http://www.noidapackers.co.in/
    packers and movers noida sector 39 @ http://www.noidapackers.co.in/
    packers and movers noida sector 62 @ http://www.noidapackers.co.in/
    packers and movers noida sector 61 @ http://www.noidapackers.co.in/

    ReplyDelete