Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
757 views
in Technique[技术] by (71.8m points)

javafx - Disable pagination animation

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.

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

Any ideas?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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.

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";
}

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.

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...