import javax.swing.*;
import java.awt.*;
import java.awt.Color;
public class JDemo3DRectangles extends JPanel
{
@Override
public void paint(Graphics gr)
{
super.paint(gr);
final int WIDTH = 60, HEIGHT = 80;
gr.setColor(Color.PINK);
gr.fill3DRect(20, 40, WIDTH, HEIGHT, true);
gr.fill3DRect(100, 40, WIDTH, HEIGHT, false);
}
public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.add(new JDemo3DRectangles());;
frame.setSize(200, 180);
frame.setVisible(true);
}
}
The highlighted code above creates two filled 3D rectangles. Describe how the color of the rectangles is set, and explain the five arguments that are used to draw the rectangles.
Correct Answer:
Verified
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q56: A Polygon object is created by defining
Q57: Write the statement that will create a
Q58: Why would a programmer use the repaint()
Q59: What are the three arguments the BasicStroke
Q60: What are the constructors for the Dimension
Q61: The getFontMetrics() method can be used to
Q62: Write the statement to create a Rectangle2D.Float
Q63: Write the setPaint() statement that will set
Q65: A rectangle is drawn with the following
Q66: Write the statement to instruct a Graphics
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents