Answer:
Kindly note that, you're to replace "at" with shift 2 as the brainly text editor can't take the symbol
Explanation:
import java.awt.event.*;
import java.awt.geom.Area;
import javax.swing.*;
class MVCTester implements ActionListener{
JButton b; //button
JTextField t1; //textfiled
JTextArea area; //text area
MVCTester(){
JFrame f=new JFrame("Button Example");
//button
b=new JButton("add");
b.setBounds(0,0,125,27);
f.add(b);
b.addActionListener(this);
//textfiled
t1=new JTextField();
t1.setBounds(0,161,125,24);
f.add(t1);
//textarea
area=new JTextArea();
area.setBounds(0,28,123,130);
f.add(area);
area.setColumns (17);
area.setLineWrap (true);
area.setWrapStyleWord (false);
f.setSize(125,225);
f.setLayout(null);
f.setVisible(true);
}
"at"Override
public void actionPerformed(ActionEvent arg0) {
Control c=new Control(area,t1,b);
}
}
class Control {
Control(JTextArea area,JTextField t1,JButton b){
//simple logic getting text of text area adding text of textfiled and setting the text to text area
area.setText(area.getText()+t1.getText()+"\n");
t1.setText("");
}
}
public class Modal{
public static void main(String[] args) {
MVCTester be=new MVCTester();
}
}