Explain choosing font faces and sizes in java awt packages, JAVA Programming

Assignment Help:

Explain Choosing Font Faces and Sizes in java AWT packages?

Choosing a font face is simple. First you create a new Font object. Then you call g.setFont(Font f). To instantiate a Font object uses this constructor:

public Font(String name, int style, int size)

name is the name of the font family, e.g. "Serif", "SansSerif", or "Mono".

size is the size of the font in points. In computer graphics a point is considered to be equal to one pixel. 12 points is a general size font. 14 points is possible better on most computer displays. Smaller point sizes look good on paper printed along with a high resolution printer, but not in the lower resolutions of a computer monitor.

style is an mnemonic constant from java.awt.Font that tells while the text will be bold, italic or plain. The three constants are Font.PLAIN, Font.BOLD, and Font.ITALIC. The program below prints each font in its own face and 14 point bold.

import java.applet.*;
import java.awt.*;

public class FancyFontList extends Applet {

private String[] availableFonts;

public void init () {

Toolkit t = Toolkit.getDefaultToolkit();
availableFonts = t.getFontList();

}

public void paint(Graphics g) {

for (int i = 0; i < availableFonts.length; i++) {
Font f = new Font(availableFonts[i], Font.BOLD, 14);
g.setFont(f);
g.drawString(availableFonts[i], 5, 15*i + 15);
}
}

}


Related Discussions:- Explain choosing font faces and sizes in java awt packages

I want java web developer, Project Description: A web developer is requi...

Project Description: A web developer is required to finish a webcam site with basic account management and voting functionality. The website can make use of a third party fla

Explanation of EM algorithm, try { pa="weblog"; pa...

try { pa="weblog"; pas="weblog"; Connection c; Statement st;

Developing a prototype system in php and javascript, General Overview A...

General Overview A number of organisations are using micro-blogging as a cost-effective way of communicating with customers, building online communities and releasing informati

What type of operations takes place inside microprocessors, What type of op...

What type of operations takes place inside Microprocessors Building Blocks? Enlist them along with brief description. Bus Interface Unit: The bus interface unit is the part o

Query and update the text database for a library , Implement a program to q...

Implement a program to query and update the text database for a library using a client/server model allowing multiple clients safe access to the database, and using a producer-cons

Need software protection with data files encryption, Need Software protecti...

Need Software protection with data files encryption Project Description: I am use to Chinese dongle sense lock clave 2, i need to prepare to dongle encryption tool same appli

Functions of specific codes, Please can you write some codes and their func...

Please can you write some codes and their functions too. At least 10! Please

Stream as an object, What interface must an object implement before it can ...

What interface must an object implement before it can be written to a stream as an object?      Ans) An object must execute the Serializable or Externalizable interface before i

Data access objects (DOA) in JDBC, Business Objects represent the data cl...

Business Objects represent the data client. They are the objects that need access to the datasource to obtain and store data. Data Access Objects abstract the relying data access i

Illustrate about the java runtime environment, Java Runtime Environment (JR...

Java Runtime Environment (JRE) Java Virtual Machine is a part of a large system i.e. Java Runtime Environment (JRE). Every operating system and CPU architecture requires dif

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd