forked from 11sloe/Snake
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.java
More file actions
43 lines (35 loc) · 1.18 KB
/
App.java
File metadata and controls
43 lines (35 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.Parent;
import javafx.scene.input.KeyEvent;
public class App extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
// Darstellung als fxml-Datei
FXMLLoader loader = new FXMLLoader(getClass().getResource("view.fxml"));
Parent root = loader.load();
// der zugehörige Controller wird geladen
Controller controller = loader.getController();
// Fenster erstellen und anzeigen
Scene scene = new Scene(root);
scene.setOnKeyPressed((KeyEvent ke) -> {
controller.gedrueckt(ke);
});
/*
scene.setOnKeyReleased((KeyEvent ke) -> {
controller.losgelassen(ke);
});
*/
//scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.setTitle("SNAKE");
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
public void steuerungEinrichten(){
}
}