Код
package listener;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class Listener{
JFrame okno;
JTextField pole1;
JTextField pole2;
JButton ok ;
public Listener (){
okno = new JFrame();
pole1 = new JTextField(12);
pole2 = new JTextField(12);
ok = new JButton("ok");
ok.addActionListener(new okAL());
okno.add(pole1);
okno.add(pole2);
okno.add(ok);
okno.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
okno.setLayout(new FlowLayout());
okno.setVisible(true);
okno.pack();
}
public static void main(String[] args) {
new Listener();
}
public class okAL implements ActionListener {
@Override
public void actionPerformed(ActionEvent event){
String text1 = pole1.getText();
pole2.setText(text1);
}
}
}//end_class