Graphics Program in Java | Through Applet 500+ Programs


Graphics Program in Java Through Applet.

My Dear student we’ll learn how to make an Applet Program in Java, with code. I hope you will learn here something new in a different way. let start:- “Graphics Program in Java Through Applet”.

Write this Applet code in Notepad or Text Editor & Save Name with ““.

Applet programming in java

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

public class Arcdraw extends Applet

  Font f1= new Font("courier New", Font.BOLD, 50);      //("Font_Name",Font.Style, Size)
  Font f2= new Font("Bell MT", Font.BOLD, 28);

public void paint(Graphics g)

  setBackground (Color. blue);

        g.setFont(f1);                                  //Font Name or Variable
        g.drawString("This is an Emoji.",40,350);       //Text and Place 

//g.drawArc(init, init, Width, Height, Start Angel, Stop Angel)

        g.drawArc(95,25,270,270,30,360);                 //CIRCLE 
        g.drawArc(160,80,50,50,30,360);                  //LEYE
        g.drawArc(250,80,50,50,30,360);                  //REYE
        g.fillArc(215,155,30,30,30,360);                 //NOSE
        g.fillArc(195,210,70,60,00,180);                 //LIPS
        g.fillArc(170,95,30,35,30,360);                  //LPUPIL
        g.fillArc(259,95,30,35,30,360);                  //RPUPIL
        g.fillArc(175,104,20,20,25,360);                 //LCORNIA
        g.fillArc(264,104,20,20,25,360);                 //RCORNIA


Again Open Notepad and write this HTML code and Save with same name Arcdraw with extension .html like “Arcdraw.html” :-

HTML code
<Applet code="Arcdraw.class" width=500 height=100>
(In this code Width and Height doesn't affect in Output)

Graphics Program in Java | Through Applet 500+ Programs

Read This for your Basic Knowledge about Applet or Graphics Program in JAVA.


What is Applet ?

:- An Applet is a special type of program that is embedded in the web page to Generate the Dynamic content. It runs inside a browser and work at client site, and Run using the Applet Viewer. It can perform Arithmetic Operation , Display Graphics, Play Sounds, Accept User Input, Create Animation and Play Interactive Games. Graphics program in java. Advantages of Applet:- It is secure. It works at client site so less response time. It can be executed by browser’s and Running under many Platforms. Life Cycle of Applet:- Java Applet inherits a set of default behaviors from the Applet class. New Born ‘or’ Running Idle Dead / Destroy Initialization State:- (Applet enters the initialization state when it loaded first) This is achieved by calling the init() method of Applet class. The Applet is born, at this stage we may do the following things. ‘If required’. Create Object needed by the Applet Set up initial values Load image or fonts Set up colors This initialization occurs only once in the Applet’s life cycle. To provide any of the behaviors that mentioned above, we must override the init() method. The Applet class which is contained in the Java.applet package. It’s provide life and behavior to the applet through it’s method such as init(), start() and point(). This required that the applet code imports the java.awt package that contains the Graphics class. In this all output operations of an applet are performed using the method that defined in the Graphics class.

clearRect()   Erases a rectangular area of the canvas.

copyArea ()    Copies a rectangular area of the canvas to another area.

drawArc ()     Draws a hollow arc.

drawLine()     Draws a straight line.

drawOval()     Draws a hollow oval.

drawPolygon()  Draws a hollow polygon.

drawRect()     Draws a hollow rectangle.

drawRoundRect() Draws a hollow rectangle with rounded corners.

drawString()   Displays a text string.

fillArc()      Draws a filled arc.

fillOval()     Draws a filled oval.

fillPolygon()  Draws a filled polygon.

fillRect()     Draws a filled rectangle.

fillRoundRect() Draws a filled rectangle with rounded corners.

getColor()     Retrieves the current drawing color.

getFont()      Retrieves the currently used font.

getFontMetrics() Retrieves information about the current font.

setColor()     Sets the drawing color.

setsFont()     Sets the font.
                                     Graphics program in java.

Graphics Program in Java | Through Applet 500+ Programs 1

Dear student  I hope you learn here “Applet Programming java” for more deeply knowledge of java click here

Fore more you can also visit this website.

Note:- These days Java is the Second Popular Language and Python is the Number one in whole word. So i suggest to you, if you want to become a good programmer in life. Then you need to Learn it. And update yourself time-to -time.

Best Of Luck

Don’t forget to give your valuable Feedback on Graphics program in java.


One Response
  1. best CBD Oil April 17, 2020 /

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Learn For Free.