您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes

Introduction

Content

Apply

Reflect

Extend

previous.gif
 (3087 bytes)

next.gif
 (2959 bytes)

 

Content Index

Content Page # 17

Creating and using a font

This example creates a Label object, and assigns to it a plain Helvetica font of size 36 points (half an inch high).:

 

Label timeDisplay = new Label ("");

timeDisplay.setFont (new Font ("helvetica", Font.PLAIN, 36));

This example creates a font and enables it in the current graphics context. All subsequent text methods will then use that font. 

g.setFont (new Font ("helvetica", Font.PLAIN, 36));

g.drawString ("hello", 5, 5);

Back to top

basicline.gif (169 bytes)

RITSEC - Global Campus
Copyright ?1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg