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

pls help Write a program called DayGui.java that creates a GUI having the follow

ID: 3547079 • Letter: P

Question

pls help

Write a program called DayGui.java that creates a GUI having the following properties

Object

Property

Setting

JFrame

Name
Caption
Layout

JButton

Name
Caption
Mnemonic

JButton

Name
Caption
Mnemonic

Add individual event handlers to your program so that when a user clicks the Good button, the message "Today is a good day!" appears in a dialog box, and when the Bad button is clicked, the message "I'm having a bad day today!" is displayed. The following tutorial shows you much of the code solution. Feel free to use the tutorial, but make changes so that you are not simply copying the tutorial code for your entire solution. To make this different from the tutorial, change the colors of the buttons and panel. Also, add this application to a tabbed pane along with the program you will complete in the next step, Step 3. The following tutorials will likely be useful as you work to complete this step:

Grading Rubric

DayGui

Points

Description

Standard header included

1

Object

Property

Setting

JFrame

Name
Caption
Layout

mainFrame
Messages
FlowLayout

JButton

Name
Caption
Mnemonic

cmdGood
Good
G

JButton

Name
Caption
Mnemonic

cmdBad
Bad
B

Explanation / Answer

import javax.swing.*;

import java.awt.event.*;

import java.awt.Container;

import java.awt.*;


public class DayGui extends JFrame implements ActionListener {


private JFrame mainframe;

private JButton cmdgood;

private JButton cmdbad;


public void actionPerformed(ActionEvent e) {

if (e.getSource() == cmdgood)

JOptionPane.showMessageDialog(null, "Today is a good day!",

"Event Handler Message", JOptionPane.INFORMATION_MESSAGE);

else if (e.getSource() == cmdbad)

JOptionPane.showMessageDialog(null, "I'm having a bad day!",

"Event Handler Message", JOptionPane.INFORMATION_MESSAGE);

}


public DayGui() {

mainframe = new JFrame("Messages");

cmdgood = new JButton("good");

cmdbad = new JButton("bad");

Container container = mainframe.getContentPane();

container.setLayout(new FlowLayout());

container.add(cmdgood);

container.add(cmdbad);

cmdgood.setMnemonic('G');

cmdbad.setMnemonic('B');

mainframe.setSize(300, 100);

mainframe.addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent e) {

System.exit(0);

}

});

cmdgood.addActionListener(this);

cmdbad.addActionListener(this);

mainframe.setVisible(true);


}


public static void main(String[] args) {

DayGui dayGui = new DayGui();

}

}