Tuesday, 9 June 2015

An applet program that concatenates two string entered in TextField


Code for An applet program that concatenates two string entered in TextField in Java



 



 



 
import java.awt.*;
import java.applet.*;

publicclass concat2Str extends Applet
{
       TextField Ts1,Ts2;

       publicvoid init(){
            Ts1 = new TextField(10);
            Ts2 = new TextField(10);
            add(Ts1);
            add(Ts2);
            Ts1.setText("");
            Ts2.setText("");
        }

        publicvoid paint(Graphics g){
            String str1,str2;

            g.drawString("Enter Two String to Concat Them ",10,50);

            str1=Ts1.getText();
            str2=Ts2.getText();
            g.setColor(Color.red);
            g.drawString(str1+" "+str2,10,70);
            showStatus("Concatination of 2 String");
     }

     public boolean action(Event e, Object o){
           repaint();
           returntrue;
    }

}

No comments:

Post a Comment