Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package pract01;
- import java.net.URL;
- import java.util.ResourceBundle;
- import javafx.event.ActionEvent;
- import javafx.fxml.FXML;
- import javafx.fxml.Initializable;
- import javafx.scene.control.Label;
- import javafx.scene.input.*;
- import javafx.scene.layout.GridPane;
- import javafx.scene.shape.Circle;
- /**
- *
- * @author anal13a
- */
- public class FXMLDocumentController implements Initializable {
- private Label label;
- @FXML
- private Circle circle;
- @FXML
- private GridPane pane;
- private void handleButtonAction(ActionEvent event) {
- System.out.println("You clicked me!");
- label.setText("Hello World!");
- }
- @Override
- public void initialize(URL url, ResourceBundle rb) {
- // TODO
- }
- @FXML
- private void handleTecla(KeyEvent event) {
- switch (event.getCode()) {
- case UP:
- moveUp();
- break;
- case RIGHT:
- moveRight();
- break;
- case DOWN:
- moveDown();
- break;
- case LEFT:
- moveLeft();
- break;
- }
- }
- private void moveUp() {
- GridPane.setRowIndex(circle, GridPane.getRowIndex(circle) - 1);
- }
- private void moveLeft() {
- GridPane.setColumnIndex(circle, GridPane.getColumnIndex(circle) - 1);
- }
- private void moveRight() {
- GridPane.setColumnIndex(circle, GridPane.getColumnIndex(circle) + 1);
- }
- private void moveDown() {
- GridPane.setRowIndex(circle, GridPane.getRowIndex(circle) + 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement