adsense


Showing posts with label JAVA EXAMPLES FILL COLOUR'S USING APPLET. Show all posts
Showing posts with label JAVA EXAMPLES FILL COLOUR'S USING APPLET. Show all posts

Monday, 2 November 2015

JAVA EXAMPLES FILL COLOUR'S USING APPLET PAGE 202

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button



JAVA EXAMPLES FILL COLOUR'S USING APPLET









Java Examples - Fill colour’s using Applet?



Problem Description:
How to fill colors in shapes using Applet?
Solution:
Following 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 willl be drawn in the browser.