Guest User

Untitled

a guest
Oct 26th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. error: cannot find symbol
  2. invice invc=new invice();
  3.  
  4. package invicedemo;
  5. public class Invicedemo {
  6. public static void main(String[] args) {
  7. invice invc=new invice();
  8. invc.setSize(300,250);
  9. invc.setTitle("party memo");
  10. invc.setVisible(true);
  11. }
  12.  
  13. }
  14.  
  15. import java.awt.*;
  16. import java.sql.*;
  17. import java.awt.event.*;
  18. import javax.swing.*;
  19. import javax.swing.event.*;
  20. import javax.swing.table.*;
  21.  
  22. public class invice extends JFrame implements ActionListener, KeyListener, FocusListener {
  23.  
  24. JTextField tf, tf1, tf2, tf3;
  25. JButton bt, bt1;
  26. JLabel lb, lb1, lb2, lb3;
  27. Container cn;
  28.  
  29. public invice() {
  30. cn = getContentPane();
  31. cn.setLayout(null);
  32.  
  33. lb = new JLabel("Bill No.:");
  34. lb.setBounds(10, 10, 70, 25);
  35. cn.add(lb);
  36. tf = new JTextField();
  37. tf.setBounds(100, 10, 150, 25);
  38. cn.add(tf);
  39.  
  40. lb1 = new JLabel("Party Name:");
  41. lb1.setBounds(10, 40, 70, 25);
  42. cn.add(lb1);
  43. tf1 = new JTextField();
  44. tf1.setBounds(100, 40, 150, 25);
  45. cn.add(tf1);
  46.  
  47. lb2 = new JLabel("Date:");
  48. lb2.setBounds(10, 70, 70, 25);
  49. cn.add(lb2);
  50. tf2 = new JTextField();
  51. tf2.setBounds(100, 70, 150, 25);
  52. cn.add(tf2);
  53.  
  54. lb3 = new JLabel("Gr No.:");
  55. lb3.setBounds(10, 100, 70, 25);
  56. cn.add(lb3);
  57. tf3 = new JTextField();
  58. tf3.setBounds(100, 100, 150, 25);
  59. cn.add(tf3);
  60.  
  61. bt = new JButton("Store:");
  62. bt.setBounds(30, 160, 70, 25);
  63. cn.add(bt);
  64.  
  65. bt1 = new JButton("Cancel:");
  66. bt1.setBounds(150, 160, 80, 25);
  67. cn.add(bt1);
  68.  
  69. tf.addKeyListener(this);
  70. tf1.addKeyListener(this);
  71. tf2.addKeyListener(this);
  72. tf.addFocusListener(this);
  73. tf1.addFocusListener(this);
  74. tf2.addFocusListener(this);
  75.  
  76. bt.addKeyListener(this);
  77. bt.addFocusListener(this);
  78.  
  79. tf3.addKeyListener(this);
  80. tf3.addFocusListener(this);
  81.  
  82. bt1.addKeyListener(this);
  83. bt1.addFocusListener(this);
  84. bt.addActionListener(this);
  85. bt1.addActionListener(this);
  86. }
  87.  
  88. public void actionPerformed(ActionEvent ae) {
  89.  
  90. if (ae.getSource() == bt) {
  91.  
  92. String party_name = tf.getText();
  93. String date = tf1.getText();
  94. String gr_no = tf2.getText();
  95. String Sno = tf3.getText();
  96.  
  97. try {
  98. Class.forName("com.mysql.jdbc.Driver");
  99. Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "asiya");
  100. Statement st = con.createStatement();
  101. st.executeUpdate("Insert into invis values('" + Sno + "','" + party_name + "', '" + date + "', '" + gr_no + "')");
  102.  
  103. JOptionPane.showMessageDialog(cn, "your data is successfully store", "storage", JOptionPane.INFORMATION_MESSAGE);
  104.  
  105. } catch (Exception e) {
  106. JOptionPane.showMessageDialog(cn, e, "storage", JOptionPane.INFORMATION_MESSAGE);
  107. }
  108.  
  109. }
  110. if (ae.getSource() == bt1) {
  111. tf.setText("");
  112. tf1.setText("");
  113. tf2.setText("");
  114. tf3.setText("");
  115. }
  116. }
  117.  
  118. public void keyPressed(KeyEvent ke) {
  119. if (ke.getSource() == tf && ke.getKeyCode() == KeyEvent.VK_ENTER) {
  120. tf1.requestFocus();
  121. }
  122.  
  123. if (ke.getSource() == tf1 && ke.getKeyCode() == KeyEvent.VK_ENTER) {
  124. tf2.requestFocus();
  125. }
  126.  
  127. if (ke.getSource() == tf2 && ke.getKeyCode() == KeyEvent.VK_ENTER) {
  128. tf3.requestFocus();
  129. }
  130. if (ke.getSource() == tf3 && ke.getKeyCode() == KeyEvent.VK_ENTER) {
  131. bt.requestFocus();
  132. }
  133.  
  134. if (ke.getSource() == bt && ke.getKeyCode() == KeyEvent.VK_ENTER) {
  135. bt1.requestFocus();
  136.  
  137. tf.setText("");
  138. tf1.setText("");
  139. tf2.setText("");
  140. }
  141.  
  142. }
  143.  
  144. public void keyTyped(KeyEvent ke) {
  145. }
  146.  
  147. public void keyReleased(KeyEvent ke) {
  148. }
  149.  
  150. public void focusGained(FocusEvent fe) {
  151. }
  152.  
  153. public void focusLost(FocusEvent fe) {
  154. }
  155. }
Add Comment
Please, Sign In to add comment