Hi i have written following java application in java and now i wnt to convert it into java applet,so an anybody help me out,plz.thanx in advance.

import java.awt.*;
import java.io.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.text.*;
import javax.swing.event.*; 
import javax.swing.undo.*;
import javax.swing.text.*; 
import javax.swing.KeyStroke.*;

public class mynote extends JFrame implements ActionListener
{
 Container c;
 MenuBar mb;
 Menu m1,m2,m3,m4;
 MenuItem m1i1,m1i2,m1i3,m1i4,m1i5;
 MenuItem m2i1,m2i2,m2i3,m2i4,m2i5,m2i6,m2i7,m2i9,m2i10;
 MenuItem m3i1,m3i2;
 CheckboxMenuItem m2i8;
 static JTextArea ta;
 String s="",s1,str,str1;
 File f1,f2,f3;
 MenuShortcut msc;
 int flag=0,v,h;
 int x,y,i=0;
 File f;
 FileOutputStream fos;
 FileInputStream fis;
 byte b[]=new byte[20];
 String line="";
 DateFormat df,df1;
 Date d;
 JScrollPane jsp;
 int fileflag=1;
 String filename;
 private UndoManager undo = new UndoManager();
 mynote()
 {
  c=getContentPane();
  c.setLayout(new BorderLayout());
  MyWindowAdapter adapter=new MyWindowAdapter(this);
  addWindowListener(adapter);
  ta=new JTextArea(s,80,80);
  c. add(ta);
  jsp=new JScrollPane(ta);
  c.add(jsp);
  setTitle("UNTITLED-NOTEPAD");
  msc=new MenuShortcut(79);
  mb=new MenuBar();
  m1=new Menu("File");  
  m2=new Menu("Edit");
  m3=new Menu("Search");
  m1i1=new MenuItem("New",new MenuShortcut( KeyEvent.VK_N ));
  m1i2=new MenuItem("Open",new MenuShortcut( KeyEvent.VK_O ));
  m1i3=new MenuItem("Save",new MenuShortcut( KeyEvent.VK_S ));
  m1i4=new MenuItem("Save As..");
  m1i5=new MenuItem("Exit");
  m1.add(m1i1); 
  m1.add(m1i2); 
  m1.add(m1i3); 
  m1.add(m1i4);
  m1.add(m1i5);
  m2i1=new MenuItem("Undo",new MenuShortcut(KeyEvent.VK_Z ));
  m2i2=new MenuItem("Cut",new MenuShortcut(KeyEvent.VK_X ));
  m2i3=new MenuItem("Copy",new MenuShortcut(KeyEvent.VK_C ));
  m2i4=new MenuItem("Paste",new MenuShortcut(KeyEvent.VK_V ));
  m2i5=new MenuItem("Delete",new MenuShortcut(KeyEvent.VK_DELETE));
  m2i6=new MenuItem("Select All",new MenuShortcut(KeyEvent.VK_A));
  m2i7=new MenuItem("Time/Date",new MenuShortcut(KeyEvent.VK_F5));
  m2i8=new CheckboxMenuItem("WordWrap");
  m2i9=new MenuItem("Set Font...");
  m2i10=new MenuItem("Redo");
  m2.add(m2i1);
  m2.add(m2i2); 
  m2.add(m2i3);
  m2.add(m2i4);
  m2.add(m2i5);
  m2.add(m2i6);
  m2.add(m2i7);
  m2.add(m2i8);
  m2.add(m2i9);
  m2.add(m2i10);
  m3i1=new MenuItem("Find...");
  m3i2=new MenuItem("FindNext F3");
  m3.add(m3i1); 
  m3.add(m3i2);
  mb.add(m1); 
  mb.add(m2);
  mb.add(m3);
  setMenuBar(mb);
  m1i1.addActionListener(this);
  m1i2.addActionListener(this);
  m1i3.addActionListener(this);
  m1i4.addActionListener(this);
  m1i5.addActionListener(this);
  m2i1.addActionListener(this);
  m2i2.addActionListener(this);
  m2i3.addActionListener(this);
  m2i4.addActionListener(this);  
  m2i5.addActionListener(this);
  m2i6.addActionListener(this);
  m2i7.addActionListener(this);
  m2i8.addActionListener(this);
  m2i9.addActionListener(this);
  m2i10.addActionListener(this);
  m3i1.addActionListener(this);
  m3i2.addActionListener(this);
  Document doc = ta.getDocument();
  doc.addUndoableEditListener(new UndoableEditListener() {
  public void undoableEditHappened(UndoableEditEvent evt) {
  undo.addEdit(evt.getEdit());
  }
  });
  ta.setWrapStyleWord(false);
  setSize(500,500);
  setVisible(true);
  }

 public String getExtension(String  f) 
 {
  if(f != null) 
  {
  int extensionIndex = f.lastIndexOf('.');
  if(extensionIndex < 0) 
  {
  return null;
  }
  return f.substring(extensionIndex+1).toLowerCase();
  }
  return null;
 }

public void actionPerformed(ActionEvent ae)
 {
  if(ae.getSource()==m1i2)
  {
  FileDialog fd=new FileDialog(this,"Open",FileDialog.LOAD);
  fd.setVisible(true);
  s=fd.getFile();
  setTitle(s+"- NOTEPAD");
  str=fd.getDirectory();
  str1=(fd.getDirectory()+fd.getFile());
  s1=getExtension(s);
  try
  {
   FileReader fr=new FileReader(str1);
   BufferedReader br=new BufferedReader(fr);
   while((line=br.readLine())!=null)
   {
    ta.append(line+"\n");
   }
  }
  catch(Exception e){}
  }

  if(ae.getSource()==m1i3)
  {
   DataInputStream dis;
   try
   {
   if(fileflag==0)
   {
   FileDialog fd=new FileDialog(this,"Save",FileDialog.SAVE);
   fd.setVisible(true);
   s=fd.getFile();
   filename=s;
   str1=fd.getDirectory()+fd.getFile();
   setTitle(s+".txt- NOTEPAD");
   System.out.println(filename);
   fileflag=1;
   }  
   s1="";
   s1=ta.getText();
   FileWriter fw=new FileWriter(str1);
   StringReader sr=new  StringReader(s1);
   BufferedReader br=new BufferedReader(sr);
   String lr="";
   while((lr=br.readLine())!=null)
   {
   fw.write(lr+"\r\n");
   }
   fw.close();
   }catch(Exception pe)
   {setTitle("UNTITLED.txt");}  
   }

  if(ae.getSource()==m1i4)
  {
  FileDialog fd=new FileDialog(this,"Save As",FileDialog.SAVE);
  fd.setVisible(true);
  s=fd.getFile();
  setTitle(s+" - NOTEPAD");
  DataInputStream dis;
  str1=fd.getDirectory()+fd.getFile();
  try
  {
  s1="";
  s1=ta.getText();
  FileWriter fw=new FileWriter(fd.getDirectory()+fd.getFile());
  StringReader sr=new  StringReader(s1);
  BufferedReader br=new BufferedReader(sr);
  String lr="";
  while((lr=br.readLine())!=null)
  {
   fw.write(lr+"\r\n");
  }
  fileflag=1; 
  fw.close();
  }
  catch(Exception pe){}
 }

 if(ae.getSource()==m1i5)
 {
  System.exit(0);
 }

 if(ae.getSource()==m1i1)
 {
  s="";
  ta.setText(s);
  setTitle("UNTITLED-NOTEPAD");
  fileflag=0;
  filename="";
 }

 if(ae.getSource()==m2i1)
 {
 try {
 if (undo.canUndo())
 {
 undo.undo();
 }
 }catch(CannotUndoException e){ }
 }

 if(ae.getSource()==m2i9)
 {
 myfont  myfon=new myfont(this);
 }

 if(ae.getSource()==m2i10)
 {
 try {
 if (undo.canRedo())
 {
 undo.redo();
 }
 }catch(CannotRedoException e) { }  
 }

 if(ae.getSource()==m2i2)
 {
 s=ta.getSelectedText();
 ta.cut(); 
 }

 if(ae.getSource()==m3i2)
 {
 find sear=new find(this);
 }

 if(ae.getSource()==m2i3)
 {
 s=ta.getSelectedText();
 ta.copy(); 
 }

 if(ae.getSource()==m2i4)
 {
 s=ta.getSelectedText();
 ta.paste(); 
 }

 if(ae.getSource()==m2i6)
 {
 ta.selectAll(); 
 }

 if(ae.getSource()==m2i5)
 {
 x=ta.getSelectionStart();
 y=ta.getSelectionEnd();
 ta.replaceRange(" ",x,y);
 }

 if(ae.getSource()==m2i8)
 {
 if(ta.getWrapStyleWord()==false)
 {
 ta.setWrapStyleWord(true);
 System.out.println("wordwrap is set");
 }
 else
 {
 ta.setWrapStyleWord(false);
 System.out.println("wordwrap is not set");
 }
 }

 if(ae.getSource()==m2i7)
 {
  d=new Date();
  df=DateFormat.getDateInstance(DateFormat.MEDIUM);
  df1=DateFormat.getTimeInstance(DateFormat.MEDIUM);
  str= df.format(d);
  str1=df1.format(d);
  ta.setText(str+"   "+str1);
  }

 if(ae.getSource()==m3i1)
 {
  find sear=new find(this);
 }
 }

public static void main(String a[])
{
 mynote mynote=new mynote();
 }
}

class MyWindowAdapter extends WindowAdapter
{
 mynote mynote;
 MyWindowAdapter(mynote mynote)
 {
  this.mynote=mynote;
 }
 public void windowClosing(WindowEvent we)
 {
 System.exit(0);
 }
}

class myfont extends Dialog implements ActionListener,ItemListener
{
 GraphicsEnvironment ge;
 java.awt.List l1,l2,l3;
 Button b1,b2;
 Font f1[];
 String f[];
 int i,j;
 mynote mynote;
 TextField tf1,tf2,tf3;
 Label ll1,ll2,ll3;
 String fn;
 int fs,fsize;
 public myfont(mynote myno)
 {
 super(myno,"Font",true);
 setLayout(null);
 mynote=myno;
 ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
 l1=new java.awt.List();
 l2=new java.awt.List();
 l3=new java.awt.List();
 b1=new Button("OK");
 b2=new Button("CANCEL");
 tf1=new TextField(10);
 tf2=new TextField(10);
 tf3=new TextField(10);
 ll1=new Label("Font");
 ll2=new Label("Font Style");
 ll3=new Label("Size");
 ll1.setBounds(20,60,100,20);
 add(ll1);
 tf1.setBounds(20,80,100,20);
 add(tf1);
 l1.setBounds(20,100,100,150);
 add(l1);
 ll2.setBounds(140,60,100,20);
 add(ll2);
 tf2.setBounds(140,80,100,20);
 add(tf2);
 l2.setBounds(140,100,100,150);
 add(l2);
 ll3.setBounds(260,60,100,20);
 add(ll3);
 tf3.setBounds(260,80,100,20);
 add(tf3);
 l3.setBounds(260,100,100,150); 
 add(l3);
 b1.setBounds(380,70,80,20);
 add(b1);
 b2.setBounds(380,95,80,20);
 add(b2);
 f=ge.getAvailableFontFamilyNames();
 for(i=0;i<f.length;i++)
 {
  l1.add(f[i]);
  }
 l2.add("Regular");
 l2.add("Bold");
 l2.add("Italic");
 l2.add("BoldItalic");
 for(i=8;i<=72;i+=2)
 l3.add(String.valueOf(i));
 b2.addActionListener(this);
 b1.addActionListener(this);
 l1.addItemListener(this);
 l2.addItemListener(this);
 l3.addItemListener(this);
 setSize(480,280);
 setResizable(false);   
 setVisible(true);
}

public void actionPerformed(ActionEvent fe)
{
 if(fe.getSource()==b2)
 {
 dispose();
 }

 if(fe.getSource()==b1)
 {
 mynote.ta.setFont(new Font(fn,fs,fsize));
 dispose();
 }
}

public void itemStateChanged(ItemEvent ie)
{
if(ie.getSource()==l1)
{
tf1.setText(l1.getSelectedItem());
fn=tf1.getText();
}

if(ie.getSource()==l2)
{
tf2.setText(l2.getSelectedItem());
if(tf2.getText().equals("Bold"))
fs=Font.BOLD;
else 
    if(tf2.getText().equals("Italic"))
    fs=Font.ITALIC;
    else
        if(tf2.getText().equals("BoldItalic"))
        fs=Font.BOLD+Font.ITALIC;
        else fs=Font.PLAIN; 

if(tf2.getText()=="")
{
tf2.setText("Regular");
fs=Font.PLAIN; 
}   
}

if(ie.getSource()==l3)
{  
tf3.setText(l3.getSelectedItem());
fsize=Integer.parseInt(tf3.getText());
if(tf3.getText()=="")
 {
 fsize=8;
 }  
}   
}
} 

class find extends JDialog implements ActionListener
{
 JPanel jPanel = new JPanel();
 JButton find_next = new JButton();
 JButton replace = new JButton();
 JButton replaceAll = new JButton();
 JButton cancel = new JButton();
 JTextField find = new JTextField();
 JTextField replacewith = new JTextField();
 JLabel jLabel1 = new JLabel();
 JLabel jLabel2 = new JLabel();
 JCheckBox matchcase = new JCheckBox();
 int pos;
 int count;
 int a;
 int newcounter;
 int jass=0;

 public find(mynote mynote)
 {
 find_next.setText("Find Next");
 replace.setText ("   Replace  ");
 replaceAll.setText("Replace All");
 cancel.setText ("    Cancel    ");
 jLabel1.setText("Find Text:");
 jLabel2.setText("Replace With:");
 matchcase.setText("Match Case");
 JPanel jPanela = new JPanel();
 JPanel jPanelb = new JPanel();
 JPanel jPanelc = new JPanel();
 JPanel jPaneld = new JPanel();
 jPanel.setLayout(new GridLayout(0, 1, 4, 0));
 jPanela.setLayout(new FlowLayout(FlowLayout.RIGHT));
 jPanelb.setLayout(new FlowLayout(FlowLayout.RIGHT));
 jPanelc.setLayout(new FlowLayout(FlowLayout.RIGHT));
 jPaneld.setLayout(new FlowLayout(FlowLayout.RIGHT));
 jPanela.add(jLabel1);
 jPanela.add(find);
 jPanela.add(find_next);
 jPaneld.add(matchcase);
 jPanelb.add(jLabel2);
 jPanelb.add(replacewith);
 jPanelb.add(replace);
 jPanelc.add(cancel);
 find.setColumns(14);
 replacewith.setColumns(14);
 jPanel.setBorder(BorderFactory.createTitledBorder(""));
 jPanel.add(jPanela);
 jPanel.add(jPanelb);
 jPanel.add(jPanelc);
 jPanel.add(jPaneld);
 getContentPane().add(jPanel);
 find_next.addActionListener(this);
 replace.addActionListener(this);
 cancel.addActionListener(this);
 setResizable(false);
 setVisible(true);
 pack();
 KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
 Keymap map = find.getKeymap();
 map.removeKeyStrokeBinding(enter);
 getRootPane().setDefaultButton(find_next);
 }

 public void actionPerformed(ActionEvent se)
 {
 if (se.getSource() == cancel)
 {
 setVisible(false);
 }
 else if (se.getSource() == find_next)
 {
 finds();
 }
 else if (se.getSource() == replace)
 {
 Replace();
 }
 }

 public void finds()
 {
 String str;
 String txt;
 if (matchcase.isSelected())
 {
 txt = mynote.ta.getText();
 str = find.getText();
 }
 else
 {
 txt = mynote.ta.getText().toLowerCase();
 str = find.getText().toLowerCase();
 }
 pos = txt.indexOf(str,mynote.ta.getSelectionEnd());
 if (pos !=0)
 mynote.ta.select(pos,(pos+str.length()));
 else
 System.out.println("Could not find match ");
 } 

 public void Replace()
 {
 int start = mynote.ta.getSelectionStart();
 int end = mynote.ta.getSelectionEnd();
 if (end != start)
 {
 mynote.ta.replaceSelection(replacewith.getText());
 System.out.println(start+(replacewith.getText().length()));
 mynote.ta.select(start, start + replacewith.getText().length());
 finds();
 }
 else
 {
 System.out.println("this is inside the else loop");
 System.out.println(start+replacewith.getText().length());
 }
 }
}

read up on what makes an applet and applet and you'll know soon enough what you need to do.
Hint: it's a few methods that need implementing, a bit of code shuffled from the main method to a utility method to be called from both main and some of those methods, and that's basically it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.