import java.awt.*;
import javax.swing.*;

/**
 * A demonstration of a custom Component that supports
 * text drop.
 * 
 * @author  Prof. David Bernstein, James Madison University
 */
public class StringCollageDemo implements Runnable
{
  /**
   * Create and show the GUI.
   * 
   * @param args The command line arguments (which are ignored)
   * @throws Exception if something goes wrong
   */
  public static void main(String[] args) throws Exception
  {
    SwingUtilities.invokeAndWait(new StringCollageDemo());
  }
 
  /**
   * The code to execute in the event dispatch thread.
   */
  public void run()
  {
    JFrame f = new JFrame("TextCollageDemo");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(640, 480);
    
    JPanel cp = (JPanel)f.getContentPane();
    cp.setLayout(new BorderLayout());

    JTextField field = new JTextField();
    field.setBorder(BorderFactory.createTitledBorder("Type text here and then drag it onto the collage"));
    field.setDragEnabled(true);
    cp.add(field, BorderLayout.NORTH);
    
    StringCollage collage = new StringCollage();
    cp.add(collage, BorderLayout.CENTER);
    
    f.setVisible(true);
  }
}
