Blogroll

This blog is created for education about engineering students.All the engineering students are get free downloadable books here. not only books and also different software also available here

12.b. draw lines,rectangles and ovals


b) Write a Java program that allows the user to draw lines, rectangles and ovals.
//
import java.applet.*;
import java.awt.*;
import javax.swing.*;
public class LinesRectsOvals extends JApplet
{
public void paint(Graphics g)
{
super.paint(g);
g.setColor(Color.red);
g.drawLine(5,30,350,30);
g.setColor(Color.blue);
g.drawRect(5,40,90,55);
g.fillRect(100,40,90,55);
g.setColor(Color.cyan);
g.fillRoundRect(195,40,90,55,50,50);
g.drawRoundRect(290,40,90,55,20,20);
g.setColor(Color.yellow);
g.draw3DRect(5,100,90,55,true);
g.fill3DRect(100,100,90,55,false);
g.setColor(Color.magenta);
g.drawOval(195,100,90,55);
g.fillOval(290,100,90,55);
}
}

No comments:

Post a Comment

Total Pageviews