How to Set JFrame Form Icon in GUI using swing (Using Drag & Drop Components In Netbeans IDE) in java.

How to Set JFrame Form Icon in GUI using swing (Using Drag & Drop Components In Netbeans IDE) in java.

In this article we will see two steps for how to set JFrame form icon in GUI using swing (Using Drag & Drop Components In Netbeans IDE) in java.

Step - 1 :

java swing GUI set icon in JFrame form (Drag & Drop Components In Netbeans IDE)

First of all create your project and inside a project create one JFrame Form.

java swing GUI set icon in JFrame form (Drag & Drop Components In Netbeans IDE)

After creating the JFrame form, right click on that and create a windowOpened event.

To create a WindowOpened event right click on JFrame form then Go to Events > Windows > WindowsOpened.

Image icon = Toolkit.getDefaultToolkit().getImage("Your image file path");
setIconImage(icon);

Place the above code in your windowOpened event.

Step - 2 :

java swing GUI set icon in JFrame form (Drag & Drop Components In Netbeans IDE)

Go to source tab.

java swing GUI set icon in JFrame form (Drag & Drop Components In Netbeans IDE)
Image icon = Toolkit.getDefaultToolkit().getImage("Your image file path");
setIconImage(icon);

Place above code after initComponents() as shown in the image above.

Post a Comment

0 Comments