FileDocCategorySizeDatePackage
FontChooser.javaAPI DocJ2ME MIDP 2.03445Thu Nov 07 12:02:16 GMT 2002example.chooser

FontChooser

public class FontChooser extends Form implements ItemStateListener
A Font chooser. This screen can be used to choose fonts. A form is used to select from the various choices for size, style, and face.

Fields Summary
int
face
int
style
int
size
ChoiceGroup
faceChoice
ChoiceGroup
styleChoice
ChoiceGroup
sizeChoice
Constructors Summary
public FontChooser()
Create a new font chooser form. Create each of the form entries

	super("Choose Attributes");
	faceChoice = new ChoiceGroup("Face", Choice.EXCLUSIVE);
	faceChoice.append("System", null);
	faceChoice.append("Monospace", null);
	faceChoice.append("Proportional", null);
	styleChoice = new ChoiceGroup("Style", Choice.MULTIPLE);
	styleChoice.append("Bold", null);
	styleChoice.append("Italic", null);
	styleChoice.append("Underlined", null);
	sizeChoice = new ChoiceGroup("Size", Choice.EXCLUSIVE);
	sizeChoice.append("Small", null);
	sizeChoice.append("Medium", null);
	sizeChoice.append("Large", null);

	append("Face");
	append(faceChoice);
	append("Style");
	append(styleChoice);
	append("Size");
	append(sizeChoice);
	
	setItemStateListener(this);
    
Methods Summary
public intgetFace()
Get the face of font currently being displayed.

return
the current face of the font
see
Font#getFace

	return face;
    
public intgetSize()
Get the size of font currently being displayed.

return
the current size of the font
see
Font#getSize

	return size;
    
public intgetStyle()
Get the style of font currently being displayed.

return
the current style being used for text
see
Font#getStyle

	return style;
    
public voiditemStateChanged(Item item)
Reflect changes in the item states into the states.

param
item that to which some change occurred

	if (item == faceChoice) {
	    int f = faceChoice.getSelectedIndex();
	    switch (f) {
		case 0: face = Font.FACE_SYSTEM; break;
		case 1: face = Font.FACE_MONOSPACE; break;
		case 2: face = Font.FACE_PROPORTIONAL; break;
	    }
	} else if (item == styleChoice) {
	    style = 0;
	    if (styleChoice.isSelected(0))
		style += Font.STYLE_BOLD;
	    if (styleChoice.isSelected(1))
		style |= Font.STYLE_ITALIC;
	    if (styleChoice.isSelected(2))
		style |= Font.STYLE_UNDERLINED;
	} else if (item == sizeChoice) {
	    int s = sizeChoice.getSelectedIndex();
	    switch (s) {
		case 0: size = Font.SIZE_SMALL; break;
		case 1: size = Font.SIZE_MEDIUM; break;
		case 2: size = Font.SIZE_LARGE; break;
	    }
	}
    
public voidsetFace(int face)
Set the Face of font to display.

param
face the face to select
see
Font#getFace

	this.face = face;
    
public voidsetSize(int size)
Set the Size of font to display.

param
size of the font to set
see
Font#getSize

	this.size = size;
    
public voidsetStyle(int style)
Set the Style of font to display.

param
style the style to select
see
Font#getStyle

	this.style = style;