import java.awt.Frame; import java.awt.Button; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; class Program extends Frame implements ActionListener { Button gomb1; Button gomb2; Program() { gomb1 = new Button("Nyomj meg"); gomb2 = new Button("Vagy nyomd ezt"); gomb1.setBounds(50, 50, 100, 30); gomb2.setBounds(50, 90, 100, 30); gomb1.addActionListener(this); gomb2.addActionListener(this); add(gomb1); add(gomb2); setLayout(null); setSize(400, 300); setVisible(true); } public void actionPerformed(ActionEvent e) { if(e.getSource() == gomb1) setTitle("Első gomblt"); if(e.getSource() == gomb2) setTitle("Második gombon"); } public static void main(String args[]) { new Program(); } }