import javax.swing.*;
import java.awt.*;
import java.awt.Color;
public class JDemoRectangles extends JFrame
{
Container con = getContentPane();
public JDemoRectangles()
{
con.setBackground(Color.BLUE);
con.setLayout(new FlowLayout());
}
public void paint(Graphics gr)
{
super.paint(gr);
gr.setColor(Color.RED);
gr.fillRect(40, 40, 120, 120);
gr.setColor(Color.YELLOW);
gr.fillRect(80, 80, 160, 160);
gr.clearRect(50, 60, 50, 50);
}
public static void main(String[] args)
{
JDemoRectangles frame = new JDemoRectangles();
frame.setSize(200, 200);
frame.setVisible(true);
}
}
Using the above code, describe what objects are drawn using the shaded statements of the paint() method.
Correct Answer:
Verified
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q44: Write the statement to create an Arc2D.Float
Q47: BasicStroke myLine = new BasicStroke(12.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND);
Q52: The draw3DRect() method is used to draw
Q54: In the drawPolygon() method, what are the
Q56: A Polygon object is created by defining
Q61: The getFontMetrics() method can be used to
Q65: A rectangle is drawn with the following
Q66: Write the statement to instruct a Graphics
Q68: import javax.swing.*;
import java.awt.*;
public class JDemoFont extends JFrame
{
Font
Q70: Write the statement to position a JLabel
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