Java Applet Font Class Example

Java Applet Font

When we start development of the website the first question comes into our mind that how we can change the font or color of our text. Here with I have explained Java Applet Font class to change the font of the selected text as per your requirement. To set the font in the applet you need to use the setFont() method available in Graphics object.

 

Interested in Learning Java Programming Language but getting difficult to learn then you can check out

java tutorial using video

 

import java.applet.*;
import java.awt.*;
import java.applet.Applet;
import java.awt.Font;
import java.awt.Graphics;

/*
<applet code=”Applet6.class” height=”300″ width=”300″>
</applet>
*/
public class Applet6 extends Applet
{
public void paint(Graphics g)
{
Font mycustomefont = new Font(“Arial”, Font.BOLD,20);
g.setFont(mycustomefont);
g.drawString(“This is Sample Text using Arial Font and Bold”, 10, 50);

}
}

 

 Output

Java Applet Font Class Example

For your Information: I have published an article on C Programming, Java, Servlet, PHP, Android, JavaScript, and More. I have published many article and many video tutorial check out using any of the following link.

Adarsh Patel

My Self Adarsh Suryakant Patel. Currently I am working as Assistant Professor at Parul Instiute of Engineering and Technology, MCA Department, Limda, Vadodara. Major Responsibility : * Lectures * Organizing Training and Expert Sessions for * Placement and Recruitment * Faculty Representative