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;
        String             title;       
        TextEditor         editor;
        TextWindow         window;       

        length = Array.getLength(args);
        if (length == 0)
        {
            number = 1;
        }
        else
        {
            number = Integer.parseInt(args[0]);
        }
        
        for (int i=0; i<number; i++)
        {
            title  = String.format("JMUlti -- Window %d", i);
            
            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);
        }
    }
    
}
