アットウィキロゴ

javafx 2

package neko;
 
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.scene.shape.Circle;
 
import javafx.scene.paint.Color;
  import javafx.scene.text.*;
 
public class pro extends Application {
 
    Text[][] maru=new Text[9][9];
    int[][] point=new int[9][9]; 
 int s,sx;
 
 int px,py;
 
 
    public static void main(String[] args) {
        launch(args);
    }
 
 
    @Override
    public void start(Stage primaryStage) {
 
 
        px=5;
        py=5;
 
 
        for(s=1;s<9;s++){
        for(sx=1;sx<9;sx++){
        maru[s][sx]=new Text("abc");
        maru[s][sx].setLayoutX(50*s);
        maru[s][sx].setLayoutY(50*sx);   
        }
        }
 
          for(s=1;s<9;s++){
        for(sx=1;sx<9;sx++){
        point[s][sx]=0;
        }
          }
        Button btn1 = new Button();
        btn1.setText("左");
        btn1.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                px=px-1;
                if(px<1)px=1;
             maru[px][py].setText("a");
 
            }
        });
       btn1.setLayoutX(150);
btn1.setLayoutY(650); 
 
 
 
      Button btn2 = new Button();
        btn2.setText("上");
        btn2.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                px=px-1;
                if(px<1)px=1;
             maru[px][py].setText("a");
            }
        });
btn2.setLayoutX(200);
btn2.setLayoutY(650);
 
 Button btn3 = new Button();
        btn3.setText("決定");
        btn3.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
              px=px-1;
                if(px<1)px=1;
             maru[px][py].setText("a");
            }
        });
       btn3.setLayoutX(250);
btn3.setLayoutY(650); 
 
 
 
      Button btn4 = new Button();
        btn4.setText("下");
        btn4.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
 
                  px=px-1;
                if(px<1)px=1;
             maru[px][py].setText("a");
 
            }
        });
btn4.setLayoutX(300);
btn4.setLayoutY(650);
 
Button btn5 = new Button();
        btn5.setText("右");
        btn5.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
           px=px-1;
                if(px<1)px=1;
             maru[px][py].setText("a");
 
            }
        });
btn5.setLayoutX(350);
btn5.setLayoutY(650);
 
 
 
Group root = new Group();
Scene scene = new Scene(root, 700, 700); 
root.getChildren().add(btn1);
root.getChildren().add(btn2);
 root.getChildren().add(btn3);
root.getChildren().add(btn4);
root.getChildren().add(btn5);
 
for(s=1;s<9;s++){
        for(sx=1;sx<9;sx++){
root.getChildren().add(maru[s][sx]);
        }
}
 
        primaryStage.setTitle("Button");
        primaryStage.setScene(scene);
        primaryStage.show();
    }
 
 
}
最終更新:2014年03月19日 22:47