Saturday 4 February 2012

Membuat Program Font di Java

i sini saya akan menuliskan Program untuk penggunaan Objek/class Font di java,



di bawah ini program lengkapnya:

01 import java.awt.*;
02 import javax.swing.*;
03 
04 public class Fonts extends JFrame {
05 public Fonts() {
06 super ("Mengatur Font");
07 
08 setSize (400,300);
09 setVisible (true);
10 }
11 
12 public void paint (Graphics g) {
13 super.paint (g);
14 
15 g.setFont (new Font("Serif", Font.BOLD, 12));
16 g.drawString ("Serif 12pt Bold", 20,50);
17 
18 g.setFont (new Font("Arial", Font.ITALIC, 24));
19 g.drawString ("Monospaced 24pt Italic", 20,70);
20 
21 g.setFont (new Font("Verdana", Font.PLAIN, 14));
22 g.drawString ("Verdana 14pt Plain", 20,90);
23 
24 g.setColor (Color.RED);
25 g.setFont (new Font("Verdana", Font.BOLD + Font.ITALIC, 18));
26 g.drawString (g.getFont().getName()+" "+g.getFont().getSize() +
27 "pt Bold Italic", 20,110);
28 }
29 
30 public static void main (String args[]) {
31 Fonts test = new Fonts();
32 test.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
33 }
34 }

Semoga bermanfaat

0 comments:

Post a Comment

Vabry.Ardianto Design. Powered by Blogger.
Klik Like Untuk Menyukai FP Aurora
Twitter Delicious Facebook Digg Stumbleupon Favorites More