Begin javafx
This commit is contained in:
parent
f281a7189c
commit
5446859dee
17 changed files with 681 additions and 103 deletions
|
@ -1,14 +1,44 @@
|
|||
package app;
|
||||
|
||||
/**
|
||||
* Created by loic on 21/09/16.
|
||||
*/
|
||||
public class Application {
|
||||
import adapter.ModelAdapter;
|
||||
import controller.MainWindowController;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.stage.Stage;
|
||||
import model.Board;
|
||||
import model.IModel;
|
||||
import observer.IObserver;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class Application extends javafx.application.Application{
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(Application.class.getClassLoader().getResource("JavafxView/MainWindow.fxml"));
|
||||
Scene scene=new Scene((Parent)fxmlLoader.load());
|
||||
|
||||
primaryStage.setTitle("2048");
|
||||
primaryStage.setScene(scene);
|
||||
|
||||
|
||||
// COnfigure controller
|
||||
IModel model=new Board(4,4);
|
||||
ModelAdapter adapter=new ModelAdapter((Board) model);
|
||||
adapter.addRandomNumber();
|
||||
MainWindowController controller=fxmlLoader.getController();
|
||||
adapter.addObserver((IObserver)controller);
|
||||
controller.loadComponent(adapter,model,scene);
|
||||
|
||||
|
||||
public static void main(String[] args){
|
||||
System.out.println("Test");
|
||||
primaryStage.show();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue