A Fast Gateway to OOP in Java using NetBeans IDE
(Page 1 of 5 )
This series introduces you to object oriented programming in Java visually using NetBeans IDE. This series will be a bit different from traditional introductions to OOP in Java. In traditional introductions of OOP in Java, we are generally used to working with console applications using the command line.
A downloadable file for this article is available
here.
Even though doing things the manual way gives us a better understanding, I prefer fast development and fast learning. This is why I chose NetBeans IDE (which is FREE) to learn and work with OOP in Java very quickly. If you are looking for a manual way of working with Java and learning OOP, this article may not work for you!
I already introduced NetBeans IDE in my first article “Developing Java Applications using NetBeans.” Even though that article is fairly introductory, the next two articles concentrate on the basics of JFC. You can find the next two articles here and here.
If you are new to NetBeans IDE, I strongly suggest you go through the existing articles first, before proceeding with this one. If you are new to developing Microsoft SQL Server based Java applications, I request you go through another article of mine (of course, this is also part of a series) called "Developing SQL Server based Java Applications using NetBeans IDE."
Creating your first class definition in Java using NetBeans IDE: a testing frame
I don’t want to bore you with any introductions to OOP. There are plenty of resources on the web to really learn the concepts of OOP. I would like to focus rather practically.
So, let’s start without wasting a second. Using NetBeans IDE, create a new project and name it “SampleOOPApplication.”
- Within the “Project” view, open “SampleOOPApplication,” right click on “Source Packages,” and go to New -> Java Package (Fig 01).

- Within the “New Package” dialog, provide the package name “MyPack” (Fig02) and click on “Finish.”

- Again, right click on “MyPack” -> New -> JFrame Form (Fig03).

- Within the “New JFrame Form” dialog, give the class name “Test” and click on “Finish.”
- To make this sample simple, right click on the Frame, and go to Set Layout -> Null Layout (Fig04).

- Drop a button (btnShow) and a label (lblMsg) from “Palette” and make sure that the screen looks something like this (Fig05).

- Go to the source view and replace the following:
public class Test extends javax.swing.JFrame {
/** Creates new form Test */
public Test() {
initComponents();
}
with:
public class Test extends javax.swing.JFrame {
/** Creates new form Test */
public Test() {
initComponents();
this.setSize(300,200);
}
Next: Adding your own class >>
More Java Articles
More By Jagadish Chaterjee