How to Create a new Java Applet in Netbeans

First create a new project. Make sure you select “Java Application” not Desktop Application or other types.

On the left hand of the screen you should see “Source Packages” and your project name in lower case underneath. If you don’t see this in the little window on the left, expand the coffee icon with your project name.


Right click your package (mine is javafileuploader in the screenshot above) and select New->Java Class.

Make sure your new class is selected, and then referencing my code snippet below, import java.applet.* and java.awt.* then add new functions for “paint” and “init”.

(code snippet courtesy of ehow link in references)

 * To change this template, choose Tools | Templates
 * and open the template in the editor.

package javafileuploader;

import java.applet.*;
import java.awt.*;

 * @author fedora
public class NewClass extends Applet {
int m_height, m_width;

public void paint(Graphics m) {
for (int i=0; i<10; ++i)m.drawLine(m_width,m_height,i*m_width/10,0);

public void init() {

Once you have this typed/pasted in, select run->file and voila! you should see a little applet window appear with a green background and oblique lines. You’re now ready to begin. Enjoy!


About Ronnie Diaz

Ronnie Diaz is an enterprise software engineer responsible for front-end and back-end development for companies in many industries. Heavily involved in cloud development, online retail, e-commerce and electronic ordering, fulfillment and customer relational systems.

Posted on November 30, 2012, in Programming & Development and tagged , , , , , , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: