public void init(  ) 
{
SecurityManager securitymanager = System.getSecurityManager();
    	if (securitymanager != null)
	{
      	try{
        		securitymanager.checkSystemClipboardAccess();
        		clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        		if (debug) System.out.println("Using system clipboard");
      	    }
	catch (SecurityException se)
		{
        		clipboard = new Clipboard("SimpleTextEditor");
        		System.out.println("SystemClipboardAccess is denied.");
		System.out.println("SecurityException: " + se.getMessage());
	                if (debug) System.out.println("Using application clipboard");
                                }
    	 }
	else{
      		clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    		if (debug) System.out.println("Using system clipboard");
    	        }
    
	frame = new JFrame("SimpleTextEditor");
    	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    	//button controls
               JMenuBar menuBar = new JMenuBar();
               JMenu fileMenu = new JMenu("File");
               JMenu editMenu = new JMenu("Edit");
               JMenu formatMenu = new JMenu("Format");
               JMenu compileMenu = new JMenu("Compile");
               JMenu helpMenu = new JMenu("Help");
               menuBar.add(fileMenu);
               menuBar.add(editMenu);
               menuBar.add(formatMenu);
               menuBar.add(compileMenu);
              JMenuItem formatFont=new JMenuItem("Font");
              JMenuItem formatColor=new JMenuItem("Color");
        //compile menu item
             JMenuItem compileCompile= new JMenuItem("Compile");
             JMenuItem compileExecute= new JMenuItem("Execute");
	formatMenu.add(formatFont);
	formatMenu.addSeparator();
	formatMenu.add(formatColor);
   //add complie menuitem to compile item
	compileMenu.add(compileCompile);
	compileMenu.addSeparator();
	compileMenu.add(compileExecute);
         //help action
    compileCompile.addActionListener(this);
    compileExecute.addActionListener(this);
    formatColor.addActionListener(this);
    formatFont.addActionListener(this);  
    for (int i=0; i < fileItems.length; i++) {
   JMenuItem item = new JMenuItem(fileItems[i]);
   item.setAccelerator(KeyStroke.getKeyStroke(fileShortcuts[i],Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));
   item.addActionListener(this);
   fileMenu.add(item);
        }
    // Assemble the File menus with keyboard accelerators.
       for (int i=0; i < editItems.length; i++) {
            JMenuItem item = new JMenuItem(editItems[i]);
            item.setAccelerator(KeyStroke.getKeyStroke(editShortcuts[i],Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));
            item.addActionListener(this);
            editMenu.add(item);
        }
        frame.getContentPane().add(menuBar,"North");
	for(int i=0;i<buttonLables.length;++i) 
	{
	icons[i] = new ImageIcon(iconFiles[i]);
	buttons[i] = new JButton(icons[i]);
	buttons[i].setToolTipText(buttonLables[i]);
	buttons[i].addActionListener(this);
	menuBar.add(buttons[i]);
	}
	 //editor
    	editor = new JTextArea(new PlainDocument(),"",60,60); //initializes a JTextArea with width 60& height 30 
    	editor.setFont(editorfont);
         editor.setTabSize(tabsize);
	ta.setEditable(false);
	frame.getContentPane().add(ta,"South");
	JScrollPane scrollpane = new JScrollPane(editor);
    	frame.getContentPane().add(scrollpane,"Center");
    	frame.pack();
    	frame.show();
	addKeyListener(this);
	requestFocus();
 }