import javax.swing.JFrame; import javax.swing.JButton; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; class Program extends JFrame implements ActionListener { JButton kilepesgomb; JButton valtoztatgomb; JButton visszagomb; Program() { kilepesgomb = new JButton("Kilépés"); valtoztatgomb = new JButton("Változtat"); visszagomb = new JButton("Vissza"); kilepesgomb.setBounds(10, 100, 100, 30); kilepesgomb.addActionListener(this); valtoztatgomb.setBounds(120, 100, 100, 30); valtoztatgomb.addActionListener(this); visszagomb.setBounds(230, 100, 100, 30); visszagomb.addActionListener(this); setLayout(null); add(kilepesgomb); add(valtoztatgomb); add(visszagomb); setSize(400, 300); setVisible(true); } public void actionPerformed(ActionEvent e) { if(e.getSource() == kilepesgomb) System.exit(0); if(e.getSource() == valtoztatgomb) setTitle("Működik"); if(e.getSource() == visszagomb) setTitle("Másik"); } public static void main(String args[]) { new Program(); } }