最近我开发了一个个人软件来帮助我完成我的日程安排。我试图让荷马辛普森的闪屏吃饭,作为一个很酷的启动闪屏,但不幸的是,GIF不会播放。JavaFX Splash场景与GIF
这里是整个代码
public class Homer extends Application
{
public static final String SPLASH_GIF =
"https://media.giphy.com/media/JRQ1PegFVKXBu/giphy.gif";
private static final int SPLASH_WIDTH = 400;
private static final int SPLASH_HEIGHT = 224;
private Pane splashLayout;
public static void main(String[] args) throws Exception
{ launch(args); }
@Override
public void start(final Stage initStage) throws Exception {
ImageView splash = new ImageView(new Image(
SPLASH_GIF
));
splashLayout = new Pane();
splashLayout.getChildren().add(splash);
Scene scene = new Scene(splashLayout, SPLASH_WIDTH, SPLASH_HEIGHT);
scene.setFill(Color.TRANSPARENT);
initStage.initStyle(StageStyle.TRANSPARENT);
initStage.setWidth(SPLASH_WIDTH);
initStage.setHeight(SPLASH_HEIGHT);
initStage.setScene(scene);
initStage.show();
System.out.println("finished");
}
}
具有画面格式转换到PNG为下面的工作
public static final String SPLASH_GIF =
"http://www.dashboardwidgets.com/showcase/data/43/homerQuotes-1p2f.png";
这将导致在荷马的只是一个简单的图片,不吃香蕉。我想用GIF来制作它。
怎么可能?
请编辑问题并将gif添加到问题中。如果它与PNG一起工作,它也应该“与gif一起工作”。所以只要JavaFX正确理解你的特定gif文件格式(它应该......),它就应该可以工作。我不知道你是否在阻止gif动画运行的JavaFX应用程序线程上做其他工作。要确定任何加载格式失败,可以将侦听器添加到图像错误和异常属性,并使用System.out调试例程输出其值。 – jewelsea
@jewelsea我已经完成了原始帖子中的问题仍然存在的孤立代码示例。 –