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
Although you can use a dialog box to indent paragraphs, word provides a quicker way through the ____.
pishuonlain [190]
B. Quick access toolbar

3 0
3 years ago
What is tahe difference between a cone and a prism
Natalka [10]

prism is (geometry) a polyhedron with parallel ends of the same size and shape, the other faces being parallelogram-shaped sides while cone is (label) a surface of revolution formed by rotating a segment of a line around another line that intersects the first line.

4 0
2 years ago
What is the function of Google Analytics? web graphics website monitor website statistics programming
Leviafan [203]

Google Analytics monitors websites so it's B. Hope this helps!

8 0
3 years ago
Read 2 more answers
Explain why a holiday on a cruise liner will be an ideal holiday​
liubo4ka [24]

Answer:

The great thing about a cruise holiday is that everyone in your party can please themselves yet still have a real holiday together. The kids can make new friends and take part in fun and educational activities during the day, while the adults unwind by the pool, learn a new skill or hit the casino.

3 0
2 years ago
________________ involves tricking other people into breaking security procedures and sharing sensitive information.
Nuetrik [128]

Answer:

The right answer is social engineering.

Explanation:

social engineering has different meanings in terms of computer security and social studies.

In computer security, social engineering can be defined as the practice to manipulate some people so that they give their personal credentials with the attacker. Their first moto is to gather the information of that user by fraud.

It can be the credential of banking, system access etc.

Hence, the most appropriate answer is social engineering.

5 0
3 years ago
Read 2 more answers
Other questions:
  • After a webcast is completed there are no files left on your computer.
    14·1 answer
  • A new protocol for new information distribution proposed by CERN became the world wide wed in 1991.
    10·1 answer
  • Which item is essential to know before sketching a navigation menu flowchart? template specifics, such as horizontal or vertical
    12·1 answer
  • g 18.6 [Contest 6 - 07/10] Reverse an array Reversing an array is a common task. One approach copies to a second array in revers
    8·1 answer
  • Which of the following is a camera problem that dirt can cause?
    8·2 answers
  • Need the answer for this code hs will give brainly
    7·1 answer
  • 20 points
    5·1 answer
  • The Brinley website will not let me search for questions anymore. It says “Search all you want in-app” and then covers the quest
    14·1 answer
  • 1 #include 2 3 int max2(int x, int y) { 4 int result = y; 5 if (x > y) { 6 result = x; 7 } 8 return result; 9 } 10 11 int max
    12·1 answer
  • All Office programs have similar commands on the tab for changing the document view a. File b. View c. Locate d. display ​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!