Java
  Home arrow Java arrow Page 2 - Finding and Traversing Rows using NetBeans...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Finding and Traversing Rows using NetBeans IDE
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2006-06-21

    Table of Contents:
  • Finding and Traversing Rows using NetBeans IDE
  • The code generated
  • The heart of the application
  • Explaining the code

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Finding and Traversing Rows using NetBeans IDE - The code generated


    (Page 2 of 4 )

    In this section, I shall give you some overview of the code generated behind the application.  Let me start part by part.

    private javax.swing.JButton btnSearch;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel4;
        private javax.swing.JLabel jLabel5;
        private javax.swing.JLabel lblMsg;
        private javax.swing.JTextField txtDeptno;
        private javax.swing.JTextField txtEmpno;
        private javax.swing.JTextField txtEname;
        private javax.swing.JTextField txtSal;

    Each and every control we drop at design time will be coded something like the snippet above. The respective class will be automatically chosen based on the control you drop from the palette.  Proceeding further, we have the following:

    private void initComponents() {
            jLabel1 = new javax.swing.JLabel();
            txtEmpno = new javax.swing.JTextField();
            btnSearch = new javax.swing.JButton();
            txtEname = new javax.swing.JTextField();
            txtSal = new javax.swing.JTextField();
            txtDeptno = new javax.swing.JTextField();
            jLabel2 = new javax.swing.JLabel();
            jLabel4 = new javax.swing.JLabel();
            jLabel5 = new javax.swing.JLabel();
            lblMsg = new javax.swing.JLabel();

    Every control gets instantiated within "initComponents," which gets executed from the contructor (as shown in previous section).

    getContentPane().setLayout(null);
    jLabel1.setText("Empno:");
    getContentPane().add(jLabel1);
    jLabel1.setBounds(20, 10, 80, 14);
    getContentPane().add(txtEmpno);
    txtEmpno.setBounds(90, 10, 90, 20);
    .
    .
    .

    Currently, for this series, I set "Layout" to null so that I can define my own bounds for every control.  From the above code, you can observe that every control is being provided with certain property values and finally being added to the content panel based on the bounds specified.

    The button declaration would be a bit different because it has some "event" to be published. The following is the relative code for the same:

    btnSearch.setText("Search");
            btnSearch.addActionListener(new
    java.awt.event.ActionListener() {
                public void actionPerformed
    (java.awt.event.ActionEvent evt) {
                    btnSearchActionPerformed(evt);
                }
            });
            getContentPane().add(btnSearch);
            btnSearch.setBounds(190, 10, 90, 23);

    The above code would simply add a "listener" to the button; we need to write our "button event handling" code in "btnSearchActionPerformed."

    More Java Articles
    More By Jagadish Chaterjee


       · Hello, another contribution got added to the netbeans series. enjoy and give me...
     

    JAVA ARTICLES

    - Deploying Multiple Java Applets as One
    - Deploying Java Applets
    - Understanding Deployment Frameworks
    - Database Programming in Java Using JDBC
    - Extension Interfaces and SAX
    - Entities, Handlers and SAX
    - Advanced SAX
    - Conversions and Java Print Streams
    - Formatters and Java Print Streams
    - Java Print Streams
    - Wildcards, Arrays, and Generics in Java
    - Wildcards and Generic Methods in Java
    - Finishing the Project: Java Web Development ...
    - Generics and Limitations in Java
    - Getting Started with Java Web Development in...







    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek