My program displays some windows (jframe and jpanel) on the screen and a main frame. When the user select the option to delete one of these windows in the main frame, it should close the selected window.
I have those windows in an array. When the user select the window to close, it will erase that jframe and it's jpanel from the array and it should close that jframe, but it doesn't. There are no errors showned and when I run the program again, everything is as it is suposed to be: the deleted frame isn't showed. My conclusion is i'm not working correctly with closing the jframe, and the rest of the program is fine.
i have tried:
windows[Frame_to_close].setDefaultCloseOperation(windows[Frame_to_close].DISPOSE_ON_CLOSE );
and
windows[Frame_to_close].setVisible(false);
windows[Frame_to_close].dispose();
Am I doing anything wrong when closing the window? Is there any other way of closing a window(Jframe and Jpanel)?