// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;

public class Paging extends JFrame implements ActionListener {
    private JTextField txt;
    private JButton btn;
    public Paging() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        getContentPane().setLayout(new BorderLayout());
        txt = new JTextField();
        txt.setText("");
        getContentPane().add(txt, BorderLayout.CENTER);
        btn = new JButton("Vis nyt billede");
        btn.addActionListener(this);
        getContentPane().add(btn, BorderLayout.SOUTH);
        this.setSize(300, 300);
    }
    public void load(String s) {
        txt.setText(s);
    }
    public void actionPerformed(ActionEvent ev) {
        if (ev.getSource() == btn) {
            T t = new T(this);
            t.start();
        }
    }
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                Paging f = new Paging();
                f.setVisible(true);
            }
        });
    }
}

class T extends Thread {
    private static int n = 0;
    private Paging pag;
    public T(Paging dn) {
        this.pag = dn;
    }
    public void run() {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                pag.load("Nu viser vi billede af nogle pausefisk");
            }
        });
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
        }
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                n++;
                pag.load("Nu viser vi et rigtigt billede nummer " + n);
            }
        });
    }
} 
