package fx;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.scene.Group;
import javafx.scene.image.Image;
import javafx.scene.canvas.Canvas;
import javafx.scene.image.PixelReader;
import javafx.scene.paint.Color;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.input.MouseEvent;
public class pro extends Application {
Canvas cam;
GraphicsContext gc;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
cam = new Canvas(500,500);
gc = cam.getGraphicsContext2D();
Image im= new Image("file:1.jpg");
gc.drawImage(im, 40.0, 40.0);
cam.addEventFilter(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
System.out.println("rr");
}
});
Group root = new Group();
Scene scene = new Scene(root, 700, 700);
root.getChildren().add(cam);
stage.setTitle("練習");
stage.setScene(scene);
stage.show();
}
}
最終更新:2014年04月27日 05:24