Code:
import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JLabel;
 

 
public class TextEx extends JApplet{
       
        public void init (){
               
            
                JLabel MyLbl = new JLabel("Text Example.");
               
                add (MyLbl);
               
             
                String txt = MyLbl.getText();
        }
       
}