Search This Blog

Sunday, 21 August 2022

B3. NEP Java Program to draw several shapes in the created window.

//B3. NEP Java Program to draw several shapes in the created window.

 /*

<applet code = ProgB3.class width=600 height=600>

</applet>

*/

import java.applet.*;

import java.awt.*;

public class ProgB3 extends Applet

{

    Font  f1;

           //Function to initialize applet

        public void init()

        {

             f1=new Font("Georgia",Font.BOLD,22);

        setBackground(Color.gray);

             setLayout(null);

        }

   

   //Function to draw shapes

   public void paint(Graphics g)

        {

        g.setFont(f1);

        g.setColor(Color.green);

        g.drawString("Different Shapes",10,20);

        g.setColor(Color.blue);

        g.drawLine(100,200,50,60);

        g.setColor(Color.red);

        g.drawOval(120,120,70, 90);

        g.setColor(Color.orange);

        g.drawRect(200, 250, 90, 100);

        }

}

No comments :

Post a Comment

FREE Hit Counters