import java.awt.*;
import java.util.*;
import javax.swing.*;

/**
 * An application that demonstrates DnD for a custom object.
 * 
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class AppointmentPanelDemo implements Runnable
{
  /**
   * The entry point.
   * 
   * @param args The command line arguments (which are ignored)
   */
  public static void main(String[] args) throws Exception
  {
    SwingUtilities.invokeAndWait(new AppointmentPanelDemo());
  }
  
  /**
   * The code to execute in the event dispatch thread.
   */
  public void run()
  {
    String[] rooms = {"CS236", "CS243", "CS246", "CS248", "CS250"};
    
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    f.setSize(640, 480);
    JPanel cp = (JPanel)f.getContentPane();
    cp.setLayout(new GridLayout(1,2));
    
    JPanel left = new JPanel();
    left.setLayout(new GridLayout(3,1));
    {
      AppointmentPanel ap = new AppointmentPanel();
      ap.setAppointment(new Appointment(new Date(), "Database Demo"));
      left.add(ap);
      
      ap = new AppointmentPanel();
      ap.setAppointment(new Appointment(new Date(), "Graphics Demo"));
      left.add(ap);
      
      ap = new AppointmentPanel();
      ap.setAppointment(new Appointment(new Date(), "Robotics Demo"));
      left.add(ap);
    }
    cp.add(left);
    
    JPanel right = new JPanel();
    right.setLayout(new GridLayout(rooms.length, 2));
    {
      for (int i=0; i<rooms.length; i++)
      {
        AppointmentPanel ap = new AppointmentPanel(rooms[i]);
        right.add(ap);
      }
    }
    cp.add(right);
    
    f.setVisible(true);
  }
}
