I tried to make a simple game with Javafx ① "Let's find happiness game" (unfinished)

I made a simple game with Javafx ①

"Let's find happiness game" (unfinished)


package happy_unhappy_game;

import java.util.Random;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.TilePane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

	public class Sample extends Application {

		public static void main(String[]args) {

		 public static Scene scene1 = null;
		 public static Scene scene2 = null;

		 public static String txt=null;
		 public static String txt2=null;
    	 public static Label status=new Label();
    	 public static Button btn2 =null;
    	 public static VBox root=new VBox();
    	 public static TilePane pane=new TilePane();

    public void start(Stage stage) throws Exception {

    	  //Creating a stage


    public static void initScene1(Stage stage){

    	Random rnd=new Random();

    	Button button[]=new Button[144];
    	for(int i=0;i<144;i++) {
    		button[i]=new Button("Spicy");
    		String txt=String.format("that is\"Spicy\"is.");

    		int number=rnd.nextInt(144);
			button[number]=new Button("Fortunately");
    		txt2=String.format("\"Fortunately\"Was clicked.");

    	pane=new TilePane();

    	root=new VBox();

    	scene1=new Scene(root);

    public static void initScene2(Stage stage) {

    	Button btn = new Button("Scene change completed! !! !!");
    	    btn.setOnMouseClicked(event -> setScene2(stage,scene1));

    	    AnchorPane root = new AnchorPane();
    	    scene2 = new Scene(root);


    public static void push(Stage stage) {
    	btn2 = new Button("next");
		btn2.setOnMouseClicked(event -> setScene(stage,scene2));

    public static  void setScene(Stage stage,Scene changeScene) {

    public static  void setScene2(Stage stage,Scene changeScene) {


Outline of the game and problems at this stage

A game that searches for one "good luck" button from a large number of "spicy" buttons. At the moment, I am struggling because the screen transition is not good. In the future, we have added a time limit and a counting function.


Recommended Posts

I tried to make a simple game with Javafx ① "Let's find happiness game" (unfinished)
I tried to make a group function (bulletin board) with Rails
A simple rock-paper-scissors game with JavaFX and SceneBuilder
I tried to break a block with java (1)
[Android] I tried to make a material list screen with ListView + Bottom Sheet
I tried to make a login function in Java
I want to make a function with kotlin and java!
Let's make a simple API with EC2 + RDS + Spring boot ①
I tried to make a client of RESAS-API in Java
I tried to create a padrino development environment with Docker
[Java] I tried to make a rock-paper-scissors game that beginners can run on the console.
I tried to interact with Java
Make a typing game with ruby
[Unity] I tried to make a native plug-in UniNWPathMonitor using NWPathMonitor
I tried to build a simple application using Dockder + Rails Scaffold
I tried to make an Android application with MVC now (Java)
I wanted to make JavaFX programming easier with the Spring Framework
[Java] I tried to make a maze by the digging method ♪
I made a virtual currency arbitrage bot and tried to make money
I tried playing with BottomNavigationView a little ①
I tried to make a talk application in Java using AI "A3RT"
I tried to make a program that searches for the target class from the process that is overloaded with Java
Let's create a TODO application in Java 2 I want to create a template with Spring Initializr and make a Hello world
[Java] I tried to connect using a connection pool with Servlet (tomcat) & MySQL & Java
I tried to automatically generate a class to convert from a data class to a Bundle with APT
I tried to clone a web application full of bugs with Spring Boot
[Small story] I tried to make the java ArrayList a little more convenient
[Android] I want to make QA easier ... That's right! Let's make a debug menu!
I wanted to make (a == 1 && a == 2 && a == 3) true in Java
I tried to create a LINE clone app
Let's make a search function with Rails (ransack)
I tried to link JavaFX and Spring Framework.
I tried to develop a website to record expenses.
I tried to implement a server using Netty
I tried to make a product price comparison tool of Amazon around the world with Java, Amazon Product Advertising API, Currency API (2017/01/29)
[Azure] I tried to create a Java application for free ~ Connect with FTP ~ [Beginner]
I tried to create a Clova skill in Java
I want to monitor a specific file with WatchService
Let's make a robot! "A simple demo of Java AWT Robot"
I tried to draw animation with Blazor + canvas API
I tried OCR processing a PDF file with Java
I tried to implement Stalin sort with Java Collector
Let's make a LINE Bot with Ruby + Sinatra --Part 1
I used to make nc (netcat) with JAVA normally
[Introduction to Android application development] Let's make a counter
I tried to find out what changed in Java 9
Implemented a strong API for "I want to display ~~ on the screen" with simple CQRS
Easy to make LINE BOT with Java Servlet Part 2: I tried image messages and templates
Make a simple CRUD with SpringBoot + JPA + Thymeleaf ① ~ Hello World ~
Learning Ruby with AtCoder 13 How to make a two-dimensional array
I tried to make Java Optional and guard clause coexist
I tried to link chat with Minecraft server with Discord API
[Rails] I tried to implement batch processing with Rake task
Even in Java, I want to output true with a == 1 && a == 2 && a == 3
I tried to convert a string to a LocalDate type in Java
I tried to implement a buggy web application in Kotlin
Make a simple CRUD with SpringBoot + JPA + Thymeleaf ⑤ ~ Template standardization ~
I tried OCR processing a PDF file with Java part2
I tried to get started with Swagger using Spring Boot
I tried to be able to pass multiple objects with Ractor