开发者

Swing Application Framework does not save program's session (window postition, size etc.) in Linux

I'm developing a tiny app in Java using Swing and Swing Application Framework (JSR 296). It should work under Windows and Linux.

In Windows XP session (window postition, size etc.) is saved, but in Linux it is not! Program extends SingleFrameApplication. It should save window position automatically. No additional code was written for that. I traced framework sources but didn't find anything wrong. Session storage must save window state into .MyApp dir in home folder. The file is not present there. I have some user parameters which I save into xml manually using java properties, not session storage! This file is saved without any problems into .MyApp dir in home folder!

Does anybody know why program does not save its state in Linux but in Windows it does?

SOLVED: The reason was OpenJDK is incom开发者_C百科patible with SAF. After I removed OpenJDK and installed JDK from Oracle windows became to save & restore theirs positions and dimensions.


First of all there is an active community around Better Swing Application Framework. () It could be helpful to send your question there, or even better create a new ticket in issue tracker with full definition of you environment and extracts of your code.

In the mean time try to use your application with SUN/Oracle JRE/JDK 6. Because SAF is not tested on Open JDK and it has an issue with JDK7. (Different implementation of XMLEncoder/XMLDecoder).

I hope it was helpful.


Linux uses its own WindowManager, so it's up to the OS to decide where the window goes. If you want to override it, you need to save the window's size and location to a Properties object and put it somewhere when you exit, loading it again when you restart. Or, you can simply call setLocationRelativeTo(null) to always have the window centered on the screen.

If you're already using Properties, but it's not saving where you expected, you might need to debug it or check your environment variables.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜