Answer to Question #104770 in Java | JSP | JSF for Flores

Question #104770
write a program to create a picture frame. use fillRect() to create the bottom layer in one color. use another fillRect for an inner rectangle for the next layer in another color. finally use fillOval() inside the inner rectangle for the top layer in a 3rd color
1
Expert's answer
2020-03-11T09:07:45-0400

import java.awt.Color;

import java.awt.Graphics;

import javax.swing.JFrame;


public class Main {


   public static void main(String[] args) {

      new JFrame("picture frame"){

         {

            setBounds(200, 200, 500, 500);

            setVisible(true);

            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);            

         }


         public void paint(Graphics g)

         {

            super.paint(g);


            g.setColor(Color.red);

            g.fillRect(0, 0, 500, 500);


            g.setColor(Color.green);

            g.fillRect(100, 100, 300, 300);


            g.setColor(Color.blue);

            g.fillOval(100, 100, 300, 300);         

         }

      };

   }

}



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS