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

Implement the Swing application using the GUI you designed in the Phase 1 Discus

ID: 3843015 • Letter: I

Question

Implement the Swing application using the GUI you designed in the Phase 1 Discussion Board. The user will have to enter the following data items:

Sales representative ID

Sales representative First Name

Sales representative Last Name

Total sold for each of three categories: office supplies, books, and paper

Sales district (North, South, East, West).

Preferred means of contact with potential buyers (phone, e-mail, visit)

Include a QUIT button to exit the application and an ENTER button that causes the sales representative’s data to be retrieved from the GUI components and submitted to the application. The sales representative’s data will echo to the jTextArea each time the ENTER button is pressed.

Your application should be thoroughly commented.

Explanation / Answer

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;


public class DiscussionBoard extends JFrame implements ActionListener{
JLabel lb1,lb2,lb3,lb4,lb5,lb6;
JTextField tf1,tf2,tf3,tf4,tf5,tf6,tf7;
JButton bt1,bt2;
JComboBox cb1;
JRadioButton rb1,rb2,rb3;
ButtonGroup bg;
JTextArea ta;
public DiscussionBoard(){
lb1=new JLabel("Sales_ID");
lb2=new JLabel("First Name");
lb3=new JLabel("Last Name");
lb4=new JLabel("Category");
lb5=new JLabel("District");
lb6=new JLabel("Means of contact");
ta=new JTextArea();
tf1=new JTextField();
tf2=new JTextField();
tf3=new JTextField();
tf4=new JTextField();
tf5=new JTextField();
tf6=new JTextField();
tf7=new JTextField();
String str[]={"North","South","East","West"};
cb1=new JComboBox(str);
bg=new ButtonGroup();
rb1=new JRadioButton("Phone",true);
rb2=new JRadioButton("Email");
rb3=new JRadioButton("Visit");
bt1=new JButton("Quit");
bt2=new JButton("Enter");
bt1.addActionListener(this);
bt2.addActionListener(this);
bg.add(rb1);
bg.add(rb2);
bg.add(rb3);
setLayout(null);
lb1.setBounds(50,50,100,20);
lb2.setBounds(50,80,100,20);
lb3.setBounds(50,110,100,20);
lb4.setBounds(50,140,100,20);
lb5.setBounds(50,170,100,20);
lb6.setBounds(50,200,100,20);
tf1.setBounds(200,50,100,20);
tf2.setBounds(200,80,100,20);
tf3.setBounds(200,110,100,20);
tf4.setBounds(200,140,70,20);
tf5.setBounds(270,140,70,20);
tf6.setBounds(340,140,70,20);
cb1.setBounds(200,170,100,20);
rb1.setBounds(200,200,70,20);
rb2.setBounds(270,200,70,20);
rb3.setBounds(340,200,70,20);
tf7.setBounds(200,230,200,20);
bt1.setBounds(100,300,100,20);
bt2.setBounds(250,300,100,20);
ta.setBounds(450,50,200,300);

add(lb1);
add(lb2);
add(lb3);
add(lb4);
add(lb5);
add(lb6);
add(tf1);
add(tf2);
add(tf3);
add(tf4);
add(tf5);
add(tf6);
add(tf7);
add(cb1);
add(rb1);
add(rb2);
add(rb3);
add(bt1);
add(bt2);
add(ta);
  
}
public static void main(String args[]){
DiscussionBoard db=new DiscussionBoard();
db.setSize(900,500);
db.setVisible(true);
}

@Override
public void actionPerformed(ActionEvent e) {
String str=e.getActionCommand();
if(str.equals("Quit")){
System.exit(0);
} else{
ta.setText("ID ="+tf1.getText()+" Name is= "+tf2.getText()+" "+tf3.getText()+" Total Supply is= Office "+tf4.getText()+" Books "+tf5.getText()+" Paper "+tf6.getText()+" District is= "+cb1.getSelectedItem()+" Contact is= "+tf7.getText());
}
}
}