title: moving an image with arrows in JAVAFX
body: <p>Iam working on a small game here, and I am trying to move an image using right and left arrows.</p>
  
  <p>The image has been declared as an ImageView as you will see in the attached code.. </p>
  
  <p>feel free to correct me as much as you want!!</p>
  
  <pre><code>package wordsfalling;
  
      import java.*; 
      import java.net.URL;  
      import java.util.*;
      import java.util.ResourceBundle; 
      import javafx.event.*; 
      import javafx.event.EventHandler; 
      import javafx.fxml.*; 
      import javafx.fxml.Initializable; 
      import javafx.scene.image.ImageView;
      import javafx.scene.input.KeyCode; 
      import javafx.scene.input.KeyEvent; 
      import javafx.scene.input.*; 
      import javafx.scene.*; 
  
  /**  * FXML Controller class  * 
        * @author ad  */
  
        public class WordsFallingFXMLController implements Initializable {
  
          @FXML
          private ImageView bar;
  
         // char [] alphapet = "ABCDEFGHIKLMNOPQRSTUVWXYS".toCharArray();
  
  
          public void initialize(URL url, ResourceBundle rb) {
  
  
  
              bar.setOnKeyPressed(new EventHandler&lt;KeyEvent&gt;()
          {
              @Override
              public void handle(KeyEvent ke)
              {
                  if (ke.getCode().equals(KeyCode.RIGHT))
                  {
                      bar.setX(4);
                  }
              }
          }
              );
  
          } }
  </code></pre>
  
  <p>i have also treid to modify and implement this 
  <a href="https://stackoverflow.com/questions/22014950/javafx-moving-image-with-arrow-keys-and-spacebar">JavaFX: Moving image with arrow keys and spacebar</a></p>
  
  <p>but it didnt work !!</p>
  
  <p>any suggestions ?</p>
  
  <p>thanks in advance</p>