Question
Final Product: Description 1. Create a Smiley class a. The class needs to extend JPanel b. The constructor for this class should have 4 parameters.
Final Product:
Description
1.
Create a Smiley
class
a.
The class needs to extend JPanel
b.
The constructor for this
class should have 4 parameters. Each parameter should
be a color. One for the outline, one for the skin, one for the smile and one for
the eyes.
c.
Use the paintComponent method to draw the sm
iley using the colors from the
constructor
i.
The smiley must be drawn
2.
Create a SmileyGrid class
a.
This class needs to extend JFrame
b.
Use
a GridLayout to divide the frame into a 3 by 3 grid
c.
Use a loop to create an instance of the Smiley class for each square in
the grid,
using random colors for each instance
Code so far:
Grid Code:
import java.awt.*; import java.awt.event.*; import javax.swing.*;
/** * Displays a grid of Smiley objects * * @author
public SmileyGrid() {
}
private void createGUI() { setDefaultCloseOperation(EXIT_ON_CLOSE);
} public void actionPerformed(ActionEvent ae) {
} }
Smiley Code:
import java.awt.*; import javax.swing.*;
/** * Draws a single smiley face * * @author
} // Use this method to draw the smiley face on the panel public void paintComponent(Graphics g) { super.paintComponent(g); } }
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