To create a JFrame project in Netbeans 6.x do the following:

  1.  Start Netbeans
  2.  Close any projects previously left open.
  3.  Under the File menu item, select New Project
  4.  This will bring up the New Project Window, set the following
    • Category - Java
    • Projects - Java Application (not Java Desktop Application)
    • press the Next button
       
  5. The name and location window will now be display, set the following
    • Project Name - use whatever you like (don't use spaces though), e.g . JavaApplication1
    • Project Location - browse to an area on your harddisk, floppy (not recommended) or thumb drive where the project folder is to be created (folder will be created using the project name).
    • Leave on the Set as Main Project box 
    • Turn off the Create Main Class box, if you leave it on, it will automatically create a Main.java file
    • Press Finish 
    • you will now have an empty project created.

To create a Java Application within your project do the following:

  1. From the File menu item, select New File
  2. This will bring up the New File Window, set the following
    • Categories - select Swing GUI Forms
    • File Types - select JFrame Form
    • Press Next
  3. The new JFrame Form window will now be displayed, set the following
    • Fill in the class name, e.g. Demo1.   The first letter of each word in the name should be capitalized, there should be no spaces in the class name.
    • Optionally, fill in the package name, e.g.  application1.  Package names should be in all lower case.
    • Press Finish.
  4. Your program should look something like the picture below
     

 

 

Completing your first application

    private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
       System.exit(0);
    }
  • Run your program,
    • Press on the run button in the tool bar (this button has a green triangle with a yellow folder behind it).
    • If all went well you should see the final image shown below.
       

   


 

 

  • Other things you can do:
    • Change the fonts and colors of the items in your JPanel
    • Right click on the item, then select properties. 
    • To change the fonts, then press the little square button with the three dots next to the font item.
    • To change the color, then press the little square button with the three dots next to the foreground item.