
Sir i want ur help in my program. I want to save the data in the database. When i'll click on save button the entered data must be save in the database. I want an action performed method for this.
import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; public class New_Cust extends JFrame implements ActionListener { JLabel l1,l2,l3,l4,l5,l6; JTextField tf1,tf2,tf3,tf4,tf5,tf6; JButton b1,b2; JPanel p; JFrame f;
New_Cust()
{
l1 = new JLabel("Customer Name");
tf1 = new JTextField(5);
l2 = new JLabel("Alias Name");
tf2 = new JTextField(5);
l3 = new JLabel("Address");
tf3 = new JTextField(5);
l4 = new JLabel("Phone No.");
tf4 = new JTextField(5);
l5 = new JLabel("Mobile No.");
tf5 = new JTextField(5);
l6 = new JLabel("E-Mail");
tf6 = new JTextField(5);
b1 = new JButton("SAVE");
b1.setBackground(Color.GRAY);
b2 = new JButton("CANCEL");
b2.setBackground(Color.GRAY);
b1.addActionListener(this);
b2.addActionListener(this);
f = new JFrame();
f.setSize(600,600);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
p = new JPanel();
p.setLayout(null);
p.setBackground(Color.red);
l1.setBounds(100,100,200,30);
tf1.setBounds(250,100,200,30);
l2.setBounds(100,150,200,30);
tf2.setBounds(250,150,200,30);
l3.setBounds(100,200,200,30);
tf3.setBounds(250,200,200,30);
l4.setBounds(100,250,200,30);
tf4.setBounds(250,250,200,30);
l5.setBounds(100,300,200,30);
tf5.setBounds(250,300,200,30);
l6.setBounds(100,350,200,30);
tf6.setBounds(250,350,200,30);
b1.setBounds(100,400,150,30);
b2.setBounds(300,400,150,30);
p.add(l1);
p.add(tf1);
p.add(l2);
p.add(tf2);
p.add(l3);
p.add(tf3);
p.add(l4);
p.add(tf4);
p.add(l5);
p.add(tf5);
p.add(l6);
p.add(tf6);
p.add(b1);
p.add(b2);
f.add(p);
}
public static void main(String args[])
{
New_Cust nc = new New_Cust();
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.