
Draw the given picture
- Import the required packages.
- Create the class “Micky”,
- Define the “main()” method,
- Construct the “DrawingPanel” object.
- Set the background for the panel.
- Create “Graphics” object and call the method “getGrphics()”.
- Set the color as “BLUE”.
- Fill the oval shapes for the given range with color “BLUE”.
- Set the color as “RED”.
- Fill the rectangle shape for the specified range with color “RED”.
- Set the color as “BLACK”.
- Draw the line with color “BLACK”.
- Define the “main()” method,

This program is to use the “DrawingPanel” to draw the given picture.
Explanation of Solution
Program:
File name: “Micky.java”
//Import necessary packages
import java.awt.Color;
import java.awt.Graphics;
//Create a class
public class Micky
{
//Define the main() method
public static void main(String[] args)
{
//Create DrawingPanel object
DrawingPanel p = new DrawingPanel(220, 150);
//Set the background
p.setBackground(Color.YELLOW);
//Create Graphics object
Graphics g1 = p.getGraphics();
//Set the color as "BLUE"
g1.setColor(Color.BLUE);
//Fill the oval shape in a range with that color
g1.fillOval(50, 25, 40, 40);
g1.fillOval(130, 25, 40, 40);
//Set the color as "RED"
g1.setColor(Color.RED);
//Fill the rectangle shape with the given range as "RED"
g1.fillRect(70, 45, 80, 80);
//Set the color as "BLACK"
g1.setColor(Color.BLACK);
//Draw the line with "BLACK" color
g1.drawLine(70, 85, 150, 85);
}
}
Screenshot of output:
Want to see more full solutions like this?
Chapter 3G Solutions
Building Java Programs: A Back To Basics Approach (5th Edition)
- I need to make a parallel version of this sequential code.arrow_forwardBenefits of using arrays as instance variables: What are the advantages of incorporating arrays as instance variables within a class? Initializing and managing arrays: How do you initialize and manage arrays within class constructors and mutators (setters)? Example of using arrays as instance variables: Share an example where you have used arrays as instance variables and discuss its application in a real-world scenario. Common mistakes with arrays as instance variables: What are some common mistakes to avoid when working with arrays as instance variables? Information hiding violations: What is the potential violation of information hiding when using arrays as instance variables? How can this be resolved?arrow_forwardDo you think that computers should replace teachers? Give three references with your answer.arrow_forward
- Is online learning or face to face learning better to teach students around the around the world? Give reasons for your answer and provide two references with your response. What are benefits of both online learning and face to face learning ? Give two references with your answer. How does online learning and face to face learning affects students around the world? Give two references with your answer.arrow_forwardExplain Five reasons if computers should replace teachers. Provide three references with your answer. List three advantages and three disadvantages face to face learning and online learning may have on children. Provide two references with your answer.arrow_forwardYou were requested to design IP addresses for the following network using the address block 10.10.10.0/24. Specify an address and net mask for each network and router interfacearrow_forward
- For the following network, propose routing tables in each of the routers R1 to R5arrow_forwardFor the following network, propose routing tables in each of the routers R1 to R5arrow_forwardUsing R language. Here is the information link. http://www.cnachtsheim-text.csom.umn.edu/Kutner/Chapter%20%206%20Data%20Sets/CH06PR18.txtarrow_forward
- Using R languagearrow_forwardHow can I type the Java OOP code by using JOptionPane with this following code below: public static void sellCruiseTicket(Cruise[] allCruises) { //Type the code here }arrow_forwardDraw a system/level-0 diagram for this scenario: You are developing a new customer relationship management system for the BEC store, which rents out movies to customers. Customers will provide comments on new products, and request rental extensions and new products, each of which will be stored into the system and used by the manager for purchasing movies, extra copies, etc. Each month, one employee of BEC will select their favorite movie pick of that week, which will be stored in the system. The actual inventory information will be stored in the Entertainment Tracker system, and would be retrieved by this new system as and when necessary. Example of what a level-0 diagram looks like is attached.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





