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

TextSample

public class TextSample extends Canvas
A Text sample. This screen can be used to display a Sample string. using the Face, Style, Size and foreground and background color.

Fields Summary
int
face
int
style
int
size
int
bgcolor
int
fgcolor
String
text
The sample text
static final int
border
The width of the border.
Constructors Summary
public TextSample()
Create a new TextSample canvas.


                  
      
	fgcolor = 0xffffff;
	bgcolor = 0x000000;
	size = Font.SIZE_MEDIUM;
	face = Font.FACE_SYSTEM;
	style = Font.STYLE_PLAIN;
    
Methods Summary
public intgetBackgroundColor()
Get the color of font currently being displayed.

return
the background color

	return bgcolor;
    
public intgetFace()
Get the face of font currently being displayed.

return
the current font face
see
Font#getFace

	return face;
    
public intgetForegroundColor()
Get the color of font currently being displayed.

return
the foreground color

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

return
The current size of font.
see
Font#getSize

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

return
the font style
see
Font#getStyle

	return style;
    
protected voidpaint(Graphics g)
Paint the canvas with the current color and controls to change it.

param
g the graphics context to which to paint


                              
        

	int w = getWidth();
	int h = getHeight();

	// Fill the background
	g.setColor(bgcolor);
	g.fillRect(0, 0, w, h);

	g.setColor(fgcolor);
	Font font = Font.getFont(face, style, size);
	g.setFont(font);
	g.drawString(text, 2, border,  Graphics.LEFT|Graphics.TOP);
    
public voidsetBackgroundColor(int color)
Set the Color of font to display.

param
color a new background color

	bgcolor = color;
    
public voidsetFace(int face)
Set the Face of font to display.

param
face to which to set the font
see
Font#getFace

	this.face = face;
    
public voidsetForegroundColor(int color)
Set the Color of font to display.

param
color a new foreground color

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

param
size to which the font should be set
see
Font#getSize

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

param
style to which to set the font
see
Font#getStyle

	this.style = style;