Buggy code:
public class ConnectionScreen extends JFrame implements ActionListener , MouseListener { private static final long serialVersionUID = 1L ; JButton connectToGame ; JButton createGame ; JPanel gamePanel ; JTextField portField ; JTextField hostField ; JLabel portLabel ; JLabel hostLabel ; ChessGame game ; Socket socket ; public ConnectionScreen ( ) { } @ Override public void mouseClicked ( MouseEvent e ) { if ( ( e . getSource ( ) ) == ( createGame ) ) { hostLabel . setVisible ( false ) ; hostField . setVisible ( false ) ; int op = JOptionPane . showConfirmDialog ( null , gamePanel , "Create<seq2seq4repair_space>a<seq2seq4repair_space>Game" , JOptionPane . OK_CANCEL_OPTION ) ; if ( op == ( JOptionPane . OK_OPTION ) ) { int port = - 1 ; try { port = Integer . parseInt ( portField . getText ( ) ) ; } catch ( NumberFormatException ex ) { JOptionPane . showMessageDialog ( this , "Please<seq2seq4repair_space>enter<seq2seq4repair_space>a<seq2seq4repair_space>valid<seq2seq4repair_space>number" ) ; } if ( ( port > 0 ) && ( port <= 65535 ) ) { System . out . println ( ( "Creating<seq2seq4repair_space>a<seq2seq4repair_space>game<seq2seq4repair_space>with<seq2seq4repair_space>port<seq2seq4repair_space>" + port ) ) ; JLabel label = new JLabel ( "Waiting<seq2seq4repair_space>for<seq2seq4repair_space>opponent..." ) ; add ( label , BorderLayout . CENTER ) ; ServerSocket serverSocket ; Socket clientSocket = null ; try { serverSocket = new ServerSocket ( port ) ; clientSocket = serverSocket . accept ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } if ( clientSocket != null ) { game . getGUI ( ) . setVisible ( true ) ; game . getGUI ( ) . setMe ( Color . WHITE ) ; game . SetSocket ( clientSocket ) ; this . setVisible ( false ) ; new Thread ( game ) . start ( ) ; } } } } if ( ( e . getSource ( ) ) == ( connectToGame ) ) { hostLabel . setVisible ( true ) ; hostField . setVisible ( true ) ; <START_BUG> int op = JOptionPane . showConfirmDialog ( null , gamePanel , "Create<seq2seq4repair_space>a<seq2seq4repair_space>Game" , JOptionPane . OK_CANCEL_OPTION ) ; <END_BUG> if ( op == ( JOptionPane . OK_OPTION ) ) { int port = - 1 ; try { port = Integer . parseInt ( portField . getText ( ) ) ; } catch ( NumberFormatException ex ) { JOptionPane . showMessageDialog ( this , "Please<seq2seq4repair_space>enter<seq2seq4repair_space>a<seq2seq4repair_space>valid<seq2seq4repair_space>number" ) ; } socket = null ; if ( ( port > 0 ) && ( port <= 65535 ) ) { System . out . println ( ( ( ( "Connecting<seq2seq4repair_space>to<seq2seq4repair_space>a<seq2seq4repair_space>game<seq2seq4repair_space>with<seq2seq4repair_space>port<seq2seq4repair_space>" + port ) + "<seq2seq4repair_space>and<seq2seq4repair_space>host<seq2seq4repair_space>name<seq2seq4repair_space>" ) + ( hostField . getText ( ) ) ) ) ; try { socket = new Socket ( InetAddress . getByName ( hostField . getText ( ) ) , port ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } } if ( ( socket ) != null ) { game . getGUI ( ) . setVisible ( true ) ; game . getGUI ( ) . setMe ( Color . BLACK ) ; game . SetSocket ( socket ) ; this . setVisible ( false ) ; new Thread ( game ) . start ( ) ; } } } } @ Override public void mousePressed ( MouseEvent e ) { } @ Override public void mouseReleased ( MouseEvent e ) { } @ Override public void mouseEntered ( MouseEvent e ) { } @ Override public void mouseExited ( MouseEvent e ) { } @ Override public void actionPerformed ( ActionEvent e ) { } }

Fix:
int op = JOptionPane . showConfirmDialog ( null , gamePanel , "Connect<seq2seq4repair_space>to<seq2seq4repair_space>a<seq2seq4repair_space>Game" , JOptionPane . OK_CANCEL_OPTION ) ;