Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Drawing function descriptions drawLine(int x1, int y1, int x2, int y2) public vo

ID: 3826690 • Letter: D

Question

Drawing function descriptions drawLine(int x1, int y1, int x2, int y2) public void fillOval(int x, int y, int width, int height) drawOval(int x, int y, int width, int height) drawRect(int x, int y, int width, int height) drawString(String str, int x, int y) fillRect(int x, int y, int width, int height) One - Sketch the results of a call to the following paint function public void paintComponent (Graphics g) {g. drawString ("Let It Snow", 100, 100); g.setColor(Color.blue); g.drawOval (200, 150, 50, 50); g. drawOval(187, 200, 75, 75); g.drawOval(175, 275, 100, 100); g.setColor(Color.black); g. drawLine(200, 150, 250, 150); g.fillRect(210, 120, 30, 30);

Explanation / Answer

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class MainClass extends JPanel {


    public void paintComponent(Graphics g) {   

     g.drawString("Let It Snow", 100, 100);
     g.setColor(Color.blue);
   g.drawOval(200,150,50,50);
     g.drawOval(187,200,75,75);
g.drawOval(175,275,100,100);
g.setColor(Color.black);
g.drawLine(200,150,250,150);
g.fillRect(210,120,30,30);
     }


public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.getContentPane().add(new MainClass());

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(200,200);
    frame.setVisible(true);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote