我想使用JavaFX的创建每次显示图像 一个时间 一定的时间,我无法将图像获取循环或显示JavaFX的帧图像
的VBOX显示一个窗口空手而归
这是我在获得VBOX孩子最后一次尝试添加到VBOX
任何的想法?我一直停留在此的
package digitalframe;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;
import java.util.*;
import javafx.scene.image.Image;
import javafx.util.Duration;
import java.util.ArrayList;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
public class DigitalFrame extends Application {
@Override
public void start(Stage stage) throws Exception {
final ArrayList imageList = new ArrayList<>();
imageList.add(new ImageView("1.jpg"));
imageList.add(new ImageView("2.jpg"));
imageList.add(new ImageView("3.jpg"));
// Create the label and align its contents
final VBox vBox = new VBox();
vBox.setAlignment(Pos.CENTER);
// This is the keyframe handler.
class ImageHandler implements EventHandler<ActionEvent> {
@Override
public void handle(ActionEvent event) {
for (int n = 0; n > imageList.size(); n++) {
vBox.getChildren().add(new ImageView());
}
}
}
// Build the keyframe.
Duration sec = new Duration(1000);
ImageHandler image = new ImageHandler();
KeyFrame keyFrame = new KeyFrame(sec, image);
// Build the time line animation.
Timeline timeline = new Timeline(keyFrame);
timeline.setCycleCount(15);
// Set the stage and show, and play the animation
stage.setScene(new Scene(vBox, 250, 300));
stage.setTitle("Animation Counter");
stage.show();
timeline.playFromStart();
}
// @param args the command line arguments
public static void main(String[] args) {
launch(args);
}
}
您是否曾将ImageView与您加载的图像关联? – matt