package app;

import java.util.*;
import javax.swing.*;

/**
 * A simple example of a MultimediaApp
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class   RandomMessageApp
       extends AbstractMultimediaApp
{
    // Attributes
    private JLabel                label;       

    // The pseudo-random number generator
    private static Random         rng = new Random();    

    // The messages
    private static final String[] MESSAGES = 
    {
       "What a great example!",
       "This class is great.",
       "I can't wait to do the programming assignments.",
       "I wish lectures lasted for 5 hours.",
       "I've never had a better Professor."
    };

    

    /**
     * "Create" a message at random
     *
     * @return   The message
     */
    private static String createRandomMessage()
    {
       return  MESSAGES[rng.nextInt(MESSAGES.length)];
    }


    /**
     * Called to indicate that this MultimediaApp has been loaded
     */
    public void init()
    {
       JPanel                    contentPane;
       String                    s;
       
       // Select a message at random
       s = createRandomMessage();

       // Get the container for all content
       contentPane = (JPanel)rootPaneContainer.getContentPane();
       contentPane.setLayout(null);     
  

       // Add a component to the container
       label = new JLabel(s, SwingConstants.CENTER);
       label.setBounds(50,50,500,100);       
       contentPane.add(label);    
    }
}
