Advertisement
rsvaco

ipc bolita

Feb 21st, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.85 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package pract01;
  7.  
  8. import java.net.URL;
  9. import java.util.ResourceBundle;
  10. import javafx.event.ActionEvent;
  11. import javafx.fxml.FXML;
  12. import javafx.fxml.Initializable;
  13. import javafx.scene.control.Label;
  14. import javafx.scene.input.*;
  15. import javafx.scene.layout.GridPane;
  16. import javafx.scene.shape.Circle;
  17.  
  18. /**
  19.  *
  20.  * @author anal13a
  21.  */
  22. public class FXMLDocumentController implements Initializable {
  23.    
  24.     private Label label;
  25.     @FXML
  26.     private Circle circle;
  27.     @FXML
  28.     private GridPane pane;
  29.    
  30.     private void handleButtonAction(ActionEvent event) {
  31.         System.out.println("You clicked me!");
  32.         label.setText("Hello World!");
  33.     }
  34.    
  35.     @Override
  36.     public void initialize(URL url, ResourceBundle rb) {
  37.         // TODO
  38.        
  39.        
  40.     }    
  41.  
  42.     @FXML
  43.     private void handleTecla(KeyEvent event) {
  44.        
  45.             switch (event.getCode()) {
  46.         case UP:
  47.             moveUp();
  48.             break;
  49.         case RIGHT:
  50.             moveRight();
  51.             break;
  52.         case DOWN:
  53.             moveDown();
  54.             break;
  55.         case LEFT:
  56.             moveLeft();
  57.             break;
  58.     }
  59.     }
  60.    
  61.     private void moveUp() {
  62.         GridPane.setRowIndex(circle, GridPane.getRowIndex(circle) - 1);
  63.        
  64.     }
  65.  
  66.     private void moveLeft() {
  67.         GridPane.setColumnIndex(circle, GridPane.getColumnIndex(circle) - 1);
  68.        
  69.     }
  70.  
  71.     private void moveRight() {
  72.         GridPane.setColumnIndex(circle, GridPane.getColumnIndex(circle) + 1);
  73.        
  74.     }
  75.  
  76.     private void moveDown() {
  77.         GridPane.setRowIndex(circle, GridPane.getRowIndex(circle) + 1);
  78.        
  79.     }
  80.    
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement