Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Java program that meets the following requirements: Write an application

ID: 3770960 • Letter: W

Question

Write a Java program that meets the following requirements:

Write an application that extends JFrame and that displays a yellow smiling face on the screen. Save the file as JSmileFace.java.

b. Add a JButton to the JSmileFace program so the smile changes to a frown when the user clicks the JButton.

Purpose: Create a java program from detailed directions.

Ability to: Follow established programming conventions for writing java programs

Use inheritance

Use the JFrame class

Use a Button with an Event

Use an IF statement Create and use a Graphic object

Explanation / Answer

Can help you with a) bit


import javax.swing.*;
import java.awt.*;
public class JSmileFace
{
public static void main(String[] args)
{
JSmileFace j = new JSmileFace();
}
public JSmileFace()
{
JFrame frame = new JFrame("JSmileFace");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new MyComponent());
frame.setSize(400,400);
frame.setVisible(true);
}
public class MyComponent extends JComponent
{
public void paint(Graphics g)
{
g.setColor(Color.yellow);
g.drawOval(100, 50, 200, 200);
g.setColor(Color.yellow);
g.fillOval(100,50,200,200);
g.setColor(Color.BLACK);
g.fillOval(155, 100, 10, 20);
g.fillOval(230, 100, 10, 20);
g.setColor(Color.BLACK);
g.drawArc(150, 160, 100, 50, 180, 180);
}}
}
public static void main(String[] args)
{
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote