This code creates a small application which is a basic text editor initially and I have added a drop down file menu which is obvious in every editor, it includes features like 'new', 'open', 'save' and 'save as'.
I am not getting how to add the feature of saving in the existing file and a new file.
import java.io.*;  
import java.awt.event.*;  
import javax.swing.*;    
import java.io.IOException;
import java.nio.file.StandardOpenOption;
public class Editor implements ActionListener
{    
    boolean updateStatus;
    Editor Jedtr;
    boolean saved;  
    boolean newFileFlag;  
    String fileName;    
    static File fileRef;  
    JFrame f;    
    JMenuBar mb;    
    JMenu file,edit,help;    
    JMenuItem cut,copy,paste,selectAll,NewFile,Open,Save,SaveAs;    
    JTextArea ta;  
    Editor(){ 
        saved=true;  
        newFileFlag=true;  
        fileName=new String("Untitled");  
        fileRef=new File(fileName);  
        Open=new JMenuItem("Open File");    
        Open.addActionListener(this);            
        file=new JMenu("File");    
        file.add(Open);             
        mb=new JMenuBar();    
        f=new JFrame();    
        cut=new JMenuItem("Cut");    
        copy=new JMenuItem("Copy");    
        paste=new JMenuItem("Paste");    
        selectAll=new JMenuItem("Select All");    
        /////////////////////////////////////////////////////////////////////////////////
        NewFile =new JMenuItem("New");
        Open=new JMenuItem("Open");
        Save=new JMenuItem("Save");
        SaveAs=new JMenuItem("Save As");
        ///////////////////////////////////////////////////////////////////////////////////
        cut.addActionListener(this);    
        copy.addActionListener(this);    
        paste.addActionListener(this);    
        selectAll.addActionListener(this);
        /////////////////////////////////////////////////////////////////////////////////////
        NewFile.addActionListener(this);
        Open.addActionListener(this);
        Save.addActionListener(this);
        SaveAs.addActionListener(this);
        //////////////////////////////////////////////////////////////////////////////////
        mb=new JMenuBar();    
        file=new JMenu("File");    
        edit=new JMenu("Edit");    
        help=new JMenu("Help");     
        file.add(NewFile);file.add(Open);file.add(Save);file.add(SaveAs);    
        edit.add(cut);edit.add(copy);edit.add(paste);edit.add(selectAll);    
        mb.add(file);mb.add(edit);mb.add(help);    
        ///////////////////////////////////////////////////////////////////////////////////////
        ta=new JTextArea();    
        ta.setBounds(5,5,1200,1200);    
        f.add(mb);f.add(ta);    
        f.setJMenuBar(mb);  
        f.setLayout(null);    
        f.setSize(800,400);    
        f.setVisible(true);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }     
    /////////////////////////////Action performed/////////////////////////////////////////////////
    public void actionPerformed(ActionEvent e) 
    {
        if(e.getSource()==cut)                 
            ta.cut();                                // to cut text.
        else if(e.getSource()==paste)
            ta.paste();                             // to paste text. 
        else if(e.getSource()==copy)
            ta.copy();                              // to copy text.
        else if(e.getSource()==selectAll)
            ta.selectAll();                        // to select text. 
        else if(e.getSource()==Open)
        {
            JFileChooser fc=new JFileChooser();
            int i=fc.showOpenDialog(f);
            if(i==JFileChooser.APPROVE_OPTION)
            {
                File f=fc.getSelectedFile();
                String filepath=f.getPath();
                try
                {
                    BufferedReader br=new BufferedReader(new FileReader(filepath));
                    String s1="",s2="";
                    while((s1=br.readLine())!=null)
                    {
                        s2+=s1+"\n";
                    }
                    ta.setText(s2);
                    br.close();
                }
                catch (Exception ex)
                {
                    ex.printStackTrace();
                }
            }
        }                                       //to open an existing file
        else if(e.getSource() == NewFile)
        {
            JFileChooser fc=new JFileChooser();
            int j=fc.showOpenDialog(f);
            if (j==JFileChooser.CUSTOM_DIALOG);
            System.out.println("New File");
            File file = new File("C:\\Android\\.txt");
            boolean result;
            try {
                // create a new file
                result = file.createNewFile();
                // test if successfully created a new file
                if(result){
                    System.out.println("Successfully created "+file.getAbsolutePath());
                }
                else{
                    System.out.println("Filed creating "+file.getAbsolutePath());
                }
            }
                catch (IOException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
    }                                            // to create a new file.
            else if(e.getSource()== SaveAs)
            {                                  // what to specify here?
                }
            else if(e.getSource()==Save)
            {                                 // what to specify here?
            }
}
                /*private Object SaveAs(File temp)
{
    // TODO Auto-generated method stub
    return null;
}
///////////////////////////////////////////////////////////////////////////////////////////////
private void updateStatus(File temp, boolean b)
{
    // TODO Auto-generated method stub
}*/
                boolean isSave()
                {
                    return saved;}  
                void setSave(boolean saved)
                {
                    this.saved=saved;
                }
                String getFileName()
                {
                    return new String(fileName);
                }
                void setFileName(String fileName)
                {
                    this.fileName=new String(fileName);
                }  
                ////-------File-------////////
                //public class File implements ActionListener{}
                ////-------File-------////////
                /*public void actionPerformedf(ActionEvent O) {    
if(O.getSource()==Open){    
    JFileChooser fc=new JFileChooser();    
    int i=fc.showOpenDialog(f);    
    if(i==JFileChooser.APPROVE_OPTION){    
        File f=fc.getSelectedFile();    
        String filepath=f.getPath();    
        try{  
        BufferedReader br=new BufferedReader(new FileReader(filepath));    
        String s1="",s2="";                         
        while((s1=br.readLine())!=null){    
        s2+=s1+"\n";    
        }    
        ta.setText(s2);    
        br.close();    
        }catch (Exception ex) 
        {
            ex.printStackTrace();          
        }
    }
    }
    }*/    
                public static void main(String[] args) {    
                    new Editor(); 
                }    
            }
 
     
    