Buggy code:
public class MojamComponent extends Canvas implements ButtonListener , CommandListener , PacketListener , KeyListener , MouseListener , MouseMotionListener , Runnable { private static final long serialVersionUID = 1L ; public static final int GAME_WIDTH = 512 ; public static final int GAME_HEIGHT = ( ( MojamComponent . GAME_WIDTH ) * 3 ) // 4 ; public static final int SCALE = 2 ; private boolean running = true ; private Cursor emptyCursor ; private double framerate = 60 ; private int fps ; private Screen screen = new Screen ( MojamComponent . GAME_WIDTH , MojamComponent . GAME_HEIGHT ) ; private Level level ; private Stack < GuiMenu > menuStack = new Stack < GuiMenu > ( ) ; private boolean mouseMoved = false ; private boolean mouseHidden = false ; private int mouseHideTime = 0 ; public MouseButtons mouseButtons = new MouseButtons ( ) ; public Keys keys = new Keys ( ) ; public Keys [ ] synchedKeys ; public Player [ ] players ; private int numPlayers = 1 ; public Player player ; public TurnSynchronizer synchronizer ; private PacketLink packetLink ; private ServerSocket serverSocket ; private static boolean isMultiplayer ; private boolean isServer ; private int localId ; private Thread hostThread ; public static SoundPlayer soundPlayer ; private static boolean bPaused ; private boolean bPauseMenuUp ; private int createServerState = 0 ; public MojamComponent ( ) { } public void mouseDragged ( MouseEvent arg0 ) { } public void mouseMoved ( MouseEvent arg0 ) { } public void mouseClicked ( MouseEvent e ) { } public void mouseEntered ( MouseEvent e ) { } public void mouseExited ( MouseEvent e ) { } public void mousePressed ( MouseEvent e ) { } public void mouseReleased ( MouseEvent e ) { } public void paint ( Graphics g ) { } public void update ( Graphics g ) { } public void start ( ) { } public void stop ( ) { } public static void togglePause ( ) { } private void init ( ) { } private synchronized void createLevel ( ) { } public void run ( ) { } private synchronized void render ( Graphics g ) { } private void tick ( ) { } public static void main ( String [ ] args ) { } public void handle ( int playerId , NetworkCommand packet ) { } public void handle ( Packet packet ) { if ( packet instanceof StartGamePacket ) { if ( ! ( isServer ) ) { menuStack . clear ( ) ; StartGamePacket tmp = ( ( StartGamePacket ) ( packet ) ) ; synchronizer . onStartGamePacket ( tmp ) ; numPlayers = tmp . getNumPlayers ( ) ; localId = tmp . getLocalId ( ) ; createLevel ( ) ; } } else if ( packet instanceof TurnPacket ) { TurnPacket tmp = ( ( TurnPacket ) ( packet ) ) ; if ( isServer ) ( ( MultiplePacketLink ) ( packetLink ) ) . sendPacketExcept ( packet , tmp . getPlayerId ( ) ) ; synchronizer . onTurnPacket ( tmp ) ; } else if ( packet instanceof JoinPacket ) { if ( ( menuStack . peek ( ) ) instanceof JoinWaitMenu ) { ( ( JoinWaitMenu ) ( menuStack . peek ( ) ) ) . numPlayers = ( ( JoinPacket ) ( packet ) ) . getNumPlayers ( ) ; } } else if ( packet instanceof PartPacket ) { <START_BUG> if ( ! ( isServer ) ) { <END_BUG> if ( ( menuStack . peek ( ) ) instanceof JoinWaitMenu ) { JoinWaitMenu menu = ( ( JoinWaitMenu ) ( menuStack . peek ( ) ) ) ; menu . numPlayers = 0 ; menu . message = ( ( PartPacket ) ( packet ) ) . getMessage ( ) ; if ( ( packetLink ) != null ) { packetLink . sendPacket ( new PartPacket ( ) ) ; packetLink = null ; } } } } } public void gameDisconnect ( ) { } public void buttonPressed ( Button button ) { } private void clearMenus ( ) { } private void addMenu ( GuiMenu menu ) { } private void popMenu ( ) { } public void keyPressed ( KeyEvent e ) { } public void keyReleased ( KeyEvent e ) { } public void keyTyped ( KeyEvent e ) { } No newline ; at end ; of file ; }

Fix:
if ( ( ! ( isServer ) ) && ( ! ( menuStack . isEmpty ( ) ) ) ) {