Oleh: denysutani | Juli 26, 2008

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);
}
}


Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

Kategori

%d blogger menyukai ini: