SlideShare a Scribd company logo
Npm : 2012 4350 1228
Nama : Syahroni
Kelas : R7H
Mata Kuliah : Komputer Grafik
Dosen : Nahot Frastian, M.Kom
Program Studi : Teknik Informatika
Universitas : Universitas Indraprasta PGRI
Program Komputer Grafik :
- DrawText
Input :
import java.awt.Graphics ;
import java.awt.Color ;
import java.awt.* ;
public class DrawText extends java.applet.Applet {
public void paint ( Graphics g ) {
Font font = new Font ( "Helvetica" , Font.BOLD + Font.ITALIC ,
22 ) ;
FontMetrics fm = g.getFontMetrics (font) ;
String str = new String ( " the Height result of Education is " ) ;
g.setFont (font);
g.drawString (str , (size().width - fm.stringWidth (str))/2 ,
((size().height - fm.getHeight ())/2) + fm.getAscent());
}
}
Proses :
 Font yang di gunakan adalah helvetica dengan menggunakan tebal
& miring huruf
 Lalu huruf yang di tuliskan adalah “ the Height result of Education
is “
Output :

More Related Content

Draw text

  • 1. Npm : 2012 4350 1228 Nama : Syahroni Kelas : R7H Mata Kuliah : Komputer Grafik Dosen : Nahot Frastian, M.Kom Program Studi : Teknik Informatika Universitas : Universitas Indraprasta PGRI Program Komputer Grafik : - DrawText Input : import java.awt.Graphics ; import java.awt.Color ; import java.awt.* ; public class DrawText extends java.applet.Applet { public void paint ( Graphics g ) { Font font = new Font ( "Helvetica" , Font.BOLD + Font.ITALIC , 22 ) ; FontMetrics fm = g.getFontMetrics (font) ; String str = new String ( " the Height result of Education is " ) ; g.setFont (font); g.drawString (str , (size().width - fm.stringWidth (str))/2 , ((size().height - fm.getHeight ())/2) + fm.getAscent()); } }
  • 2. Proses :  Font yang di gunakan adalah helvetica dengan menggunakan tebal & miring huruf  Lalu huruf yang di tuliskan adalah “ the Height result of Education is “