This series introduces you to a step-by-step process to develop Java (or JFC) based applications with Microsoft SQL Server as the database, using NetBeans IDE. In this article, I shall introduce you to finding and traversing rows using Java.
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).
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: