import java.awt.FlowLayout; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.swing.JFrame; import javax.swing.JButton; import javax.swing.JTextField; class Program extends JFrame { JButton kilepesgomb; JButton duplazasgomb; JTextField szammezo; Program() { kilepesgomb = new JButton("Kilépés"); duplazasgomb = new JButton("Dupláz"); szammezo = new JTextField(); kilepesgomb.addActionListener(new KilepesGomb_Click()); duplazasgomb.addActionListener(new DuplazoGomb_Click()); szammezo.setColumns(7); add(kilepesgomb); add(duplazasgomb); add(szammezo); setLayout(new FlowLayout()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); setVisible(true); } class KilepesGomb_Click implements ActionListener { public void actionPerformed(ActionEvent e) { System.exit(0); } } class DuplazoGomb_Click implements ActionListener { public void actionPerformed(ActionEvent e) { String szamstr = szammezo.getText(); int szam = Integer.parseInt(szamstr); int eredmeny = szam * 2; szammezo.setText(Integer.toString(eredmeny)); } } public static void main(String args[]) { new Program(); } }