I have a project that I\'m working one. I have to draw a circle and a square and
ID: 3648928 • Letter: I
Question
I have a project that I'm working one. I have to draw a circle and a square and then fill the background with the color blue. I got the circle and square part but I can't fill the background blue. Would you please help? Here's my code:
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import javax.swing.JApplet;
public class Picture extends JApplet {
private Circle sun;
private Square ground;
public void init()
{
this.setSize(500, 400);
this.setBackground(Color.blue);
sun = new Circle();
sun.setX(60);
sun.setY(50);
sun.setRadius(35);
sun.setFillColor(Color.yellow);
ground = new Square();
ground.setX(0);
ground.setY(300);
ground.setSize(600);
ground.setFillColor(Color.green);
}
public void paint(Graphics g)
{
sun.paintComponent(g);
ground.paintComponent(g);
}
}
Explanation / Answer
hi
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.