Font di Java

Berikut ini contoh code untuk mengatur font tulisan menggunakan java. Semoga berguna

import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.FlowLayout;
import java.awt.Font;

public class Teks extends JFrame {
JLabel lbl1 = new JLabel(“Helvetica biasa”);
JLabel lbl2 = new JLabel(“SansSerif bold”);
JLabel lbl3 = new JLabel(“Monospaced italic”);
JLabel lbl4 = new JLabel(“Serif biasa”);

public Teks()
{
setTitle(“Font”);
setApplicationLayout();
setSize(175,200);
setLocationRelativeTo(null);
setVisible(true);
}

public static void main(String args[])
{
Teks teks = new Teks();
teks.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

public void setApplicationLayout()
{
setLayout(new FlowLayout());
lbl1.setFont(new Font (“Helvetica”, Font.PLAIN, 16));
lbl2.setFont(new Font (“SansSerif”, Font.BOLD, 16));
lbl3.setFont(new Font (“Monospaced”, Font.ITALIC, 16));
lbl4.setFont(new Font (“Serif”, Font.PLAIN, 24));
add(lbl1);
add(lbl2);
add(lbl3);
add(lbl4);
}
}

This entry was posted in J2SE. Bookmark the permalink.

2 Responses to Font di Java

  1. is your site already submitted to digg?because when i tried bookmarking it on digg lots of pages of your site already came up.i voted one of those though.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>