Cara membuat berbagai jenis font yanga da di bahasa pemrograman java. Disini diambil sample beberapa jenis huruf saja.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Jacka Santosa
*/
import java.awt.*;
import java.applet.*;
//demonstrates the use of fonts
public class Huruf extends Applet
{
Font font1 = new Font("Helvetica", Font.PLAIN, 22);
Font font2 = new Font("TimesRoman", Font.PLAIN, 20);
Font font3 = new Font("Courier", Font.PLAIN, 18);
Font font4 = new Font("Helvetica", Font.BOLD, 16);
Font font5 = new Font("Helvetica", Font.ITALIC, 16);
Font font6 = new Font("Helvetica", Font.BOLD + Font.ITALIC, 16);
public void paint(Graphics g)
{
g.setFont(font1);
g.drawString("This is Font 1 (Helvetica)", 30,30);
g.setFont(font2);
g.drawString("This is Font 2 (TimesRoman)", 30,80);
g.setFont(font3);
g.drawString("This is Font 3 (Courier)", 30,130);
g.setFont(font4);
g.drawString("This is Helvetica Bold", 30,180);
g.setFont(font5);
g.drawString("This is Helvetica Italic", 30,230);
g.setFont(font6);
g.drawString("This is Helvetica Bold and Italic", 30,280);
}
}
Tampilannya akan seperti ini :
Macam Font dalam bahasa Java
7/05/2011 03:20:00 PM |
Label:
Pemrograman
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar