import java.util.*;
import javax.swing.*;

import app.JApplication;



public class      BadRandomMessageJApplication
       extends    JApplication
{
    // 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."
    };


    /**
     * The entry point of the application
     *
     * @param args   The command-line arguments
     */
    public static void main(String[] args) throws Exception
    {
       SwingUtilities.invokeAndWait(
          new BadRandomMessageJApplication(600,400));
    }
    

    /**
     * Explicit Value Constructor
     */
    public BadRandomMessageJApplication(int width, int height)
    {
       super(width, height);       
    }
    

    /**
     * "Create" a message at random
     *
     * @return   The message
     */
    private static String createRandomMessage()
    {
       return  MESSAGES[rng.nextInt(MESSAGES.length)];
    }
    
    
    /**
     * Called to indicate that this JApplication 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)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);    
    }
}
