Langsung ke konten utama

JAVA APPLET AND JAVAFX


Java Applet

Program:
import java.awt.*;
public class TesApplet extends java.applet.Applet{

    public void paint(Graphics g){
        Font f = new Font("Tahoma"Font.BOLD60);
        g.setFont(f);
        g.setColor(Color.GRAY);

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

 Output:



JavaFX

Program:
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import java.util.Random;

public class FortuneTeller extends Application
{
    Text fortune = new Text("");
    String[] fortunes = {"You will lead a long and happy life",
        "You will become a famous Hollywood actor",
        "You will win the lottery but then lose everything",
        "A secret admirer will soon send you a sign of affection",
        "Your heart is in a place to draw true happiness",
        "A thrilling time is in your near future",
        "The one you love is closer than you think",
        "Plan for many pleasures ahead",
        "Something you lost will turn up soon",
        "The stars are in your favor",
        "A day is a span of time no one is wealthy enough to waste",
        "Financial hardships in your life is coming to an end",
        "One that would have the fruit must climb the tree",
        "You find beauty in ordinary things, do not lose this ability",
        "You will enjoy good health",
        "Your imagination is a great asset"};

    @Override
    public void start(Stage stage) throws Exception
    {
        VBox box = new VBox();
        box.setPadding(new Insets(20));
        box.setSpacing(20);
        box.setAlignment(Pos.CENTER);
       
        Text title = new Text("Fortune Teller");
        title.setFont(Font.font("SanSerif"36));
       
        box.getChildren().add(title);
       
        fortune.setFont(Font.font("SanSerif"18));
       
        box.getChildren().add(fortune);
       
        Button button = new Button("New Fortune");
        box.getChildren().add(button);
       
        button.setOnAction(this::buttonClick);
       
        Scene scene = new Scene(box, 500300);
        stage.setTitle("Fortune Teller");
        stage.setScene(scene);
        stage.show();
    }

    private void buttonClick(ActionEvent event)
    {
        Random rand = new Random();
        fortune.setText(fortunes[rand.nextInt(fortunes.length)]);
    }
}


 Output:




 

Komentar

Postingan populer dari blog ini

CRUD dengan CodeIgniter

CRUD CodeIgniter Tutorial lengkap bisa anda lihat di  petanikode Untuk sourcecode saya yang sudah saya modifikasi sendiri bisa dilihat  disini Hasil Read (menampilkan user) : Hasil Create (add user) : Hasil Update (Edit data user) : Hasil Delete (menghapus data user) :

Membuat Web dengan Google Apps Script

Membuat Web dengan Google Apps Script Apps Script adalah platform scripting yang dikembangkan oleh Google untuk pengembangan aplikasi ringan di platform G Suite. Google Apps Script pada awalnya dikembangkan oleh Mike Harm sebagai proyek sampingan sambil bekerja sebagai pengembang di Google Sheets. Dalam App Script ini anda dapat membuat berbagai bentuk aplikasi web, api, script sheet dll  dengan bantuan database Google Sheets. Dalam tutorial ini akan saya jelaskan cara membuat web pendataan YearBook dengan bantuan Apps Script ini. Website : https://script.google.com/macros/s/AKfycbyWGScRVdAYqZIX7qriMz-GSqii7YhoQIJGuCs3/exec 1. Pertama-tama silahkan kunjungi Google Sheets  anda. Silahkan login menggunkan akun google anda. Pilih menu Go to Google Sheets. 2. Isikan SpreadSheet anda dengan atribut-atribut data yang anda butuhkan. Seperti pada gambar dibawah Atribut yang saya gunakan : - nama - alamat - email - nohp - ig - tw...

Membuat Fungsi Login CodeIgniter

Membuat Login CodeIgniter SourceCode dapat dilihat disini  Tugas 4 Tutorial lebih lanjut bisa dilihat di  petanikode   Hasil Login Page: Setelah Login: