Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- /**
- * Implementasi JavaFX: Random Waifu
- *
- * @author Thomas Felix
- * @version 13 Desember 2020
- */
- public class RandomWaifu extends Application
- {
- Text waifu = new Text("");
- String[] waifus =
- {
- "Rem - Re:Zero",
- "Emilia - Re:Zero",
- "Makise Kurisu - Steins;Gate",
- "Senjougahara Hitagi - Monogatari Series",
- "Gasai Yuno - Mirai Nikki",
- "Saber - Fate Series",
- "Yuuki Asuna - Sword Art Online",
- "Yukinoshita Yukino - Oregairu",
- "Megumin - Konosuba",
- "Miyazono Kaori - Shigatsu wa Kimi no Uso"
- };
- @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("Random Waifu");
- title.setFont(Font.font("Highway Gothic", 36));
- box.getChildren().add(title);
- waifu.setFont(Font.font("Highway Gothic", 18));
- box.getChildren().add(waifu);
- Button button = new Button("Klik Daku!");
- box.getChildren().add(button);
- button.setOnAction(this::buttonClick);
- Scene scene = new Scene(box, 500, 250);
- stage.setTitle("Random Waifu");
- stage.setScene(scene);
- stage.show();
- }
- /**
- * Fungsi akan dijalankan ketika button diklik.
- * Dan akan increment++
- */
- private void buttonClick(ActionEvent event)
- {
- Random rand = new Random();
- waifu.setText(waifus[rand.nextInt(waifus.length)]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment