changement vue + ajout taille grille

master
Yohann BREUIL 4 years ago
parent 90503842ed
commit 7cabe1fc32

@ -1,15 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.collections.FXCollections?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.shape.Rectangle?>
<BorderPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="FXML.VueJeu"
fx:controller="views.VueJeu"
prefHeight="400.0" prefWidth="600.0">
<top>
<VBox>
@ -22,11 +19,6 @@
<MenuItem text="License"/>
</Menu>
</MenuBar>
<HBox>
<Button>Play</Button>
<Button>Pause</Button>
<Button>Random</Button>
</HBox>
</VBox>
</top>
<right>
@ -40,14 +32,48 @@
<Label>3</Label> <CheckBox/>
<Label>4</Label> <CheckBox/>
</HBox>
<Label>Column</Label>
<Spinner fx:id="colGame" min="0" max="50"/>
<Label>Death</Label>
<HBox>
<Label>1</Label> <CheckBox/>
<Label>2</Label> <CheckBox/>
<Label>3</Label> <CheckBox/>
<Label>4</Label> <CheckBox/>
</HBox>
<HBox>
<Label> Rules </Label>
<ChoiceBox>
<items>
<FXCollections fx:factory="emptyObservableList">
</FXCollections>
</items>
</ChoiceBox>
</HBox>
<Label>Row</Label>
<Spinner fx:id="rowGame" min="0" max="50"/>
<TextField fx:id="rowGame" text="50"/>
<Label>Column</Label>
<TextField fx:id="colGame" text="50"/>
<HBox>
<!-- Bouton temporaire -->
<Button fx:id="createGrid" onAction="#initialize"> Create </Button>
</HBox>
<HBox>
<Button>Play</Button>
<Button>Pause</Button>
<Button>Random</Button>
</HBox>
</VBox>
</right>
<center>
<GridPane fx:id="map" hgap="2" vgap="2">
</GridPane>
</center>
<bottom>
<HBox>
<Label> Grid size : </Label>
<Label fx:id="nbRowGame"> </Label>
<Label> x </Label>
<Label fx:id="nbColGame"> </Label>
</HBox>
</bottom>
</BorderPane>

@ -1,26 +0,0 @@
package FXML;
import javafx.fxml.FXML;
import javafx.scene.control.Spinner;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Rectangle;
public class VueJeu {
@FXML
private GridPane map = new GridPane();
@FXML
private Spinner rowGame = new Spinner();
@FXML
private Spinner colGame = new Spinner();
public void initialize() {
for(int i=0; i<50; ++i){
for(int j=0; j<50; ++j) {
map.add(new Rectangle(10, 10, Paint.valueOf("#AABBCC")), i, j);
}
}
}
}

@ -9,8 +9,9 @@ import javafx.stage.Stage;
public class Launcher extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(this.getClass().getResource("/FXML/VueJeu.fxml"));
Parent root = FXMLLoader.load(this.getClass().getResource("/fxml/VueJeu.fxml"));
Scene sc = new Scene(root);
primaryStage.setTitle("Jeu de la vie");
primaryStage.setScene(sc);
primaryStage.show();

@ -0,0 +1,43 @@
package views;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.control.cell.TextFieldListCell;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Rectangle;
public class VueJeu {
@FXML
private GridPane map;
@FXML
private TextField rowGame;
@FXML
private TextField colGame;
@FXML
private Button createGrid;
@FXML
private Label nbRowGame;
@FXML
private Label nbColGame;
private void createGrid() {
for(int i=0; i < Integer.parseInt(rowGame.getText()); ++i){
for(int j=0; j < Integer.parseInt(colGame.getText()); ++j) {
map.add(new Rectangle(10, 10, Paint.valueOf("#AABBCC")), i, j);
}
}
}
public void initialize() {
createGrid();
nbColGame.setText(colGame.getText());
nbRowGame.setText(rowGame.getText());
}
}
Loading…
Cancel
Save