So today I present you simple tutorial about how to create an applet(Java)!
So lets move on !
The library we will use for the applet !
import java.awt.*; import javax.swing.*;We will use the .awt.*; library, since we are going to create a simple interface why not use the library for it ;)
The base of the application !
public class CodeCallApplet extends JApplet {
public void init() {
Here are we making it clear for the application that we are gonna use the JApplets functions, i.o.w; we are going to inheritance its functions.Our functions !
JLabel L = new JLabel("Welcome to CodeCall Applet !,JLabel.CENTER);
add(L);
L.setOpaque(true);
L.setBackground(Color.gray);
L.setForeground(Color.black);
L.setFont(new Font("SansSerif", Font.BOLD, 24));
}
}
There with out message and positioning it as well declaring no transparent background also what colours we will use and font :)The whole code !
import java.awt.*;
import javax.swing.*;
public class CodeCallApplet extends JApplet {
public void init() {
JLabel L = new JLabel("Welcome to CodeCall Applet !,JLabel.CENTER);
add(L);
L.setOpaque(true);
L.setBackground(Color.white);
L.setForeground(Color.black);
L.setFont(new Font("Arial", Font.BOLD, 24));
}
}
However we are not done yet !We didn't have main, oh noes, well we will let the browser do the job ;)
So let's create a html file to try out our applet !
The html file !
<html> <head> <title>CodeCall's first applet</title> </head> <body> CodeCall Applet ! <br> <applet code="TestApplet.class" width="400" height="150"> </applet> <br> </body> </html>So this code is basic html...
So I hope you guys enjoy this and will have some cool usage of it sometime in life :)
Cheers !
P.S - Have a screenshot, also pardon the black;"private things there nowdays.." :P
[ATTACH]1258[/ATTACH]


Sign In
Create Account




Back to top










