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

In javascript, In JavaScript, what is event handling? What are the two type...

In JavaScript, what is event handling? What are the two types of events? In JavaScript capturing events and responding to them is event handling. The system sends events to the

Bilbo board , Design and simulate the bilbo board which should include thre...

Design and simulate the bilbo board which should include three configurable bilbos and some application logic to verify tester operation. the system will be designed using proteus

What is the parent class for all swing components? , Design pattern : As y...

Design pattern : As you may look from the diagram given below, containers collect components. Sometimes you want to accumulate a container to another container. So, a container co

Write a java program in a netbeans project, Write a Java program in a NetBe...

Write a Java program in a NetBeans project that reads a text file containing the names and addresses of several people and displays them all at once or one at a time upon selecting

A new dynamic website, A NEW Dynamic Website I have the subsequent requi...

A NEW Dynamic Website I have the subsequent requirement which needs to be designed in 30 days (Max). 1) Construct a website which is a dynamic, means allow me to change conte

Add wordpress color picker to plug-in text field, Add WordPress color picke...

Add WordPress color picker to plug-in text field Project Description: I have a simple plug-in that needs the built-in Word Press color picker added to one of the text input f

Development of an android app urgent, Development of an Android app urgent ...

Development of an Android app urgent Project Description: I am searching for some good android developer who has depth in knowledge of making an app. I am focusing on a certa

Write a program that manages a list of train tickets, A fictitious train co...

A fictitious train company, 'Transrail', has commissioned you to write a program that manages a list of train tickets. The program should display a text menu that prompts the us

Describe features of spring, Here are some features of spring:- ? Lightw...

Here are some features of spring:- ? Lightweight: spring is lightweight when it comes to size and transparency. The essential version of spring framework is around 1MB. And t

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