public Notepad()
	{
           	super("Secure Note");//name/heading on the window
        	try//exception handling for the user interface look and feel option
        	{
                javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
        	}
        	catch(Exception ex)
        	{
                    ex.printStackTrace();
                }
        	Container c = getContentPane();//container to add components
                

        	t.setFont(new Font("Verdana",Font.PLAIN, 12));//default font
		t.addMouseListener(new java.awt.event.MouseAdapter()
		{
    			public void mouseClicked(java.awt.event.MouseEvent evt)
				{
					if (evt.getModifiers()==4)
					{
      				final JPopupMenu jp = new JPopupMenu();
						JButton c=new JButton("cut");
						JButton cc=new JButton("copy");
						JButton p=new JButton("paste");
						JButton d=new JButton("delete");
						JButton u=new JButton("UPPERCASE");
	 	  				JButton l=new JButton("lowercase");
						JButton tt=new JButton("tts");
						JButton re=new JButton("retrieve");

						re.addActionListener(new ActionListener()
						{
							public void actionPerformed(ActionEvent e)
							{
								try
								{
									connect(t.getSelectedText());
									jp.setVisible(false);
								}
								catch(Exception ex){}
							}
						});

						c.addActionListener(new ActionListener()
						{
							public void actionPerformed(ActionEvent e)
							{
								edit_cut();
								jp.setVisible(false);
							}
						});
						cc.addActionListener(new ActionListener()
						{
							public void actionPerformed(ActionEvent e)
							{
								edit_copy();
								jp.setVisible(false);
							}
						});
						p.addActionListener(new ActionListener()
						{
							public void actionPerformed(ActionEvent e)
							{
								edit_paste();
								jp.setVisible(false);
							}
						});
						d.addActionListener(new ActionListener()
						{
							public void actionPerformed(ActionEvent e)
							{
								edit_delete();
								jp.setVisible(false);
							}
						});
						u.addActionListener(new ActionListener()
						{
							public void actionPerformed(ActionEvent e)
							{
								str2uppr();
								jp.setVisible(false);
							}
						});

						l.addActionListener(new ActionListener()
						{
							public void actionPerformed(ActionEvent e)
							{
								str2lwr();
								jp.setVisible(false);
							}
						});
						tt.addActionListener(new ActionListener()
						{

            			public void actionPerformed(ActionEvent e)
            			{
                			jp.setVisible(false);
								talk();
    	 			       }
       				});
						c.setContentAreaFilled(false);
						cc.setContentAreaFilled(false);
						p.setContentAreaFilled(false);
						d.setContentAreaFilled(false);
						u.setContentAreaFilled(false);
						l.setContentAreaFilled(false);
						tt.setContentAreaFilled(false);
						re.setContentAreaFilled(false);

						jp.add(c);
						jp.add(cc);
						jp.add(p);
						jp.add(d);
						jp.add(u);
						jp.add(l);
						jp.add(re);
						jp.add(tt);

						jp.show((Component)evt.getSource(), evt.getX(), evt.getY());

					}
    			}
			});

		  	//adding scrollbar to text area;
    	   sc = new JScrollPane(t, sc.VERTICAL_SCROLLBAR_AS_NEEDED, sc.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        	c.add(sc);//add components to container
        	menubar = new JMenuBar();//instance of java menu bar

                //---------AutoSave part----------
                Timer timer = new Timer("AutoSave");
		AutoSave as = new AutoSave(t,content);
                timer.schedule(as, 0, 100);

                 //---------------------------------

			text=new JTextField(20);
			text.setBounds(140,40,140,20);

			text.setText("Enter Website name");
			text.setForeground(Color.gray);
			KeyListener keyListener = new KeyListener()
			{
      		public void keyPressed(KeyEvent e)
				{
      			if (e.getKeyCode()==KeyEvent.VK_ENTER)
					{
						try
						{
							String s = text.getText().trim();
							connect(s);
						}
						catch(Exception ae){}
					}
  	    		}
				public void keyReleased(KeyEvent keyEvent)
				{
       			
      		}

      		public void keyTyped(KeyEvent keyEvent)
				{
        			
      		}
			};

			text.addKeyListener(keyListener);
			text.addFocusListener(new FocusListener()
			{
				int i=0;
      		public void focusGained(FocusEvent e)
				{
					if(i==0)
					{
       				text.setText("");
		 				text.setForeground(Color.black);
						i=1;
					}
					else
					{}
      		}

      		public void focusLost(FocusEvent e)
				{
     				// text.setText("Enter Website name");
					//text.setForeground(Color.gray);
      		}
  			});

			b1=new JButton("Retrieve");
			b1.addActionListener(this);


        	file = new JMenu("File");//instance of file menu
        	file_new = new JMenuItem("New");//instance of component-new in the file menu
        	//trigger action through keystrokes
        	file_new.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK));
        	file_new.addActionListener(this);//to male the item listen
        	file.add(file_new);//add it to the file menu
        	file_open = new JMenuItem("Open");//instance of component-open in the file menu
        	file_open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));
        	file_open.addActionListener(this);
        	file.add(file_open);
        	file_sep1 = new JSeparator();//instance of component-a separator in the file menu
        	file.add(file_sep1);
        	file_save = new JMenuItem("Save");//instance of component-save in the file menu
        	file_save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));
        	file_save.addActionListener(this);
        	file.add(file_save);
        	file_save_as = new JMenuItem("Save As");//instance of component-save_as in the file menu
        	file_save_as.addActionListener(this);
        	file.add(file_save_as);
                file_save_as_Image = new JMenuItem("Save As Image");//instance of component-save_as in the file menu
                file_save_as_Image.addActionListener(this);
                file.add(file_save_as_Image);
        	file_sep2 = new JSeparator();//instance of component-a separator in the file menu
        	file.add(file_sep2);
        	file_print = new JMenuItem("Print");//instance of component-print in the file menu
        	file_print.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_MASK));
        	file_print.addActionListener(this);
        	file.add(file_print);
       	file_print_preview = new JMenuItem("Print Preview");
       	file_print_preview.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.CTRL_MASK));
        	file_print_preview.addActionListener(this);
        	file.add(file_print_preview);
		  	file_sep3 = new JSeparator();
        	file.add(file_sep3);
		  	file_auto = new JMenuItem("Auto");//instance of component-save_as in the file menu
        	file_auto.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK));

		  	file_auto.addActionListener(this);
		  	file.add(file_auto);
    	   file_close = new JMenuItem("Close");//instance of component-close in the file menu
        	file_close.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.CTRL_MASK));
        	file_close.addActionListener(this);
        	file.add(file_close);
        	file_exit = new JMenuItem("Exit");//instance of component-exit in the file menu
        	file_exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK));
        	file_exit.addActionListener(this);
        	file.add(file_exit);
        	menubar.add(file);//add file menu to the menu bar



        	edit = new JMenu("Edit");
        	edit_undo = new JMenuItem("Undo");
        	edit_undo.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK));
        	edit_undo.addActionListener(this);
        	edit.add(edit_undo);
        	edit_redo = new JMenuItem("Redo");
        	edit_redo.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_MASK));
        	edit_redo.addActionListener(this);
        	edit.add(edit_redo);
        	edit_sep1 = new JSeparator();
        	edit.add(edit_sep1);
        	edit_copy = new JMenuItem("Copy");
        	edit_copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK));
        	edit_copy.addActionListener(this);
        	edit.add(edit_copy);
        	edit_cut = new JMenuItem("Cut");
        	edit_cut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK));
        	edit_cut.addActionListener(this);
        	edit.add(edit_cut);
        	edit_paste = new JMenuItem("Paste");
        	edit_paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK));
        	edit_paste.addActionListener(this);
        	edit.add(edit_paste);
        	edit_delete = new JMenuItem("Delete");
        	edit_delete.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
        	edit_delete.addActionListener(this);
        	edit.add(edit_delete);
        	edit_sep2 = new JSeparator();
        	edit.add(edit_sep2);
        	edit_find = new JMenuItem("Find");
        	edit_find.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_MASK));
        	edit_find.addActionListener(this);
        	edit.add(edit_find);
        	edit_find_next = new JMenuItem("Find Next");
        	edit_find_next.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0));
        	edit_find_next.addActionListener(this);
        	edit.add(edit_find_next);
        	edit_replace = new JMenuItem("Replace");
        	edit_replace.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_MASK));
        	edit_replace.addActionListener(this);
        	edit.add(edit_replace);
        	edit_sep3 = new JSeparator();
        	edit.add(edit_sep3);
        	edit_selectall = new JMenuItem("Select All");
        	edit_selectall.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK));
        	edit_selectall.addActionListener(this);
        	edit.add(edit_selectall);
        	edit_timedate = new JMenuItem("Time/Date");
        	edit_timedate.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));
        	edit_timedate.addActionListener(this);
        	edit.add(edit_timedate);
        	menubar.add(edit);

        	format = new JMenu("Format");
        	format_font = new JMenuItem("Font");
        	format_font.addActionListener(this);
        	format.add(format_font);

        	convert = new JMenu("Convert");//'convert' menu in the 'edit' menu
        	str2uppr = new JMenuItem("To Uppercase...");
        	str2uppr.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_MASK));
        	str2uppr.addActionListener(this);
        	convert.add(str2uppr);
        	str2lwr = new JMenuItem("To Lowercase...");
        	str2lwr.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK));
        	str2lwr.addActionListener(this);
        	convert.add(str2lwr);
        	format.add(convert);

        	format_wordwarp = new JCheckBoxMenuItem("Word Wrap");
        	format_wordwarp.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_MASK));
        	format_wordwarp.addActionListener(this);
        	format.add(format_wordwarp);
        	menubar.add(format);


 			tts = new JMenu("TTS");
 			co = new JMenuItem("Convert");
 			co.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0));
 			co.addActionListener(this);
 			tts.add(co);
 			menubar.add(tts);

	     	help = new JMenu("Help");
      	help_about = new JMenuItem("About");
        	help_about.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
        	help_about.addActionListener(this);
        	help.add(help_about);
        	menubar.add(help);

			JToolBar toolbar = new JToolBar();
			JButton t1 = new JButton();
			//JButton t2 = new JButton();
			t1.setIcon(new ImageIcon("save.jpg"));
			//t2.setIcon(new ImageIcon("save.jpg"));

			toolbar.add(t1);
			toolbar.addSeparator(  );
		//	toolbar.add(t2);
			//toolbar.addSeparator(  );
			toolbar.add(text);
			toolbar.addSeparator(  );
			toolbar.add(b1);

		 	this.setJMenuBar(menubar);
		  	c.add(toolbar,BorderLayout.NORTH);
		  	setLocationRelativeTo(menubar);

		   	     // undo manager
        	Document doc= t.getDocument();//container for text, for swing component operations

        	doc.addUndoableEditListener(
                new UndoableEditListener( )
                {
                    public void undoableEditHappened( UndoableEditEvent event )
                    {
         //Returns an UndoableEdit edit that occurred and has information about and commands to undo or redo the edit.
                        undo.addEdit(event.getEdit());
                    }
                }
        );

        // find_window
        finder = new Find(this);//initialise the instance of 'Find' class
        finder.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        // font chooser
        fc = new FontChooser(this);//initialise the instance of 'FontChooser' class
        abt = new About(this);//initialise the instance of 'About' class

        // set window size
        int w = 600;
        int h = 550;
        setSize(600, 550);
        // set window position
        Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();//find centre of the screen
        setLocation(center.x-w/2, center.y-h/2);
        this.setVisible(true);//show the container's components
        path = "";
        content="";
    }