import java.awt.*;
import java.applet.*;
/*
<applet code="Sujith" width=200 height=200>
</applet>
*/
public class Sujith extends Applet
{
public void paint(Graphics g)
{
for(int i=0;i<=250;i++)
{
Color c1=new Color(35-i,55-i,110-i);
g.setColor(c1);
g.drawRect(250+i,250+i,100+i,100+i);
g.drawOval(100+i,100+i,50+i,50+i);
g.drawLine(50+i,20+i,10+i,10+i);
}
}
}
Output:
Editorial Team
We are a group of young techies trying to provide the best study material for all Electronic and Computer science students. We are publishing Microcontroller projects, Basic Electronics, Digital Electronics, Computer projects and also c/c++, java programs.
23 thoughts on “Java applet program that allows the user to draw lines, rectangles and ovals”
thanq
very nice and its helful for beinners.
I want deficault java pkg programs
plz send me the applet program to draw a simple computer….
awesome!! thanku:)
type this in notepad and save it as ComboProg.java.
import java.awt.*;
import java.applet.*;
public class ComboProg extends Applet
{
int x,y,h,w;
public void paint(Graphics g)
{
g.drawRect(10,10,20,30);
g.drawOval(30,50,100,200);
g.drawLine(250,300,400,500);
}
}
*********************************
then type this in another notepad and saving it as ComboProg.html
go to command promt and compile and run the program
procedure
for compiling type
javac ComboProg.java
for viewing the result
appletviewer ComboProg.html
g.drawRect(10,10,20,30); in this command what is what?
prasanth first two 10,10 are position and another two are size
Nice Logic
k tnk q
init() method is not declared
i want to draw rectangle,circle,line by using buttons,
when u click on rectangle button rectangle should display
and when u click on circle ,circle should display
how will compiled and run
i hates ur prgrammmmm
Nice Program need more tough programs
explain the code
Leave a Reply
Get the latest updates on your inbox
Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.
thanq
very nice and its helful for beinners.
I want deficault java pkg programs
plz send me the applet program to draw a simple computer….
awesome!! thanku:)
type this in notepad and save it as ComboProg.java.
import java.awt.*;
import java.applet.*;
public class ComboProg extends Applet
{
int x,y,h,w;
public void paint(Graphics g)
{
g.drawRect(10,10,20,30);
g.drawOval(30,50,100,200);
g.drawLine(250,300,400,500);
}
}
*********************************
then type this in another notepad and saving it as ComboProg.html
go to command promt and compile and run the program
procedure
for compiling type
javac ComboProg.java
for viewing the result
appletviewer ComboProg.html
g.drawRect(10,10,20,30); in this command what is what?
prasanth first two 10,10 are position and another two are size
Nice Logic
k tnk q
init() method is not declared
i want to draw rectangle,circle,line by using buttons,
when u click on rectangle button rectangle should display
and when u click on circle ,circle should display
how will compiled and run
i hates ur prgrammmmm
Nice Program need more tough programs
explain the code