Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package foodchamfinal;
- import java.awt.Color;
- import java.sql.*;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- /**
- *
- * @author lenovo
- */
- public class trial extends javax.swing.JFrame implements Runnable {
- /**
- * Creates new form trial
- */
- static Thread t;
- Connection con=null;
- PreparedStatement ps=null;
- ResultSet rs=null;
- public trial() {
- initComponents();
- }
- public void run(){
- try{
- System.out.println("in");
- Class.forName("com.mysql.jdbc.Driver");
- con=DriverManager.getConnection("jdbc:mysql://localhost:3306/userlogin","root","root");
- ps=con.prepareStatement("Select * from fc2 where table_no='Table1'");
- rs=ps.executeQuery();
- System.out.println("in");
- while(rs.next()){
- button.setBackground(Color.red);repaint();
- System.out.println("next in");
- try {
- text.setText(rs.getString("table_no")+" "+rs.getString("name")+" "+rs.getString("phone_no")+" "+rs.getString("Customize")+""+rs.getInt("quantity1")+""+rs.getString("normal1")+""+rs.getInt("quantity2")+""+rs.getString("normal2")+""+rs.getInt("quantity"));
- } catch (SQLException ex) {
- Logger.getLogger(trial.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }catch(Exception e){
- System.out.println("Exception \n of \n foodcham project \n"+e);
- }
- }
- /**
- * This method is called from within the constructor to initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is always
- * regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- button = new javax.swing.JButton();
- jScrollPane2 = new javax.swing.JScrollPane();
- text = new javax.swing.JTextArea();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- button.setText("jButton1");
- button.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- buttonActionPerformed(evt);
- }
- });
- text.setColumns(20);
- text.setRows(5);
- jScrollPane2.setViewportView(text);
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(85, 85, 85)
- .addComponent(button, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 367, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(73, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(51, 51, 51)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 348, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(button, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(90, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>
- private void buttonActionPerformed(java.awt.event.ActionEvent evt) {
- button.setBackground(Color.white);
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(trial.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(trial.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(trial.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(trial.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new trial().setVisible(true);
- trial tt=new trial();
- t=new Thread(tt);
- t.start();
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JButton button;
- private javax.swing.JScrollPane jScrollPane2;
- private javax.swing.JTextArea text;
- // End of variables declaration
- }
Add Comment
Please, Sign In to add comment