Mercurial > hg > Members > sugi > javafx
view src/alice/test/topology/aquarium/fx/AquariumController.java @ 1:b997f2ce1a04
add Controller Class
author | one |
---|---|
date | Sat, 26 Jan 2013 18:29:45 +0900 |
parents | |
children | 4930f8daf49d |
line wrap: on
line source
package alice.test.topology.aquarium.fx; import example.UpdateData; import javafx.fxml.FXML; import javafx.scene.control.TextField; import javafx.scene.image.ImageView; import javafx.scene.input.KeyEvent; import javafx.scene.shape.Rectangle; public class AquariumController { @FXML private Rectangle rect1; @FXML private Rectangle rect2; @FXML private TextField text; @FXML private ImageView image; public AquariumController(){ System.out.println("run app"); } @FXML public void PressedKey1(KeyEvent ke){ } @FXML public void PressedKey2(KeyEvent ke){ } @FXML public void PressedKey3(KeyEvent ke){ switch (ke.getCode()){ case RIGHT: new UpdateData("image1", new FishData(image.getTranslateX()+10,image.getTranslateY(),image.getTranslateZ())).execute(); // rect1.setTranslateX(rect1.getTranslateX()+10.0); break; case LEFT: new UpdateData("image1", new FishData(image.getTranslateX()-10,image.getTranslateY(),image.getTranslateZ())).execute(); // rect1.setTranslateX(rect1.getTranslateX()-10.0); break; case UP: new UpdateData("image1", new FishData(image.getTranslateX(),image.getTranslateY()-10,image.getTranslateZ())).execute(); // rect1.setTranslateY(rect1.getTranslateY()-10.0); break; case DOWN: new UpdateData("image1", new FishData(image.getTranslateX(),image.getTranslateY()+10,image.getTranslateZ())).execute(); // rect1.setTranslateY(rect1.getTranslateY()+10.0); break; default: break; } } }