Removing a window will not clear its child text components. Dispose will release its own resources. The javadoc for java.awt.Window also states:
A window and its subcomponents can be displayed again by restoring their own resources and then calling pack or show. The status of the updated window and its subcomponents will be identical to the states of these objects at the point where the Window was located (not taking into account additional changes between these actions).
As suggested by others, create a new instance each time instead. If it's expensive, I think your best option is to clear the subcomponents when the view becomes visible, for example. by overriding setVisible .
EDIT: Remove the zero check to create a new frame each time.
@Action public void showAddProductToOrderView() { addProductToOrderView = new AddProductToOrderView(this); addProductToOrderView.setVisible(true); }
I don't know about the rest of your code if there is anything else depending on which frame is being reused. For example, if you connected listeners, make sure they are unregistered so as not to miss them.
source share