1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
user100 [1]
3 years ago
9

Write a method that draws a circle and a square that is centered in a DrawingPanel. The method will take in the width and height

(they are the same for both the circle and square) and a Graphics object as parameters
IN java
current code: turn it into a method along with the main method
import java.awt.*;
public class Graphics {
static final int WIDTH = 300;
static final int HEIGHT = 200;
public static void drawGraphics () {
}
public static void main(String []args) {
DrawingPanel2 draw = new DrawingPanel2(WIDTH,HEIGHT); // Make a DrawginPanel2 of size 300 by 200.
Graphics2D g = draw.getGraphics(); // gets graphics from DrawingPanel so you can draw
g.setColor(Color.RED);
g.fillRect(45, 30, 200, 150);
g.setColor(Color.BLUE);
g.fillOval(70, 30, 150, 150);
}
}
Computers and Technology
1 answer:
Katarina [22]3 years ago
3 0

Answer:

public static void drawGraphics (Graphics g, int width, int height) {

   int r = Math.round(width/2);

   int x = 45;

   int y = 30;

     g.setColor(Color.RED);

   g.fillRect(x, y, width, height);

   g.setColor(Color.BLUE);

   g.fillOval(Math.round(x/2), Math.round(y/2), r, r);

}

Explanation:

The Java method "drawGraphics" of the Graphics class accepts draws a square with the "fillRect()" method of the Graphics class object and at its center, a circular path is drawn as well.

You might be interested in
In the classroom settting,listeners can best help reduce speaker presentation anxiety by______
Anuta_ua [19.1K]

speaker ?

notify me if wrong i must know.

3 0
3 years ago
So, I am homeschooled, and I want to watch videos on my school account because I might be waiting for like emails from my teache
Jobisdone [24]

what web browser

if firefox go to addons and see if you can turn off mkaffee or something like that

or go incogneto

plese give me branliest good luck

3 0
3 years ago
Read 2 more answers
Select the correct answer from each drop-down menu. A company is recruiting for a web designer. What kind of candidate should th
prisoha [69]

Answer:a

Explanation:

8 0
3 years ago
Read 2 more answers
Russian newspaper says U.S. journalism is conducting 'experiments' to introduce fast-growing artificial intelligence technology.
Marina86 [1]

Answer:

Russian newspaper says U.S. journalism is conducting 'experiments' to introduce fast-growing artificial intelligence technology.

Explanation:

Artificial intelligence (AI) is a wide-ranging tool that enables people to rethink how we integrate information, analyze data, and use the resulting insights to improve decision making—and already it is transforming every walk of life. In this report, Darrell West and John Allen discuss AI's application across a variety of sectors, address issues in its development, and offer recommendations for getting the most out of AI while still protecting important human values.

4 0
3 years ago
Read 2 more answers
To easily add an organizational chart to a document, users should select .
stepladder [879]

The answer is SmartArt.  One can easily add an organizational Chart to a document by using Smart Art.  It is a graphical tool to easily make an easy visual representation, to make organizational types of artwork such as Organizational Chart,  SmartArt is a tool to turn ordinary text into something more visually appealing, drawing attention to important information or making information easier to interpret and understand.

3 0
3 years ago
Other questions:
  • How does an ip address allow your computer to be reached
    7·1 answer
  • "Write a program that calculates the balance of a savings account at the end of a period of time. It should ask the user for the
    15·1 answer
  • An aircraft departs an airport in the mountain standard time zone at 1615 MST for a 2-hour 15-minute flight to an airport locate
    14·1 answer
  • What is a Joint Staff approved, standardized communications link that is suitable for the transmission of digital information an
    5·1 answer
  • In the Sender Message Channel Receiver (SMCR) model, the ______ is the large, bureaucratic organization that produces messages.
    5·1 answer
  • A restaurant recorded the ages of customers on two separate days. You are going to write a program to find the minimum age of a
    5·2 answers
  • An integer is said to be a perfect number if the sum of its divisors, including 1 (but not the number itself), is equal to the n
    9·1 answer
  • A browser is a program that allow
    11·1 answer
  • The enhanced for loop _____ Group of answer choices reduces the number of iterations necessary to visit all elements of an array
    12·1 answer
  • VI. Differentiate between systems SUIwal unu up
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!