Advertisement
Guest User

l

a guest
May 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.64 KB | None | 0 0
  1. import javafx.application.Application;
  2. import javafx.collections.ObservableList;
  3. import javafx.event.EventHandler;
  4. import javafx.geometry.Pos;
  5. import javafx.scene.*;
  6. import javafx.scene.layout.GridPane;
  7. import javafx.scene.paint.Color;
  8. import javafx.scene.shape.Circle;
  9. import javafx.geometry.Insets;
  10. import javafx.scene.shape.Rectangle;
  11. import javafx.scene.text.Text;
  12. import javafx.stage.Stage;
  13. import javafx.scene.input.MouseEvent;
  14.  
  15. public class Main extends Application {
  16.  
  17.     @Override
  18.     public void start(Stage primaryStage) throws Exception{
  19.         Group g = new Group();
  20.         //Node super di quasi tutto FX
  21.         ObservableList <Node> lista_gruppo=g.getChildren();
  22.  
  23.  
  24.         //commandi abbastanza intuibili
  25.         GridPane gridPane=new GridPane();
  26.         gridPane.setMinSize(600,600);
  27.         gridPane.setAlignment(Pos.CENTER);
  28.         for (int i=0;i<10;i++){
  29.             for(int j=0;j<10;j++){
  30.                 Rectangle rettangolo = new Rectangle();
  31.                 rettangolo.setWidth(5);
  32.                 rettangolo.setHeight(5);
  33.                 rettangolo.setOnMouseClicked((MouseEvent event)->rettangolo.setFill(Color.GRAY));
  34.                 rettangolo.setFill(Color.BLUE);
  35.                 gridPane.add(rettangolo,i,j);
  36.             }
  37.         }
  38.  
  39.         lista_gruppo.add(gridPane);
  40.         //lista_gruppo.add(cerchio);
  41.         Scene scene = new Scene(g,1920, 1000);
  42.         scene.setFill(Color.AQUAMARINE);
  43.  
  44.         primaryStage.setTitle("Hello word again");
  45.         primaryStage.setScene(scene);
  46.         primaryStage.show();
  47.     }
  48.  
  49.     public static void main(String[] args) {
  50.         launch(args);
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement