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

Write code that would go inside of a handler in a GUI program. The program shoul

ID: 3578556 • Letter: W

Question

Write code that would go inside of a handler in a GUI program. The program should do the following: when the user clicks the submit button, the program should get the text typed into the name field the program should display the name back to the user in all capital letters using the label once the display is updated, the user should not be able to click the button again The program might have more than one button that uses this listener! Use the following variables: JTextField nameInputField JLabel nameOutputLabel JButton submitButton Your code would go here: public class ButtonListener implements ActionListener { public void actionPerformed(ActionEvent e) { // YOUR CODE HERE } } Thank you

Explanation / Answer


class ButtonListener implements ActionListener {
   public void actionPerformed(ActionEvent e) {
       // YOUR CODE HERE
       if(e.getSource() == submitButton ){//when submitButton button clicks
           String name = nameInputField.getText();
           nameOutputLabel.setText(name.toUpperCase());
           submitButton.setEnabled(false);
       }
       else{
             
       }
   }
}

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