import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

        // Display a Message Dialog when a button is pressed.
        // The `message' argument is an array rather than a single string.
class SwingOptionFrame2 extends JFrame {
    public SwingOptionFrame2() {
        final int width = 300, height = 100;
        setSize(width,height);
        final Container contents = getContentPane();
        // Each String will be displayed in a column.
        final String[] messages = {
            "Don't go out without an umbrella.",
            "Use plenty of sun block on hot days.",
            "Always take an extra pair of socks when you go on holiday.",
        };

        // A button to trigger the message.
        JButton advice = new JButton("Advice");
        advice.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                JOptionPane.showMessageDialog(
                        contents,
                        messages,
                        "Helpful Advice",
                        JOptionPane.INFORMATION_MESSAGE);
            }
        });

        // A panel to hold the buttons in the frame.
        JPanel panel = new JPanel();
        panel.add(advice);
        panel.add(new QuitJButton());
        contents.add(panel,"South");
    }
}
