package teump;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import java.io.File;
import javafx.scene.input.MouseEvent;
public class pro extends Application {
ImageView[] imv = new ImageView[52];
Image[] im = new Image[52];
int s,number;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
File fx=new File("data");
String[] f=fx.list();
for(s=0;s<52;s++){
im[s]= new Image("file:data/"+f[s]);
}
for(s=1;s<6;s++){
imv[s] = new ImageView();
imv[s].setImage(im[s]);
imv[s].setFitWidth(80);
imv[s].setFitHeight(80);
imv[s].setX(100*s);
imv[s].setY(200);
}
Group root = new Group();
Scene scene = new Scene(root, 700, 700);
for(s=1;s<6;s++){
root.getChildren().add(imv[s]);
}
Button btn = new Button();
btn.setText("左");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("f");
}
});
btn.setLayoutX(300);
btn.setLayoutY(650);
root.getChildren().add(btn);
imv[1].addEventFilter(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
imv[1].setImage(im[30]);
}
});
imv[2].addEventFilter(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
imv[2].setImage(im[40]);
}
});
primaryStage.setTitle("トランプ");
primaryStage.setScene(scene);
primaryStage.show();
}
}
最終更新:2014年04月26日 18:57