Draw colorful Lines in Applet


//Write a program in Java to Draw multiple colorful Lines in Applet

import java.applet.*;
import java.awt.*;
public class dLines extends Applet {

int w, h;

public void init()
{
w = getSize().width;
h = getSize().height;
setBackground( Color.black );
}

public void paint( Graphics g )
{
g.setColor( Color.red );
for ( int a= 0; a < 50; a++ )
{
g.drawLine( w, h, a * w / 50, 0);
}
g.setColor( Color.green );
for ( int b= 0; b < 30; ++b )
{
g.drawLine( w, h, b * h / 30, 0);
}
g.setColor( Color.yellow );
for ( int c= 0; c < 10; c++)
{
g.drawLine( w, h, c* h / 10, 0);
}

}}

Output :

javaLi

Related Posts

Comments are closed.