How To Create A Swing Application Using NetBeans Swing Builder


This article explains the few basic steps to create a String program on Java NetBean and showing a background image in the frame. There are two approaches to generate this feature, one is by heavy coding, second is to simply use drag and drop actions from the Jpanel of the Jframe windows.




                           Steps to create a new Program Swing Application Project:

  1. Choose a File as  ‘New Project’. This can be done alternately by clicking the New Project icon in the IDE toolbar.
  2. Select the Java node in the Categories pane, and in the Projects pane choose Java application.(Click Next)
  3. Enter Project Name as ProgramSwing and Specify the project location.
  4. Leave the check box for Use Dedicated Folder unchecked, for Storing Libraries.
  5. Make sure that the check box for set as Main Project is checked and clear the Create Main Class field.
  6. Click Finish.

    The IDE Swing Application creates the ProgramSwing folder in the designated location in your system. This folder contains all of the project’s associated files, including scripts, folders for storing source and tests as well as folders for project-specific metadata. To view the project structure, use the IDE’s File window.



Creating a Jframe Container

After creating the new application, you may have noticed that the source packages folder in the projects window contains an empty <ProgramSwing Package> node. To proceed with build our interface, we need to create a java container in which we will place the other required GUI components. In this step, we create a container using the Jframe component and place the container in a new package.

The IDE Swing Application creates the ProgramSwingUI form and also creates the ProgramSwing class with in the application and opens the ProgramSwingUI form in the GUI Builder.


                          The following shows how the Default package is replaced by my.ProgramSwing package:

  1. In the project window, right-click on the ProgramSwing node and choose New>JFrame Form. Alternately, you will find a Jframe form by choosing New>JFrame Form.
  2. Enter ProgramSwingUI as the Class Name.
  3. Enter my.ProgramSwing as the package.
  4. Click Finish.


How to Add the BackGround Images for Jframe

Adding the Background image is just the matter of few drags and drops. Open the Jframe windows, drag the Panel from the Palette which is located in the upper right corner to the Design area.




  1. Add a Jlabel

Drag a Jlabel into the Design Area. Place it on the left of the JtextField, again look for visual cues that suggest an appropriate amount of spacing. Make sure that text base for this component is aligned with that of the JtextField. Go to the Jlable Properties, click the font option than select as Font Design, font size, bold as per your choice. Set the height and width, go to text option and write the name ‘Subscribe Us’ and select foreground color.




  1. Add a JtextField

Now, Drag a JtextField from the Palette to the upper right corner of the Design Area. As you approach the upper right corner, the GUI builder provides visual cues (dashed lines) that suggest the appropriate spacing. Using these cues as a guide, drop a JtextField into the upper Right hand corner. Go to the JtextField Properties click the font option than select FontDesign, fontsize, Bold as per your choice. Set the height and width.




  1. Add a Jbutton

Next, drag a Jbutton form the Palette and drop it in to the left side and underneath the JtextField. Go to the Jbutton properties select the button images, Button size, Height, Width.




  1. Add an another Jlable

And last, drag a Jlabel into the Design Area. Place it to the top of the Jpanel Field, again looking for visual cues that suggest an appropriate amount of spacing. Make sure that text base for this component is aligned with that of the Jform. Go to the Navigator window and drag the all three fields. Jlable, Jtextfield, Jbutton above the last Jlable3[Jlable].



Go to the Jlable Properties and select the Icon option, open the Jlable-icon window select the External image radio button and then choose the image in ProgramSwing/Src/programSwing and select images.

Click OK, and Finish up.


9 source code

To view the code for creating Swing Application, which is generated automatically, click on the source option.


Show the output box message:BUILD SUCCESSFUL(total time: 0 seconds)

Press Shift+F6 to run the



Do subscribe to our newsletter if you think this tutorial was worth your time. Please share, and happy reading.