reyhanzo

Untitled

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