In this section we will show you about using swing in an applet. In this example, you will see that how resources of swing are used in the applet. All objects except lbl, have been used from Applet class since lbl which inherits from the JLabel class of the javax.swing.*; package, this is swing label which shows the message in first time This is the Swing Applet Example. when the applet is loaded but again when you click on the Add button and if first text box is blank then the label lbl shows the message Invalid entry! in red color otherwise shows the message Output of the second Text Box : number_in_second_text_box.
Here is the code of the program :
Here is the HTML code :
<applet code = "SApplet" width = "260"height = "200"></applet>
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial