简体   繁体   English

Java首选项API吞吐量

[英]Java preferences API throughput

I'm using Java Preferences API to store window position and size of Swing application. 我正在使用Java Preferences API来存储Swing应用程序的窗口位置和大小。 At this moment, I'm listening to window resize/reposition events and storing the position and size every time they change. 此时,我正在收听窗口调整大小/重新定位事件,并在每次更改时存储位置和大小。 However, that means that if user slowly resizes window which is 200px wide to 400px wide, I'll probably write new window size about 200 times during pretty short time. 但是,这意味着如果用户慢慢调整宽度为200px到400px的窗口,我可能会在相当短的时间内写入大约200次的新窗口大小。

Preferences API uses whichever datastore is available on the host system (windows registry for Windows etc.) - but the question is, what are limitations or best practices for properties API? Preferences API使用主机系统上可用的任何数据存储区(适用于Windows的Windows注册表等) - 但问题是,属性API有哪些限制或最佳实践? Is it OK, or would it be smart to write only when user has finished resizing? 是否可以,或者只有在用户完成调整大小时才能写出来? Anyone had experiences with Properties API on different platforms? 任何人都有不同平台上的Properties API经验?

Just re-read and realised you're talking about the app itself not a dialog, but the concept probably still applies: record the dimensions only on successful application shutdown. 只是重新阅读并意识到你在谈论应用程序本身而不是对话框,但这个概念可能仍然适用:仅在成功关闭应用程序时记录维度。 I think this would be perfectly fine for most users / situations. 我认为这对大多数用户/情况来说都是完美的。


Why not record the new size only on "OK" or "Cancel" button event? 为什么不在“确定”或“取消”按钮事件中记录新尺寸? Ie don't store it dynamically. 即不动态存储它。

If it's modal, you cannot lose anything by doing this, it's just the final value you want. 如果它是模态的,你不能通过这样做失去任何东西,它只是你想要的最终价值。 Who cares if it was 307 px for a millisecond? 谁在乎它是否是307 px一毫秒?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM