package lt.bit.langas; import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class MygtukasPaspaustas implements ActionListener { private JTextField x; private JTextField y; private JLabel ats; public MygtukasPaspaustas(JTextField x, JTextField y, JLabel ats) { this.x = x; this.y = y; this.ats = ats; } public void actionPerformed(ActionEvent e){ int ix = Integer.parseInt(x.getText()); int iy = Integer.parseInt(y.getText()); ats.setText( "Atsakymas: "+(ix+iy) ); System.out.println("Mygtukas buvo paspaustas: "+this.x.getText()); } }