How to fill colors in shapes using Applet?
SolutionFollowing example demonstrates how to create an applet which will have fill color in a rectangle using setColor(), fillRect() methods of Graphics class to fill color in a Rectangle.
import java.applet.*; import java.awt.*; public class fillColor extends Applet { public void paint(Graphics g) { g.drawRect(300,150,200,100); g.setColor(Color.yellow); g.fillRect( 300,150, 200, 100 ); g.setColor(Color.magenta); g.drawString("Rectangle",500,150); } }Result
The above code sample will produce the following result in a java enabled web browser.
A Rectangle with yellow color filled in it 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