How to create different shapes using Applet?
SolutionFollowing example demonstrates how to create an applet which will have a line, an Oval & a Rectangle using drawLine(), drawOval(, drawRect() methods of Graphics clas.
import java.applet.*; import java.awt.*; public class Shapes extends Applet { int x = 300, y = 100, r = 50; public void paint(Graphics g) { g.drawLine(30,300,200,10); g.drawOval(x-r,y-r,100,100); g.drawRect(400,50,200,100); } }Result
The above code sample will produce the following result in a java enabled web browser.
A line , Oval & a Rectangle will be drawn in the browser.
java_applets.htm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4