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

Design an event handler that will execute when the showNameButton component is c

ID: 3615773 • Letter: D

Question

Design an event handler that will execute when theshowNameButton component is clicked. The eventhandler should perform the following: -store the first name in a label component namedfirstNameLabel -store the middle name in a label component namedmiddleNameLabel -store your last name in a label component namedlastNameLabel (remember to store a value in a label component, you muststore the value in the components text property) Design an event handler that will execute when theshowNameButton component is clicked. The eventhandler should perform the following: -store the first name in a label component namedfirstNameLabel -store the middle name in a label component namedmiddleNameLabel -store your last name in a label component namedlastNameLabel (remember to store a value in a label component, you muststore the value in the components text property) (remember to store a value in a label component, you muststore the value in the components text property)

Explanation / Answer

please rate - thanks hope Java is good I started it before you answered my message import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.lang.*; public class shownameGUI extends JFrame {private JLabel firstNameLabel,middleNameLabel,lastNameLabel; private JTextField firstf,middlef,lastf; private JButton showB; private Container pane; private showButtonHandler sbHandler; private static final int WIDTH= 325; private static final int HEIGHT=250; public shownameGUI() {firstNameLabel=new JLabel("first name",SwingConstants.RIGHT); middleNameLabel=new JLabel("middle name",SwingConstants.RIGHT); lastNameLabel=new JLabel("last name",SwingConstants.RIGHT); firstf=new JTextField(15); middlef=new JTextField(15); lastf=new JTextField(15); showB=new JButton("show name"); sbHandler=new showButtonHandler(); showB.addActionListener(sbHandler); setTitle("Name Displayer"); pane=getContentPane(); pane.setLayout(new GridLayout(4,2)); pane.add(firstNameLabel); pane.add(firstf); pane.add(middleNameLabel); pane.add(middlef); pane.add(lastNameLabel); pane.add(lastf); pane.add(showB); firstf.setEditable(false); middlef.setEditable(false); lastf.setEditable(false); setSize(WIDTH,HEIGHT); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); } private class showButtonHandler implements ActionListener {public void actionPerformed(ActionEvent e) {String first="first name goes here"; String middle="middle name goes here"; String last="last name goes here"; firstf.setText(first); middlef.setText(middle); lastf.setText(last); } } public static void main(String[] args) { shownameGUI cd = new shownameGUI(); } }

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