Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save window geometry between sessions #146

Closed
omadawn opened this issue Sep 14, 2012 · 2 comments
Closed

Save window geometry between sessions #146

omadawn opened this issue Sep 14, 2012 · 2 comments
Assignees
Milestone

Comments

@omadawn
Copy link
Owner

omadawn commented Sep 14, 2012

There's a cool hack here:
http://codeidol.com/java/swing/Windows,-Dialogs,-and-Frames/Save-Window-Settings/

He has you implement a new class and then talk to it. I have the class created. I need to do two things one
registering to the global toolkit
Toolkit tk = Toolkit.getDefaultToolkit( );
tk.addAWTEventListener(WindowSaver.getInstance( ),
AWTEvent.WINDOW_EVENT_MASK);

which might need to be done on both the windowsaver and the main code but I'm not sure.

And b adding a save geometry call to windowsaver in my quit event.
I'm not going to add this actual Quit item but simply modify what I'm already doing on shutdown.
menu.add(new AbstractAction("Quit") {
public void actionPerformed(ActionEvent evt) {
try {
WindowSaver.saveSettings( );
System.exit(0);
} catch (Exception ex) {
System.out.println(ex);
}

             }
         });
@omadawn
Copy link
Owner Author

omadawn commented Sep 14, 2012

Why is this hard. The article above is implemented and works... mostly.
but it's awkward. For example if you maximize, quit and open the window opens at the same geometry that it used to be. NOT maximized. Which means that you actuallly loose one little line around the edge of the screen which A) looks pretty silly and B) WILL cause a problem later I can guarantee it.

Investigating some other solutions. One option:
Swing Application Framework
http://java.sun.com/developer/technicalArticles/javase/swingappfr/

Another article similar to the first(main body of the taks) but without doing annoying things like not telling you what libraries you need to import.
http://www.onyxbits.de/content/blog/patrick/saving-preferences-jtoolbar-location-and-window-geometry

It looks like a pretty similar mechanism though so I'm not sure it won't have the same 'full screen' issue.

@ghost ghost assigned omadawn Sep 14, 2012
@omadawn
Copy link
Owner Author

omadawn commented Sep 22, 2012

Done, and done correctly.

@omadawn omadawn closed this as completed Sep 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant