Reading a Properties File for a Java Application using NetBeans IDE - Starting to develop a Java application using NetBeans IDE
(Page 3 of 5 )
We shall develop a small application with a button, ScrollPane and TextArea. When the button is hit, it needs to give out the number of rows available. In fact, it needs to connect to the Microsoft SQL Server 2000 instance by reading the connection string (or keys) information from a properties file.
Currently, I named the project "SampleJavaApplication1" and the form (or JFrame) "DBSample02" in the package "MyDBPack."
When the form (or JFrame) is created with "DBSample02," the code behind it (only the constructor) will look something like the following:
public class DBSample02 extends javax.swing.JFrame {
/** Creates new form DBSample02 */
public DBSample02() {
initComponents();
}
Make changes to the above code fragment in such a way that it looks similar to the following:
public class DBSample02 extends javax.swing.JFrame {
/** Creates new form DBSample02 */
public DBSample02() {
initComponents();
this.setSize(300,200);
}
In the above code, I explicitly defined the initial size of the frame. Before dropping all controls on the form, set the layout to "null layout" (fig 01) to ease our development for this article. When you complete your form design, it should look something like the following (fig 01) and the "inspector" view should look something like the following (Fig02).

Fig 1

Fig 2
To make the code easy and convenient to understand, I named those controls as follows:
btnConnect
jScrollPane1
txtMsg
You are also required to import certain necessary packages as shown below:
import java.sql.*;
import java.util.*;
import java.io.*;
I also gave a value to the Frame property "title" (using the property window): "SQL Server Connection: Demo."
Next: Adding a properties file >>
More Java Articles
More By Jagadish Chaterjee