Replaced deprecated "hide()" with "setVisible(false)"