import java.lang.reflect.Array;

/**
 * The driver for JMUlti -- a simple multi-file text editor
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class JMUlti
{
  /**
   * The entry point for JMUlti
   *
   * @param args    The command-line arguments
   */
    public static void main(String[] args)
    {
       int           length;
       int           number;
       
       length = Array.getLength(args);
       if (length == 0) number = 1;
       else             number = Integer.parseInt(args[0]);
       
       for (int i=1; i<=number; i++)
       {
          createWindow(i);          
       }
    }
    

  /**
   * Create a TextWindow with a particular number
   *
   * @param index   The window number
   */
    private static void createWindow(int index)
    {
       String             title;       
       TextEditor         editor;
       TextWindow         window;       
       
       title  = String.format("JMUlti -- Window %d", index);       

       editor = new TextEditor();
       editor.setEditable(true);       
       editor.setShouldHaveScrollBar(true);
       editor.setText(title);
       editor.selectAll();       
       
       window = new TextWindow(title);
       window.setTextEditor(editor);       
       window.setShouldConfirmExit(true);       
       window.addFileMenu();
       window.setVisible(true);
    }
}
