Question: Below is class called house. I need help making a new class house2 that in a 2x2 gridlayout and extend Jframe. In house2 class, I

Below is class called house. I need help making a new class house2 that in a 2x2 gridlayout and extend Jframe. In house2 class, I need a loop that make an instance of the house class in each row and column in grid. The loop need to be in house2 class.

house class:

import java.awt.*; import javax.swing.JFrame; import javax.swing.JPanel;

class house extends JPanel { private Color rectangle; private Color triangle;

public house(Color rect, Color tri) { rectangle = rect; triangle = tri; } public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(rectangle); g.drawRect(50, 100, 200, 100); g.setColor(triangle); g.drawPolygon(new int[] {50, 150, 250}, new int[] {100, 20, 100}, 3); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!