Guest User

Untitled

a guest
Nov 29th, 2019
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. import java.awt.*;
  2. public class TesApplet extends java.applet.Applet
  3. {
  4.     public void paint (Graphics g)
  5.     {
  6.         Font f = new Font("SansSerif", Font.BOLD, 20);
  7.         g.setFont(f);
  8.         g.setColor(Color.BLUE);
  9.        
  10.         int xPusat = this.getSize().width/2;
  11.         int yPusat = this.getSize().height/2;
  12.        
  13.         String s = "Selamat Belajar Java Applet";
  14.         FontMetrics fm = this.getFontMetrics(f);
  15.         int posisiX = xPusat - (fm.stringWidth(s)/2);
  16.         g.drawString("Selamat Belajar java Applet", posisiX, yPusat);
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment