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
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