Java API Performance

I am using the Java Preferences API to store the window position and size of a Swing application. At this moment, I am listening to window resize / resize events and to save position and size every time they change. However, this means that if the user slowly resizes the window with a width of 200px and a width of 400px, I will probably write a new window size about 200 times in a fairly short time.

Preferences The API uses the fact that the data store is available on the host system (Windows registry for Windows, etc.) - but the question is, what are the limitations or best practices of the API properties? Is everything all right, or would it be wise to write only when the user has finished resizing? Has anyone had experience with property APIs across platforms?

+3
source share
1 answer

Just re-read and understand that you are talking about the application itself and not about the dialogue, but the concept is probably still applied: record measurements only upon successful completion of the application. I think that would be great for most users / situations.


Why not write the new size only to the OK or Cancel event? That is, do not save it dynamically.

If it is modal, you will not lose anything by doing this; it is simply the final value that you want. Who cares if it was 307 px per millisecond?

+4
source

Source: https://habr.com/ru/post/1750487/


All Articles