Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- error: cannot find symbol
- invice invc=new invice();
- package invicedemo;
- public class Invicedemo {
- public static void main(String[] args) {
- invice invc=new invice();
- invc.setSize(300,250);
- invc.setTitle("party memo");
- invc.setVisible(true);
- }
- }
- import java.awt.*;
- import java.sql.*;
- import java.awt.event.*;
- import javax.swing.*;
- import javax.swing.event.*;
- import javax.swing.table.*;
- public class invice extends JFrame implements ActionListener, KeyListener, FocusListener {
- JTextField tf, tf1, tf2, tf3;
- JButton bt, bt1;
- JLabel lb, lb1, lb2, lb3;
- Container cn;
- public invice() {
- cn = getContentPane();
- cn.setLayout(null);
- lb = new JLabel("Bill No.:");
- lb.setBounds(10, 10, 70, 25);
- cn.add(lb);
- tf = new JTextField();
- tf.setBounds(100, 10, 150, 25);
- cn.add(tf);
- lb1 = new JLabel("Party Name:");
- lb1.setBounds(10, 40, 70, 25);
- cn.add(lb1);
- tf1 = new JTextField();
- tf1.setBounds(100, 40, 150, 25);
- cn.add(tf1);
- lb2 = new JLabel("Date:");
- lb2.setBounds(10, 70, 70, 25);
- cn.add(lb2);
- tf2 = new JTextField();
- tf2.setBounds(100, 70, 150, 25);
- cn.add(tf2);
- lb3 = new JLabel("Gr No.:");
- lb3.setBounds(10, 100, 70, 25);
- cn.add(lb3);
- tf3 = new JTextField();
- tf3.setBounds(100, 100, 150, 25);
- cn.add(tf3);
- bt = new JButton("Store:");
- bt.setBounds(30, 160, 70, 25);
- cn.add(bt);
- bt1 = new JButton("Cancel:");
- bt1.setBounds(150, 160, 80, 25);
- cn.add(bt1);
- tf.addKeyListener(this);
- tf1.addKeyListener(this);
- tf2.addKeyListener(this);
- tf.addFocusListener(this);
- tf1.addFocusListener(this);
- tf2.addFocusListener(this);
- bt.addKeyListener(this);
- bt.addFocusListener(this);
- tf3.addKeyListener(this);
- tf3.addFocusListener(this);
- bt1.addKeyListener(this);
- bt1.addFocusListener(this);
- bt.addActionListener(this);
- bt1.addActionListener(this);
- }
- public void actionPerformed(ActionEvent ae) {
- if (ae.getSource() == bt) {
- String party_name = tf.getText();
- String date = tf1.getText();
- String gr_no = tf2.getText();
- String Sno = tf3.getText();
- try {
- Class.forName("com.mysql.jdbc.Driver");
- Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "asiya");
- Statement st = con.createStatement();
- st.executeUpdate("Insert into invis values('" + Sno + "','" + party_name + "', '" + date + "', '" + gr_no + "')");
- JOptionPane.showMessageDialog(cn, "your data is successfully store", "storage", JOptionPane.INFORMATION_MESSAGE);
- } catch (Exception e) {
- JOptionPane.showMessageDialog(cn, e, "storage", JOptionPane.INFORMATION_MESSAGE);
- }
- }
- if (ae.getSource() == bt1) {
- tf.setText("");
- tf1.setText("");
- tf2.setText("");
- tf3.setText("");
- }
- }
- public void keyPressed(KeyEvent ke) {
- if (ke.getSource() == tf && ke.getKeyCode() == KeyEvent.VK_ENTER) {
- tf1.requestFocus();
- }
- if (ke.getSource() == tf1 && ke.getKeyCode() == KeyEvent.VK_ENTER) {
- tf2.requestFocus();
- }
- if (ke.getSource() == tf2 && ke.getKeyCode() == KeyEvent.VK_ENTER) {
- tf3.requestFocus();
- }
- if (ke.getSource() == tf3 && ke.getKeyCode() == KeyEvent.VK_ENTER) {
- bt.requestFocus();
- }
- if (ke.getSource() == bt && ke.getKeyCode() == KeyEvent.VK_ENTER) {
- bt1.requestFocus();
- tf.setText("");
- tf1.setText("");
- tf2.setText("");
- }
- }
- public void keyTyped(KeyEvent ke) {
- }
- public void keyReleased(KeyEvent ke) {
- }
- public void focusGained(FocusEvent fe) {
- }
- public void focusLost(FocusEvent fe) {
- }
- }
Add Comment
Please, Sign In to add comment