禁用分页动画 [英] Disable pagination animation

查看:174
本文介绍了禁用分页动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JavaFX禁用 Pagination 控件动画。我找不到有关如何做到这一点的任何确切信息。我知道有些控件有 setAnimated(false)方法,但是这个没有。

I'm trying to disable the Pagination control animation using JavaFX. I could not find any precise info on how to do that. I know some controls have the setAnimated(false) method, but this one doesn't.

也许有通过CSS样式或通过Skin界面的解决方案,但我是JavaFX的新手

Maybe there is a solution via CSS styling or via the Skin interface, but I'm kinda new to JavaFX

任何想法?

推荐答案

对于JavaFX 2.2,分页动画有点难以禁用。

For JavaFX 2.2, the pagination animation is going to be a little tough to disable.

如你所知,没有用于禁用动画的公共API(CSS中没有任何内容)。您需要创建自己的皮肤并将该皮肤分配给分页控件。

As you note there is no public API to disable the animation (and there isn't anything in CSS). What you will need to is create your own skin and assign that skin to the pagination control.

要执行此操作,请使用默认 JavaFX 2.2分页皮肤作为基础并编辑它以便它不做动画。如果将自定义分页皮肤重命名为另一个包(例如org.acme.javafx.scene.control.skin),则可以通过为应用程序分配css样式表来指定新皮肤,其中包括以下规则:

To do this use the default JavaFX 2.2 pagination skin as a base and edit it so that it doesn't do animations. If you rename your custom pagination skin to another package (e.g. org.acme.javafx.scene.control.skin), then you can specify that new skin via assigning a css stylesheet to your app which includes the following rule:

.pagination {
    -fx-skin: "org.acme.javafx.scene.control.skin.PaginationSkin";
}

除了新JavaFX用户的初始实施困难之外这种方法的另一个严重缺点是在JavaFX 2.2中,皮肤API不公开,所以当发布皮肤api公开的JavaFX 8时,你的更改可能不起作用,所以你需要重新编码它们JavaFX 8.您的更改将无法继续用于JavaFX 8的原因是 com.sun.javafx.scene.control.skin.SkinBase 类是您的自定义分页皮肤需要派生的东西会转移到类似 javafx.scene.control.skin.SkinBase 的东西,成为公共API。

Apart from the difficulty of initial implementation for a new JavaFX user (which is rather significant) another serious downside to this approach is that in JavaFX 2.2, the skin API is not public, so when JavaFX 8 is released where the skin api is public, your changes probably won't work, so you will need to recode them for JavaFX 8. The reason your changes won't continue to work for JavaFX 8 is that the com.sun.javafx.scene.control.skin.SkinBase class your custom pagination skin needs to derive from will have moved to something like javafx.scene.control.skin.SkinBase to become public API.

所以我建议现在和Pagination动画一起生活,除非你真的需要摆脱它。

So I'd suggest living with the Pagination animation for now unless you really need to get rid of it.

目前有一条针对 JavaFX运行时问题跟踪器的请求允许在Pagination控件中禁用动画。请参阅 RT-26439分页:页面翻转动画应该可以停用

There is currently a a request against the JavaFX runtime issue tracker to allow disabling animation in the Pagination control. See RT-26439 Pagination: Animation of page flip should be deactivatable.

这篇关于禁用分页动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆