public void onAddToTaskBar(PropertyChangeEvent evt) {
if (window == null)
return;
if (window.isVisible()) {
FloatingWindow oldWindow = window;
// Clean
uninstallWindowListeners();
descriptor.removeFloatingWindow();
Component focusOwner = oldWindow.getWindow().getFocusOwner();
oldWindow.setVisible(false);
// Reinit window
reinitWindow(oldWindow);
// Dispose old
oldWindow.getWindow().dispose();
// Show new
window.setVisible(true);
if (focusOwner != null)
SwingUtil.requestFocus(focusOwner);
} else {
FloatingWindow oldWindow = window;
// Clean old window
uninstallWindowListeners();
descriptor.removeFloatingWindow();
// Finalize clean
oldWindow.getWindow().dispose();
}
}