tags:

views:

70

answers:

2

In my application I've a main shell window and lots of dialogs (classes extends Dialog). I use setSize(width,height) when initializing them, but I know that users constantly resize them for their taste.

What is a smarty way to get notified when the size changes so I can store/load them?

(And why don't do toolkit provide such a thing out of the box, like XUL?)

+1  A: 

Take a look at java.util.prefs.Preferences. The width and height settings can be saved via putInt() and retrieved via getInt().

It would be a pretty minor task to subclass Dialog or JDialog and create a SizeRememberingDialog, or (probably better) to create a SizeRememberer(Dialog) class to set the size when constructed, listen for resize events, and save the new size whenever a resize occurs.

Marty Lamb
+1  A: 

Most if not all GUI toolkits have a resize event that triggers whenever the user (or something else) resizes a given widget. Some readong for an example Moving and resizing - SWT

Zuu
Exactly what I needed, thanks!
mark