How to Make a Java Applet

Part 1 of 4:

Setting up the Environment

  1. How to Make a Java Applet Picture 1
    Download and install JDK from http://java.sun.com/javase/downloads/index.jsp.
    1. Download and install some Java IDE, to make things easier. Netbeans or Eclipse are good Open Source tools.
  2. How to Make a Java Applet Picture 2
    Make a folder for your source codes and projects.
Part 2 of 4:

Testing the Sample Applet

  1. How to Make a Java Applet Picture 3
    Open NotePad and copy and paste the code in the code section.
  2. How to Make a Java Applet Picture 4
    Click file, and then click save as, and save it in your java folder but name the code "test.java" (without quotation marks)
  3. How to Make a Java Applet Picture 5
    Exit the window and click start, run, then type in cmd in the box and hit ok.
  4. How to Make a Java Applet Picture 6
    Type cd C:jdk6bin and hit enter
  5. How to Make a Java Applet Picture 7
    Type javac then C:javatest.java and hit enter.
  6. How to Make a Java Applet Picture 8
    Now copy and paste the launcher into NotePad and Click file, and then click save as, and save it in your java folder but name the launcher. "test.htm" (without quotation marks).
  7. How to Make a Java Applet Picture 9
    Now go to the java folder you made and launch the test.htm file.
Part 3 of 4:

Embedding a Java program into an applet

  1. Note: You need to know how to program Java in order to make your own applet.
  1. How to Make a Java Applet Picture 10
    Open your MAYANK of choice or a simple text editor (like notepad in windows).
  2. How to Make a Java Applet Picture 11
    Code a Java program to do something. Make it a subclass of JPanel[1], so you can put it into a top level swing container like a JApplet[2] or a JFrame[3]
  3. How to Make a Java Applet Picture 12
    Create a basic JApplet to launch your JPanel program.
    1. Override the
      start()
      method, get a reference to the contentPane, add your JPanel to it and repack the Applet.
      1. You might need to fine-tune the component allocation on the JPanel, to better fit the applet window.
  4. How to Make a Java Applet Picture 13
    Use the same procedure as for compiling and loading the sample applet to pack your program and run it on the basic launcher.
Part 4 of 4:

Sample Code

Basic "Hello World" Applet

import java.awt.*; import java.applet.Applet ; public class test extends Applet { public void paint (Graphics g) { g.drawString("Hello World!", 80, 80); g.drawString("This Is My First JAVA Code!!!!",100,100); } } 

HTML Launcher

<title> My Applet title> <applet code="test.class" Width = 700 height = 400> applet> 
5 ★ | 1 Vote

May be interested

  • What is the difference between Go and Java?What is the difference between Go and Java?
    is golang better than java? is golang harder than java? can golang replace java? this comparison will give you the answer.
  • How to Fix JavaHow to Fix Java
    java is a computing platform that allows you to play games and view videos on your computer. you can tell that your computer is having problems with java if you see java errors appear when you try to run a program or visit a website that...
  • How to Compile a Java ProgramHow to Compile a Java Program
    this wikihow teaches you how to turn your java source code into an executable app using a local and online compiler. if you're using a computer, the most common way to compile java code is using java software development kit (java sdk)...
  • Oracle wants to turn Java EE into fully open sourceOracle wants to turn Java EE into fully open source
    this week, oracle announced plans to move java ee project management to an open source platform, like apache or eclipse.
  • Write and run Java code on the computer for the first timeWrite and run Java code on the computer for the first time
    after you've installed java and set up a path on your computer, you need to know how to run a simple java code on your computer. in this article, we will try to write the first java program, as well as the commands to run this program in cmd.
  • Download Java Runtime Environment 8-build-251Download Java Runtime Environment 8-build-251
    java runtime environment (jre) is a software class that provides the services needed to execute java applications. it is an essential component of the java development kit (jdk) and contains all the tools needed to run various java-based software programs.
  • How to Enable JavaHow to Enable Java
    java is a programming language and platform commonly used in a number of websites and applications. when java is not enabled, you can experience difficulty with viewing or using certain websites and applications. to use java, you must have...
  • 200 common Java interview questions, with reference answers200 common Java interview questions, with reference answers
    if you are going to a java interview, preparing for java programming language questions is necessary. these java interview questions are compiled from tutorialspoint and are accompanied by reference answers.
  • What is the difference between Java and JavaScript?What is the difference between Java and JavaScript?
    although the names of java and javascript seem to be related (javascript seems to be a script in java?), but that's the only similarity. these two languages ​​are not technically related to each other.
  • How to uninstall Java on MacHow to uninstall Java on Mac
    whether you're sick of java's security issues or find it unnecessary, there's a fairly easy way to uninstall java from your mac using java's installer.