If "screen B" is simply a confirmation screen ("are you sure you want to log out"), I'd use a
modal dialog to prompt the user without leaving "screen A".
If "screen B" is a fully-featured screen, I'd use
Card Layout to flip between the screens without destroying them.