Hello everybody, I am Pinak. I want to build an apllication regarding encryption. However,
I am confused. Should I use Applet or Swing ?????
Can you tell me what is the difference between the two??????:)

Hi there!

Okay so the difference between Swing and an Applet..

Applets are little programs imbedded in websites/HTML pages.
Applets also are more commonly used for small single tasks in
webpages.

Swing programs however, would probably be the better choice
in your situation. Swing acctualy refers to a class in the
java language that defines/handles GUI(Graphical user interface)
components like(like buttons, labels, textfields etc).

So just depends what program you want. Do you want a standalone java
program (swing) or do you want a java program imbedded in a website(applet).

Hope this helps!

Another definition;
Swing is a set of classes for building GUI.
Swing GUI classes can be used in applets or applications.
JApplet is the Swing version of the Applet class.

Applet is special class that browsers can work with to have a GUI on a web page.
The GUI can be Swing.

They are not mutually exclusive.

Applet is web base applications which are called through broswer and swing GUI.here is a little encrpt and decrpt program in swing.in this program you enter 4digit integer and then add each digit with itself and then plus with 7and %10.after that swap first digit with the 3rd and 2digit with the 4th one and then enter the encrpted number and decrpyt it to the original number.hope can give you a hint.

import javax.swing.*;
import java.util.Arrays;

class InfiniteForLoop {

               public static void main(String[] args) {

        int   i,  j=0;
        String enter,  D_Play= " ";
        int[] total= new int[4];

        enter=JOptionPane.showInputDialog("enter num");
        i=Integer.parseInt(enter);
        String str = Integer.toString(i);


       while(j<4)
{
       int result=i%10;
       int neww=(result+result+7)%10;
       total[j]=neww;
       i/=10;

       System.out.print(total[j]);
       j+=1;
}

       int tmp=total[0]+total[2];   // storing sum of total[0]&[2] in tmp
       int tmp2=total[1]+total[3];  // storing sum of total[1]&[3] in tmp

       total[0]=total[0]+total[2]-total[0]; // swaping [2] to [0]
       total[1]=total[1]+total[3]-total[1];  // swaping [3] to [1]
       total[2]=tmp-total[0];
       total[3]=tmp2-total[1];

       D_Play+="Original Numbers :" + "\n" +str+"\n"
       +"Numbers Swapped :"+"\n" +total[0]+""+total[1]+""+total[2]+""+total[3] ;

       JOptionPane.showMessageDialog(null,D_Play,"Swaped numbers",JOptionPane.INFORMATION_MESSAGE);

        Arrays.sort(total);;



///////////// ////NOW DECRPTION/////////////////////////


             int z,  k=0;;
             String Enter, D_play= " ";
             int[] Total= new int[4];

             enter=JOptionPane.showInputDialog("enter decr num");
             z=Integer.parseInt(enter);
             String Str = Integer.toString(z);

             while(k<4)
{
             int Result=z%10;
             Total[k]=Result;
             z/=10;
             k+=1;
}
             Arrays.sort(Total);

             if(Arrays.equals(Total,total))
{
            D_play+= "ORIGINAL NUMBERS :" + "\n" +str+ "\n"
            +"Encrpted n Swapped:"+"\n"+
            Str+"\n"

            +"NOW DECRPT IT :"+"\n"+"\n"+
            "Encrpted Number :"+"\n"+Str+"\n"+
            "Original Numbers :" + "\n" +str;
            JOptionPane.showMessageDialog(null,D_play,"Swaped numbers",JOptionPane.INFORMATION_MESSAGE);
}
}}

Thanx a lot..... I am goin through the code. Hope that it will help.

if your problem is solved please mark your thread as solved.thanks

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.