new progress , succeded in moving the node with the mouse still not
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
finished tho
This commit is contained in:
parent
5911d88918
commit
895b20b680
@ -1,11 +1,14 @@
|
|||||||
package application;
|
package application;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
|
import javafx.scene.Node;
|
||||||
import javafx.event.Event;
|
import javafx.event.Event;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.scene.Group;
|
import javafx.scene.Group;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.Cursor;
|
||||||
import javafx.scene.input.KeyEvent;
|
import javafx.scene.input.KeyEvent;
|
||||||
import javafx.scene.input.KeyCode;
|
import javafx.scene.input.KeyCode;
|
||||||
|
import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.shape.Polygon;
|
import javafx.scene.shape.Polygon;
|
||||||
import javafx.scene.transform.Rotate;
|
import javafx.scene.transform.Rotate;
|
||||||
@ -14,6 +17,8 @@ import javafx.stage.Stage;
|
|||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
public class Piece extends Application{
|
public class Piece extends Application{
|
||||||
|
|
||||||
|
double x;
|
||||||
|
double y;
|
||||||
public void start(Stage primaryStage) throws Exception {
|
public void start(Stage primaryStage) throws Exception {
|
||||||
|
|
||||||
Polygon piece1 = new Polygon();
|
Polygon piece1 = new Polygon();
|
||||||
@ -57,6 +62,42 @@ public class Piece extends Application{
|
|||||||
rotatelft.setNode(piece1);
|
rotatelft.setNode(piece1);
|
||||||
rotatelft.setAxis(Rotate.Z_AXIS);
|
rotatelft.setAxis(Rotate.Z_AXIS);
|
||||||
|
|
||||||
|
/* */
|
||||||
|
|
||||||
|
piece1.setOnMousePressed(new EventHandler<MouseEvent>() {
|
||||||
|
@Override public void handle(MouseEvent mouseEvent) {
|
||||||
|
// record a delta distance for the drag and drop operation.
|
||||||
|
x = piece1.getLayoutX() - mouseEvent.getSceneX();
|
||||||
|
y = piece1.getLayoutY() - mouseEvent.getSceneY();
|
||||||
|
piece1.setCursor(Cursor.CLOSED_HAND);
|
||||||
|
piece1.setFill(Color.AZURE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
piece1.setOnMouseReleased(new EventHandler<MouseEvent>() {
|
||||||
|
@Override public void handle(MouseEvent mouseEvent) {
|
||||||
|
piece1.setCursor(Cursor.HAND);
|
||||||
|
piece1.setFill(Color.LIMEGREEN);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
piece1.setOnMouseDragged(new EventHandler<MouseEvent>() {
|
||||||
|
@Override public void handle(MouseEvent mouseEvent) {
|
||||||
|
piece1.setLayoutX(mouseEvent.getSceneX() + x);
|
||||||
|
piece1.setLayoutY(mouseEvent.getSceneY() + y);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
piece1.setOnMouseEntered(new EventHandler<MouseEvent>() {
|
||||||
|
@Override public void handle(MouseEvent mouseEvent) {
|
||||||
|
piece1.setCursor(Cursor.HAND);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
|
scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
|
||||||
@ -72,9 +113,26 @@ public class Piece extends Application{
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*public void pressed(MouseEvent event, Polygon piece1) {
|
||||||
|
piece1.setFill(Color.AZURE);
|
||||||
|
int x = piece1.getLayoutX() - MouseEvent.getSceneX();
|
||||||
|
int y = piece1.getLayoutY() - MouseEvent.getSceneY();
|
||||||
|
piece1.setCursor(Cursor.MOVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dragged(MouseEvent event, Polygon piece1) {
|
||||||
|
piece1.setLayoutX(event.getSceneX()+ x);
|
||||||
|
piece1.setLayoutY(event.getSceneY()+ y);
|
||||||
|
piece1.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void released(MouseEvent event, Polygon piece1) {
|
||||||
|
piece1.setCursor(Cursor.HAND);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
launch(args);
|
launch(args);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user