It is relatively easy to transform a Java application into an Applet for use in a web browser as long as the Java application does not use external resources such as reading or writing local files.
I started with a Java Application for converting temperatures from Fahrenheit to Celcius and the other way as well. The Java Application uses the Swing library to create a GUI with two listeners on two JTextFields. Select link for code of TempConversion2.java.
I transformed the Java Application to an Java Applet called TempConvert.java. Select link for code of TempConvert.java. Note that I included comments on what I changed. Try it below.
Enter a value in either text field and press Enter.
In the html code for this web page, I added the following html tags to include the applet:
Reference: Chapter 23 in Java: How to Program by Dietel and Dietel, Eighth Edition.