0% found this document useful (0 votes)
11 views1 page

201-33P - Programming Lab Java-Algorithm - Drawing Shapes with Mouse clicks

The document outlines a Java program to draw shapes (circle, square, ellipse, and rectangle) at mouse click positions using an Applet. It details an algorithm that includes creating the Applet, implementing key and mouse listeners, handling events, and drawing shapes in the paint method. The final steps involve saving and compiling the Applet code, creating an HTML file, and running it with appletviewer.

Uploaded by

Suraj Ladkat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

201-33P - Programming Lab Java-Algorithm - Drawing Shapes with Mouse clicks

The document outlines a Java program to draw shapes (circle, square, ellipse, and rectangle) at mouse click positions using an Applet. It details an algorithm that includes creating the Applet, implementing key and mouse listeners, handling events, and drawing shapes in the paint method. The final steps involve saving and compiling the Applet code, creating an HTML file, and running it with appletviewer.

Uploaded by

Suraj Ladkat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

11.

Write a Java Program to draw circle, square, ellipse and rectangle at the mouse click
positions.

Algorithm:
Aim: Drawing the Shapes Circle, Square, Ellipse and Rectangle at the mouse click positions
Step No. Instructions
1 Start
2 Create an Applet called “list11” by
a) Inheriting the Applet class
b) Implementing the Interfaces namely, KeyListener and MouseListener
3 Use addKeyListener( ) and addMouseListener( ) functions in init( ) method
4 Catch the Key Events using keyTyped( ), keyReleased( ) and keyEntered( )
5 Catch the Mouse Event for the Mouse using mouseClicked( ), mouseReleased( ),
mouseEntered( ), mouseDragged( ), mouseMoved( ), mouseExited( ) and
mousePressed( ) functions
6 Draw the shapes associated with mouse in the paint( ) method using the functions
namely, drawOval( ), drawLine( ) anddrawRect( )
7 Save the Applet code in the name of list11.java
8 Compile the Applet code using javac
9 Create a HTML code with <APPLET> tag with its CODE attribute as list11.class
10 Save the HTML code as list11.html
11 Run the HTML code using appletviewer
12 Stop

You might also like