Created listeners to save window position as preferences and use them on restart