R4R
Right Place For Right Person TM
 

R4R Java SourceCode Set Font Java


Set Font Java

In this example we going to explain how we can set font of string on applet. We need to import two packages java.applet.Applet and java.awt.*. The java.applet.Applet is imported to make applet window and used its two methods eg. paint(Graphics g) and init(). In init() method we define the initial property which we required in application. The paint()  method is used to paint the window. We are using Font class to create an objects of font. We are using Font(String fontName, int fontType,int size) constructor. In this example we are creating three objects of font .In first object we are passing the Aligerian type font and it is pain type and the size is 25.Similay we are creating second object the name of Font is TimesRoman and it is Bold and the size of the font is 45.In last we are creating font as Courier type and it is ITALIC type and the size is 25.
To set the font we are using setFont(Font object).

SOURCE CODE


import java.applet.*;
import java.awt.*;
//<applet code="Appf1.class" width=200 height=200></applet>
public class SetFont extends Applet
{
	 Font a,b,c;
	 public void init()
	 {
		setBackground(Color.red);
		a=new Font("Algerian",Font.PLAIN,25);
		b=new Font("TimesRoman",Font.BOLD + Font.ITALIC,45);
		c=new Font("Courier",Font.ITALIC,25);
	 }
	 public void paint(Graphics g)
	 {
		g.setFont(a);
		g.setColor(Color.black);
		g.drawString("R4$",10,20);
		g.setFont(b);
		g.setColor(Color.blue);
		g.drawString("Rajesh",10,50);
		g.setFont(c);
		g.setColor(Color.white);
		g.drawString("Java",10,80);
	}
}

Download Source File
 

Output of This Example


Tolal:0 Click:
Show All Comments

Post Your Comments

Your Name:

Your Email ID :
Comments :
URL
  =* Enter SUM

New Updates

10:New Updates
Tutorials,examples and Interview Questions with answers
Posted By: Shashi     Posted Date:02.10.14

9:C# Tutorials,C# examples and C# Interview Questions with answers
R4R provide C# Tutorials,C# examples and C# Interview Questions with answers. Through R4R you can develop a small application and small programs.We cover C# Tutorials,C# examples and C# Interview Questions and answers for freshers as well experienced programmer.
Posted By: Shashi     Posted Date:11.17.13

8:Java/J2EE(Servlet,JSP,JNDI,Struts,Spring,Hibernate,EJB,JSF,JMS,Web-Services)
In this section R4R covers Java/J2EE(Servlet,JSP, JNDI, Struts, Spring, Hibernate, EJB,JSF,JMS,Web-Services) Tutorials with Examples.R4R provide Java/J2EE (Servlet,JSP, JNDI,Struts, Spring, Hibernate, EJB, JSF, JMS, Web-Services) Interview Questions with answers study materials for freshers and experienced.
Posted By: Shashi     Posted Date:11.13.13

7:CoreJava Tutorials , CoreJava Examples and CoreJava Interview Questions with answers
In this section R4R covers CoreJava Tutorials with CoreJava Examples. R4R covers CoreJava programming concept in easy way. R4R provide CoreJava Interview Questions with answers study materials for freshers and experienced.
Posted By: Shashi     Posted Date:11.04.13

6:Microsoft.net Technology ASP.NET,c# ,ADO.NET,WCF,WPF,Silverlight ,VB.net
R4R provides Microsoft Technologies(like ASP.NET,c# ,ADO.NET,WCF,WPF, Silverlight and VB.ne)Tutorials with Examples,programming concept and Interview Questions with answers study materials for freshers and experienced.
Posted By: Shashi     Posted Date:11.04.13

5:J2me Tutorials concept with Examples with Netbean IDE and J2ME Application Examples.
R4R cover basic J2me Tutorials concept with Examples and provide a way to develop J2me programming concept in easy way. R4R provide J2me Interview Questions with answers.R4R provide J2me Languages study materials with examples uing Netbean IDE and J2ME Application Examples.
Posted By: Shashi     Posted Date:10.30.13

4:J2me Tutorials concept with Examples ith netbean IDE and J2ME Application Examples.
R4R cover basic J2me Tutorials concept with Examples and provide a way to develop J2me programming concept in easy way. R4R provide J2me Interview Questions with answers.R4R provide J2me Languages study materials with examples uing Netbean IDE and J2ME Application Examples.
Posted By: Shashi     Posted Date:10.30.13

3:Java ebooks , Java tutorials , Java examples , Java interview questions and answers
R4R provides study materials for Java/j2EE technologies. R4R covers core java, advanced java, servlet, JSP, Struts, Spring, Hibernate, EJB, JSF, J2ME, ANT, JUnit and Some APIS .R4R also provides ebooks,tutorials,examples, interview questions and answers.
Posted By: Shashi     Posted Date:10.30.13

2:Learn basic C++ Tutorials with Examples , C++ Interview Questions with answers
R4R is a free E-learning website.You can learn basic C++ Tutorials with Examples , C++ Interview Questions with answers and also some hot topics.
Posted By: Shashi     Posted Date:10.30.13

1:C Tutorials with Example C subjective and objective interview questions and answers
R4R provide C Tutorials with Example and also provides C subjective and objective interview questions and answers.You can learn C in easy way.We cover basics of C here and give some examples.
Posted By: Shashi     Posted Date:10.30.13

R4R
R4R
R4R
R4R
R4R
R4R
R4R
R4R