Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider the code snippet below: public class RectangleComponent extends JComponent { private static final int RECTANGLE_WIDTH = 20; private static final int RECTANGLE_HEIGHT = 30;
Consider the code snippet below:
public class RectangleComponent extends JComponent { private static final int RECTANGLE_WIDTH = 20; private static final int RECTANGLE_HEIGHT = 30; private int xLeft; private int yTop; public RectangleComponent() { xLeft = 0; yTop = 0; } public void paintComponent(Graphics g) { g.fillRect(xLeft, yTop, RECTANGLE_WIDTH, RECTANGLE_HEIGHT); } public void moveRectangleBy(int dx, int dy) { xLeft = xLeft + dx; yTop = yTop + dy; getGraphics().setColor(Color.green); repaint(); } }
Which color will be used to fill a rectangle in paintComponent?
green |
the system's default color |
white |
it is impossible to specify |
Flag this Question
Question 2 0.1 pts
If you need force the screen to be updated, you should call the method ____.
draw |
update |
paintComponent |
repaint |
Flag this Question
Question 3 0.1 pts
Complete the following statement to construct a rectangle.
Graphics g; g.____________________ (x, y, width, height);
drawRect |
drawOval |
fillCircle |
DrawOval |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started