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

Jdbc, creating connection which will authenciate for a password

creating connection which will authenciate for a password

Finding highest and lowest numbers, Hi i need help creating a small program...

Hi i need help creating a small program that basically asks the user how many numbers hes going to use and then ask for those numbers and see which is the biggest and the smaller

Write a code in java to explain the while loop in java, Write a code in jav...

Write a code in java to explain the while loop in Java? // This is the Hello program in Java class Hello { public static void main (String args[]) { System.out.print("

Java assignment, Java Project Introduction: In this project, you will ex...

Java Project Introduction: In this project, you will explore a few sorting algorithms. You will also test their efficiency by both timing how long a given sorting operation take

What is bullseye explain with an example, What is Bullseye explain with an ...

What is Bullseye explain with an example? This is a easy applet that draws a series of filled, concentric circles alternating red and white, instead a bullseye. import java.ap

Garbage collection guarantee, Is it right that garbage collection guarante...

Is it right that garbage collection guarantee that a program will not run out of memory?

Coding, code for error correction and detection using even odd parity

code for error correction and detection using even odd parity

Develop a java - html5 based game, Develop a java/html5 based game Proje...

Develop a java/html5 based game Project Description: I want a game designed that mostly allows users to bid a certain amount of dogecoin and depending on how far they get in

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