In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces JavaFx how to achieve button anti-shake function, has a certain reference value, interested friends can refer to, I hope you have a lot of harvest after reading this article, let Xiaobian take you to understand.
JavaFX
JavaFX is an open source, next-generation client application platform for Java-based desktop, mobile, and embedded systems. It is the result of a concerted effort by many individuals and companies to provide a modern, efficient, and fully functional toolkit for developing rich client applications.
javafx Chinese website
Android platform APP, generally there is a need to set the button anti-shake (that is, in a short period of time can not be clicked multiple times), I want to JavaFx project is also to achieve anti-shake function, is to study the next
realization principle
Before clicking the button, record the current click time. When the button is clicked next time, calculate with the previously recorded click time and judge whether the interval time between the two is greater than the set condition value.
Here the idea is not difficult, mainly click on the history of time how to record? there are several ways
Use Map storage (too many buttons take up a lot of resources)
Use one of the useless fields provided by the control object for storage
In Android, you can save information using tags in View.
In JavaFx, all controls have userData fields, with this, we can store time
Implementation code Kotlin version:
kotlin version I am using the extension method, the BUtton class has been extended, do not understand the extension method can check the information, simply put, that is, to the Button class added a method
//Note Button is fun Button of javafx package.isFastClick(): Boolean { val lastClickTime = userData as Long? val currentTime = System.currentTimeMillis() userData = currentTime //Here I set it to invalid multiple clicks within 1s, which can be adjusted as needed if (lastClickTime != null && currentTime - lastClickTime
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.