import java.awt.EventQueue; 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 Program01 extends JFrame { JButton varGomb = new JButton("Vár"); JButton valtGomb = new JButton("Vált"); JTextField mezo = new JTextField(4); public Program01() { varGomb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { varGombActionListener(arg0); } }); valtGomb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { mezo.setText("Valami"); } }); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setLayout(new FlowLayout()); this.add(varGomb); this.add(valtGomb); this.add(mezo); this.pack(); this.setVisible(true); } private void varGombActionListener(ActionEvent e) { (new Thread() { public void run() { try { Thread.sleep(5000); setWindowTitle(); } catch (InterruptedException e) { System.err.println("Megszakítási hiba!"); } } }).start(); } private void setWindowTitle() { this.setTitle("Működik"); } public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { new Program01(); } }); } }