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

Please help me figure out how to complete this code. I am obviously lost in the

ID: 3823497 • Letter: P

Question

Please help me figure out how to complete this code. I am obviously lost in the world of Java. Thank you!

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class JEMail extends JFrame implements ActionListener
{
   //Create 3 labels
    JLabel jlbTo = new JLabel("To:");
    JLabel jlbSub = new JLabel("Subject:");
    JLabel jlbMsg = new JLabel("Message:");
    JTextArea jtaTo = new JTextArea(1, 34);
    JTextArea jtaSub = new JTextArea(1, 31);
    JTextArea jtaMsg = new JTextArea(10, 30);
    //Send button
    JButton jbtnSend = new JButton("Send");
    //Panels
    JPanel panel1 = new JPanel();
    JPanel panel2 = new JPanel();
    JPanel panel3 = new JPanel();
    JPanel panel4 = new JPanel();   
  
    //Constructor
    public JEMail()
    {
       //set
       super("WebBuy Company");
       setLayout(new FlowLayout());
      
       panel1.add(jlbTo);
       panel1.add(jtaTo);
       panel1.setBackground(Color.cyan);
      
       panel2.add(jlbSub);
       panel2.add(jtaSub);
       panel2.setBackground(Color.cyan);
      
       panel3.add(jlbMsg);
       panel3.add(jtaMsg);
       panel3.setBackground(Color.cyan);
      
       panel4.add(jbtnSend);
       panel4.setBackground(Color.cyan);
      
       add(panel1);
       add(panel2);
       add(panel3);
       add(panel4);
      
       jbtnSend.addActionListener(this);
       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
  
    //actionPerformed method
    public void actionPerformed(ActionEvent ae)
    {
       if(jtaTo.getText().length()!=0);
       jtaMsg.append("InMail has been sent!");
    }
  
    public static void main(String[] args)
    {
       //Create object
       JEMail frame = new JEMail();
       frame.setSize(420, 330);
       frame.setVisible(true);
    }
}

Write an application for the WebBuy Company that allows a user to compose the three parts of a complete e-mail message: the "To "Subject and "Message text. The "To:" and "Subject text areas should provide a single line for data entry The "Message area should allow multiple lines of input and be able to scroll if necessary to accommodate a long message. The user clicks a button to send the e-mail message. When the message is complete and the Send button is clicked, the application displays "Mail has been sent! on a new line in the message area. Save the file as JEMail java in the Chapter 13 folder on your Student Disk

Explanation / Answer

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;
import javax.swing.text.DefaultCaret;

public class JEMail extends JFrame implements ActionListener
{
    //Create 3 labels
    JLabel jlbTo = new JLabel("To:");
    JLabel jlbSub = new JLabel("Subject:");
    JLabel jlbMsg = new JLabel("Message:");
    JTextField jtaTo = new JTextField( 30);
    JTextField jtaSub = new JTextField( 30);
    JTextArea jtaMsg = new JTextArea(10, 30);
  
    //Send button
    JButton jbtnSend = new JButton("Send");
    //Panels
    JPanel panel1 = new JPanel();
    JPanel panel2 = new JPanel();
    JPanel panel3 = new JPanel();
    JPanel panel4 = new JPanel();   
    JScrollPane scrolll = new JScrollPane(jtaMsg);
  
    //Constructor
    public JEMail()
    {
        //set
        super("WebBuy Company");
        setLayout(new FlowLayout());
      
        panel1.add(jlbTo);
        panel1.add(jtaTo);
        panel1.setBackground(Color.cyan);
      
        panel2.add(jlbSub);
        panel2.add(jtaSub);
        panel2.setBackground(Color.cyan);
      
        panel3.add(jlbMsg);
        panel3.add(jtaMsg);
        panel3.setBackground(Color.cyan);
      
      
        panel4.add(jbtnSend);
        panel4.setBackground(Color.cyan);
      
        add(panel1);
        add(panel2);
        add(panel3);
        add(panel4);
        //setResizable(false);
        jbtnSend.addActionListener(this);
      
    }
  
    //actionPerformed method
    public void actionPerformed(ActionEvent ae)
    {
        if(jtaTo.getText().length()!=0);
        jtaMsg.append(" InMail has been sent!");
    }
  
    public static void main(String[] args)
    {
        //Create object
        JEMail frame = new JEMail();
        frame.setSize(420, 330);
        frame.setVisible(true);
    }
}

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