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 should

ID: 3582622 • 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 clocks 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 nameoutput Label JButton submitButton Your code would go here public class ButtonListener implements ActionListener {public void actionPerformed (ActionEvent e) {*//YOUR CODE HERE}}

Explanation / Answer

import java.awt.*;
import java.awt.event.*;
public class button_demo {
   public static void main(String[] args) {
       myframe my=new myframe();

   }

}
class myframe extends Frame{
   Button submitbutton;
   TextField tf;
   myframe(){
       super("button demo");
   SetLayout(new FlowLayout);
   Button submitbutton=new Button("click");
   TextField tf=new TextField(6);
   submitbutton.addActionListener(new clickmelistener());
   add(submitbutton);
   add(tf);
// tf.addActionListener(this);
   setSize(700,200);
   setVisible(true);
   }
   public void paint(Graphics g){
       g.drawString(output,50,100);
   }
}
class clickmelistener implements ActionListener
{
   public void actionperformed(ActionEvent e){
       String input=tf.getText();
   String output=   input.toUpperCase();
   repaint();
   }
}

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