// 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.Color;
import java.awt.Dimension;

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

public class BackGroundColor extends JFrame {
    private static final long serialVersionUID = 1L;
    private JButton btn;
    public BackGroundColor() {
        setTitle("Background color example");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setPreferredSize(new Dimension(400, 400));
        getContentPane().setLayout(new BorderLayout());
        getContentPane().setBackground(Color.BLUE);
        btn = new JButton("Do not click here");
        btn.addActionListener(evt -> JOptionPane.showMessageDialog(BackGroundColor.this, "You should not have clicked here!"));
        getContentPane().add(btn, BorderLayout.SOUTH);
        pack();
    }
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JFrame f = new BackGroundColor();
                f.setVisible(true);
            }
        });
    }
}
