Friday, October 26, 2012

Code used in video "Java prog#24.confermation to detele data (Do you really want to delete ) in NetBeans java GUI"

Here I am providing the downloadable code link of  the java code I have used in the video
 "Java prog#24. confirmation to delete data (Do you really want to delete ) in NetBeans java GUI"  of my YouTube channel ProgrammingKnowledge

Click Link to watch the video LINK

This code below is for the cmd_deleteActionPerformed method action perform



 private void cmd_deleteActionPerformed(java.awt.event.ActionEvent evt) {                                           
        int p = JOptionPane.showConfirmDialog(null,"Do you really want to delete","Delete",JOptionPane.YES_NO_OPTION );
       if(p==0){
        String sql="delete from Empoyeeinfo where Empoyeeid =?";
        try{
        
            pst=conn.prepareStatement(sql);
            
            pst.setString(1, txt_Empoyeeid.getText());
            
            pst.execute();
            JOptionPane.showMessageDialog(null, "Deleted");
        
        }catch(Exception e){
        
         JOptionPane.showMessageDialog(null, e);
        
        }
        Update_table();
       }
    }   

Code used in video "Java prog#23.How to open any document e.g .pdf, .doc ,.png file from By a jbutton or jmanu NetBeans"

Here I am providing the downloadable code link of  the java code I have used in the video
 "Java prog#23.How to open any document e.g .pdf, .doc ,.png file from By a jbutton or jmanu NetBeans"  of my YouTube channel ProgrammingKnowledge

Click Link to watch the video LINK

This code below is for the HelpActionPerformed method action perform


  private void HelpActionPerformed(java.awt.event.ActionEvent evt) {                                           
        
              try                                      //try statement
        {
                  Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+"C:\\Users\\FilePath\\Frequently Asked Questions.pdf");
                  
                  
        } catch (Exception e)                    //catch any exceptions here
       {
            JOptionPane.showMessageDialog(null,"Error");  //print the error
       }

        
        
        
    } 

Code used in video "Java prog#22. Using Up/Down Arrow Key to Move in a jtable and get the Data in jtextfield netbeans"

Here I am providing the downloadable code link of  the java code I have used in the video
 "Java prog#22. Using Up/Down Arrow Key to Move in a jtable and get the Data in jtextfield netbeans"  of my YouTube channel ProgrammingKnowledge

Click Link to watch the video LINK

This code below is for the Table_EmployeeKeyReleased method action perform



 private void Table_EmployeeKeyReleased(java.awt.event.KeyEvent evt) {                                           
            if ((evt.getKeyCode() == KeyEvent.VK_UP) ||(evt.getKeyCode() == KeyEvent.VK_DOWN) )
        
        
       // if (evt.getKeyCode()==KeyEvent.VK_DOWN || evt.getKeyCode()==KeyEvent.VK_UP)
        {
        
        try{
         int row =Table_Employee.getSelectedRow();
         String Table_click=(Table_Employee.getModel().getValueAt(row, 0).toString());
         String sql ="select * from Empoyeeinfo where empoyeeid='"+Table_click+"' ";
         pst=conn.prepareStatement(sql);
          rs=pst.executeQuery();
          if(rs.next()){
          
          String add1 =rs.getString("empoyeeid");
          txt_Empoyeeid.setText(add1);
          String add2 =rs.getString("name");
          txt_name.setText(add2);
          String add3 =rs.getString("surname");
          txt_surname.setText(add3);
          String add4 =rs.getString("age");
          combo_age.setSelectedItem(add4);
          }
        
        }catch(Exception e){
        
        JOptionPane.showMessageDialog(null, e);
        }
        } 
        
    }    

Code used in video "Java prog#21.Advanced search a particular data inSQLite (MySql) Database in Netbeans java jtable"

Here I am providing the downloadable code link of  the java code I have used in the video
 "Java prog#21.Advanced search a particular data inSQLite (MySql) Database in Netbeans java jtable"  of my YouTube channel ProgrammingKnowledge

Click Link to watch the video LINK

This code below is for the txt_searchKeyReleased method action perform



  private void txt_searchKeyReleased(java.awt.event.KeyEvent evt) {                                       

     
                       try{
                 
              String sql ="select * from Empoyeeinfo where name =?" ;
              
           
    pst =conn.prepareStatement(sql);
    pst.setString(1, txt_search.getText());
    rs=pst.executeQuery();
    //pst.execute();
    Table_Employee.setModel(DbUtils.resultSetToTableModel(rs));
       
   
   
              String sql3 ="select * from Empoyeeinfo where name =?" ;
              
              pst=conn.prepareStatement(sql3);
               pst.setString(1, txt_search.getText());
               
               rs=pst.executeQuery();
               if(rs.next()){
               String add1=rs.getString("empoyeeid");
               txt_Empoyeeid.setText(add1);
               String add2=rs.getString("name");
              txt_name.setText(add2);
               String add3=rs.getString("surname");
               txt_surname.setText(add3);
               String add4=rs.getString("age");
               combo_age.setSelectedItem(add4);
      
               }
               
               
  
   
              String sql2 ="select * from Empoyeeinfo where empoyeeid =?" ;
              
              pst=conn.prepareStatement(sql2);
               pst.setString(1, txt_search.getText());
               
               rs=pst.executeQuery();
               if(rs.next()){
               String add1=rs.getString("empoyeeid");
               txt_Empoyeeid.setText(add1);
               String add2=rs.getString("name");
              txt_name.setText(add2);
               String add3=rs.getString("surname");
               txt_surname.setText(add3);
               String add4=rs.getString("age");
              combo_age.setSelectedItem(add4);
               
               }
               
               
    
   
              String sql1 ="select * from Empoyeeinfo where surname =?" ;
              
              pst=conn.prepareStatement(sql1);
               pst.setString(1, txt_search.getText());
               
               rs=pst.executeQuery();
               if(rs.next()){
               String add1=rs.getString("empoyeeid");
               txt_Empoyeeid.setText(add1);
               String add2=rs.getString("name");
              txt_name.setText(add2);
               String add3=rs.getString("surname");
               txt_surname.setText(add3);
               String add4=rs.getString("age");
                combo_age.setSelectedItem(add4);
               
               }
               
               
    }
           catch(Exception e)
    {
           JOptionPane.showMessageDialog(null, e);

    }
        
        
    }       

Code used in video "Java prog#20.How to search a particular data inSQLite (MySql) Database in Netbeans java jtable"

Here I am providing the downloadable code link of  the java code I have used in the video
 "Java prog#20.How to search a particular data inSQLite (MySql) Database in Netbeans java jtable"  of my YouTube channel ProgrammingKnowledge

Click Link to watch the video LINK

This code below is for the txt_searchKeyReleased method action perform


  private void txt_searchKeyReleased(java.awt.event.KeyEvent evt) {                  

  try{
                 
               
              String sql3 ="select * from Empoyeeinfo where name =?" ;
              
              pst=conn.prepareStatement(sql3);
               pst.setString(1, txt_search.getText());
               
               rs=pst.executeQuery();
               if(rs.next()){
               String add1=rs.getString("empoyeeid");
               txt_Empoyeeid.setText(add1);
               String add2=rs.getString("name");
              txt_name.setText(add2);
               String add3=rs.getString("surname");
               txt_surname.setText(add3);
               String add4=rs.getString("age");
               combo_age.setSelectedItem(add4);
      
               }
               

               
    }
           catch(Exception e)
    {
           JOptionPane.showMessageDialog(null, e);

    }


                     
}

Code used in video "Java prog#18. How to clear a JTextField with a button in Netbeans Java"

Here I am providing the downloadable code link of  the java code I have used in the video
 "Java prog#18. How to clear a JTextField with a button in Netbeans Java"  of my YouTube channel ProgrammingKnowledge

Click Link to watch the video LINK

This code below is for the cmd_clearActionPerformed method action perform



 private void cmd_clearActionPerformed(java.awt.event.ActionEvent evt) {                                          

        txt_Empoyeeid.setText("");
        txt_name.setText("");
        txt_surname.setText("");
         combo_age.setSelectedItem("");
           CurrentDate();
    }   

Code used in video "Java prog#17.How to update/Edit a data in SQLite (MySql) Database in Netbeans java"

Here I am providing the downloadable code link of  the java code I have used in the video
 "Java prog#17.How to update/Edit a data in SQLite (MySql) Database in Netbeans java"  of my YouTube channel ProgrammingKnowledge

Click Link to watch the video LINK

This code below is for the txt_updateActionPerformed  method action perform



    private void txt_updateActionPerformed(java.awt.event.ActionEvent evt) {                                           
        try{
        
            String value1= txt_Empoyeeid.getText();
             String value2= txt_name.getText();
              String value3= txt_surname.getText();
              // String value4= txt_age.getText();
               
         String value4=combo_age.getSelectedItem().toString();
       
               
               String sql="update Empoyeeinfo set empoyeeid='"+value1+"' ,name ='"+value2+"',surname ='"+value3+"',age='"+value4+"' where empoyeeid='"+value1+"' ";
              pst=conn.prepareStatement(sql);
              pst.execute();
              JOptionPane.showMessageDialog(null, "Updated");
        
        }catch(Exception e){
        
        JOptionPane.showMessageDialog(null, e);
        
        
        }
        Update_table();
    }   

Code used in video "Java prog#16.Deleting Data from an SQLite (MySql) Database in Netbeans java"

Here I am providing the downloadable code link of  the java code I have used in the video
 "Java prog#16.Deleting Data from an SQLite (MySql) Database in Netbeans java"  of my YouTube channel ProgrammingKnowledge

Click Link to watch the video LINK

This code below is for the cmd_deleteActionPerformed  method action perform



 private void cmd_deleteActionPerformed(java.awt.event.ActionEvent evt) {                                           

      String sql="delete from Empoyeeinfo where Empoyeeid =?";
        try{
        
            pst=conn.prepareStatement(sql);
            
            pst.setString(1, txt_Empoyeeid.getText());
            
            pst.execute();
            JOptionPane.showMessageDialog(null, "Deleted");
        
        }catch(Exception e){
        
         JOptionPane.showMessageDialog(null, e);
        
        }
        Update_table();
    }  

Code used in video "Java prog#15.How To Open New Jframe From A jButton in Netbeans java"

Here I am providing the downloadable code link of  the java code I have used in the video
 "JJava prog#15.How To Open New Jframe From A jButton in Netbeans java"  of my YouTube channel ProgrammingKnowledge

Click Link to watch the video LINK

This code below is for the NewbuttonActionPerformed  method action perform




  private void NewbuttonActionPerformed(java.awt.event.ActionEvent evt) {                                         

      
        
        close();
        Userino_frame s = new Userino_frame();
         s.setVisible(true);
    } 

Code used in video "Java prog#14.How to Insert/Save data from netbeans java into database Sqlite (MySql)"



Here I am providing the downloadable code link of  the java code I have used in the video
 "Java prog#14.How to Insert/Save data from netbeans java into database Sqlite (MySql)"  of my YouTube channel ProgrammingKnowledge

Click Link to watch the video LINK

This code below is for the Cmd_saveActionPerformed  method action perform



 private void Cmd_saveActionPerformed(java.awt.event.ActionEvent evt) {                                         
       // File image=null;
       // image=new File(filename);
     //   System.out.println("fhjjjfxjdjdjhdhjdhjdjdj"+image);
       
        try{
           
         String sql ="Insert into Empoyeeinfo (Empoyeeid,name,surname,age,image,gander) values (?,?,?,?,?,?)";
            
         pst=conn.prepareStatement(sql);
         pst.setString(1, txt_Empoyeeid.getText());
         pst.setString(2, txt_name.getText());
         pst.setString(3, txt_surname.getText());
       
         String value=combo_age.getSelectedItem().toString();
         pst.setString(4,value);
         pst.setBytes(5,person_image);
         pst.setString(6,gander );
         
         
         
         //  fis = new FileInputStream(image);
       //   pst.setString(1, jTextField4.getText());
       // pst.setBinaryStream(5, (InputStream)fis, (int)(image.length()));
                //  pst.setBytes(5, person_image);
         pst.execute();
         
          JOptionPane.showMessageDialog(null, "Saved");
            }        
    
           catch(Exception e)
    {
           JOptionPane.showMessageDialog(null, e);

    }
        Update_table();
    } 

Code used in video "Java prog#13.Display Time and Date In java Netbeans"

Here I am providing the downloadable code link of  the java code I have used in the video
 "Java prog#13.Display Time and Date In java Netbeans"  of my YouTube channel ProgrammingKnowledge

Click Link to watch the video LINK
This code below is for the Update table method action perform




public void CurrentDate(){
 

Calendar cal = new GregorianCalendar();

    int month =cal.get(Calendar.MONTH);

    int year =cal.get(Calendar.YEAR);

    int day =cal.get(Calendar.DAY_OF_MONTH);

    date_txt.setText("Date"+year+"/"+(month+1)+"/"+day);

    

    int second =cal.get(Calendar.SECOND);

    int minute =cal.get(Calendar.MINUTE);

    int hour =cal.get(Calendar.HOUR);

    txt_time.setText("Time  "+hour+":"+(minute)+":"+second);

  }

Code used in video "Java prog#10. Display jtextfield when select item in jcombobox in Netbeans Java and Sqlite (mysql)"


HERE I AM PROVIDING THE downloadable CODE LINK OF  THE JAVA CODE I HAVE USED IN THE VIDEO  "Java prog#10. Display jtextfield when select item in jcombobox in Netbeans Java and Sqlite (mysql)"  OF MY YOUTUBE CHANNEL PROGRAMMINGKNOWLEDGE



Click Link to watch the video LINK


This code below is for the example of ComboBox_namePopupMenuWillBecomeInvisible  method action perform
 



  private void ComboBox_namePopupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {                                                           
   
        
        
        String tmp =(String)ComboBox_name.getSelectedItem();            
            String sql="select * from Empoyeeinfo where name=?";
           try{
            pst=conn.prepareStatement(sql);
            pst.setString(1, tmp);
            rs=pst.executeQuery();
            if(rs.next()){
            String add1 =rs.getString("Empoyeeid");
            txt_Empoyeeid.setText(add1);
            String add2 =rs.getString("name");
            txt_name.setText(add2);
            String add3 =rs.getString("surname");
            txt_surname.setText(add3);
            String add4 =rs.getString("age");
             combo_age.setSelectedItem(add4);
            
            
            
            
            }
            }        
    
           catch(Exception e)
    {
           JOptionPane.showMessageDialog(null, e);

    }
           
           
    }       

Thursday, October 25, 2012

Code used in video "Java prog#9. Get value from JTable and set it to jtextfield in Netbeans Java and Sqlite (mysql)"

HERE I AM PROVIDING THE downloadable CODE LINK OF  THE JAVA CODE I HAVE USED IN THE VIDEO  "Java prog#9. Get value from JTable and set it to jtextfield in Netbeans Java and Sqlite (mysql)"  OF MY YOUTUBE CHANNEL PROGRAMMINGKNOWLEDGE


Click Link to watch the video LINK


This code below is for the example of Table_EmployeeMouseClicked method action perform






  private void Table_EmployeeMouseClicked(java.awt.event.MouseEvent evt) {                                            
        
        int row =Table_Employee.getSelectedRow();
         String Table_click=(Table_Employee.getModel().getValueAt(row, 0).toString());
        
     
        try{
         
         String sql ="select * from Empoyeeinfo where empoyeeid='"+Table_click+"' ";
         pst=conn.prepareStatement(sql);
          rs=pst.executeQuery();
          if(rs.next()){
          
          String add1 =rs.getString("empoyeeid");
          txt_Empoyeeid.setText(add1);
          String add2 =rs.getString("name");
          txt_name.setText(add2);
          String add3 =rs.getString("surname");
          txt_surname.setText(add3);
          String add4 =rs.getString("age");
          combo_age.setSelectedItem(add4);
          
          
          int age= Integer.parseInt(add4);
    
          
          }
        
        }catch(Exception e){
        
        JOptionPane.showMessageDialog(null, e);
        }
        
        
        
    }                

Code used in video "Java prog#8. How to close previous jframe on the opening of new jframe in netbeans"

HERE I AM PROVIDING THE downloadable CODE LINK OF  THE JAVA CODE I HAVE USED IN THE VIDEO  "JJava prog#8. How to close previous jframe on the opening of new jframe in netbeans"  OF MY YOUTUBE CHANNEL PROGRAMMINGKNOWLEDGE

Click Link to watch the video LINK

This code below is for the close() function





   public void close(){

 WindowEvent winClosingEvent = new WindowEvent(this,WindowEvent.WINDOW_CLOSING);
 Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(winClosingEvent);

 }

after that you have to call the function using below code


rs.close();
      pst.close();
       close();
//Employee_info  is the frame name you want to open
        Employee_info s =new Employee_info();
       s.setVisible(true);

Other way of doing that is also

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


Java prog#8. How to close previous jframe on the opening of new jframe in netbeans





it's simple just follow the below code:
First import these two files below
import java.awt.event.*;
import java.awt.*;


then write the method for close

 public void close(){

 WindowEvent winClosingEvent = new WindowEvent(this,WindowEvent.WINDOW_CLOSING);
 Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(winClosingEvent);

 }



Java prog#25.Exit Command Button jFrame in Java netbeans 




--------------------------------------------------------------------------------------------------------

Java: How do I close a JFrame while opening another one?
How to close a jframe without closing the main program
Close one JFrame without closing another?
passing data from one jframe to another
How to disable main JFrame when open new JFrame
Opening new JFrame replaces current window
NetBeans Forums - Opening new Jframe in existing window
iit Learn     java netbeans
java tutorial netbeans


How to close a Java Swing application from the code
swing - How do I close a java application from the code
java swing close window
How to close Java program or Swing Application with Example
Closing A Swing Application?
How to close this window? Swing
IT Certification Category (English)640x480

Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com


Top Online Courses From ProgrammingKnowledge

Python Course http://bit.ly/2vsuMaS
Java Coursehttp://bit.ly/2GEfQMf
Bash Coursehttp://bit.ly/2DBVF0C
Linux Coursehttp://bit.ly/2IXuil0
C Course http://bit.ly/2GQCiD1
C++ Coursehttp://bit.ly/2V4oEVJ
PHP Coursehttp://bit.ly/2XP71WH
Android Coursehttp://bit.ly/2UHih5H
C# Coursehttp://bit.ly/2Vr7HEl
JavaFx Coursehttp://bit.ly/2XMvZWA
NodeJs Coursehttp://bit.ly/2GPg7gA
Jenkins Course http://bit.ly/2Wd4l4W
Scala Coursehttp://bit.ly/2PysyA4
Bootstrap Coursehttp://bit.ly/2DFQ2yC
MongoDB Coursehttp://bit.ly/2LaCJfP
QT C++ GUI Coursehttp://bit.ly/2vwqHSZ