When the button is clicked, besides showing B
you should call "setVisible(false)" on A. That will hide it.
Add an InternalFrameListener to B; extend InternalFrameAdapter for ease. Override "internalFrameClosed", and in it call "setVisible(true)" on A. That will show it again.