Java Applet & JavaFX
Java Applet
JavaFX
import java.awt.*;
public class TesApplet extends java.applet.Applet{
public void paint(Graphics g){
Font f = new Font("SansSerif", Font.BOLD, 20);
g.setFont(f);
g.setColor(Color.BLUE);
int xPusat = this.getSize().width/2;
int yPusat = this.getSize().height/2;
String s = "Selamat Belajar Java Applet";
FontMetrics fm = this.getFontMetrics(f);
int posisiX = xPusat - (fm.stringWidth(s)/2);
g.drawString("Selamat Belajar java Applet", posisiX, yPusat);
}
}
JavaFX
Comments
Post a Comment