/**
 * 
 */
package mathsquared.resultswizard2;

import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.Socket;

import javax.swing.JOptionPane;

/**
 * Runs the display logic of the program; acts as the client in a client-server framework.
 * 
 * @author MathSquared
 * 
 */
public class Display implements Runnable {

    ObjectInputStream in;
    ObjectOutputStream out;

    /**
     * @param args the command-line arguments; unused
     */
    public static void main (String[] args) {
        ConnectionDetailsFrame cdf = new ConnectionDetailsFrame(false); // disallow local connections by passing in false
        Socket sock = cdf.call();

        // Don't allow the user to specify a null network connection (even though we disallow local, they can still press the close button)
        while (sock == null) {
            JOptionPane.showMessageDialog(null, "You must specify an IP address and port, then press the Submit button.");
            sock = cdf.call();
        }

        InputStream sockIn;
        OutputStream sockOut;

        try {
            sockIn = sock.getInputStream();
            sockOut = sock.getOutputStream();
        } catch (IOException e) {
            System.out.println("ERROR: I/O error occurred when initializing network communication");
            e.printStackTrace(System.out);
            System.out.println("Exiting...");
            System.exit(0);
            return;
        }

        // Run the app
        try {
            new Display(sockIn, sockOut);
        } catch (IOException e) {
            System.out.println("ERROR: I/O error occurred when initializing display");
            e.printStackTrace(System.out);
            System.out.println("Exiting...");
            System.exit(0);
            return;
        }
    }

    /**
     * Creates a Display instance which communicates with its server through the given streams.
     * 
     * @param cmds the InputStream carrying serialized {@link Command} instances for the Display to act upon
     * @param resp the OutputStream used for returning <code>Command</code> instances to the client
     * @throws IOException if an I/O error occurs when instantiating the object
     */
    public Display (InputStream cmds, OutputStream resp) throws IOException {
        // Create Object__Streams
        in = new ObjectInputStream(cmds);
        out = new ObjectOutputStream(resp);
    }

    public void run () {
        // TODO display stuff

        // Select a graphics device
        GraphicsDevice[] gds = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
        GraphicsDevice gd = GraphicsDeviceSelector.selectGraphicsDevice(gds);
    }

}

@@ -495,16 +495,200 @@
 nnable %7B
+%0A    // Original streams, in case they need reinitialization based on a corrupted object received by the Object__Streams%0A    private OutputStream outRaw;%0A    private InputStream inRaw;
 %0A%0A    Ob
@@ -2632,16 +2632,62 @@
 ption %7B%0A
+        inRaw = cmds;%0A        outRaw = resp;%0A%0A
         
@@ -3083,10 +3083,448 @@
 %0A    %7D%0A%0A
+    /**%0A     * Reinitializes the Object__Streams based on the %3Ccode%3EInputStream%3C/code%3E and %3Ccode%3EOutputStream%3C/code%3E given to the constructor.%0A     */%0A    private void restartStreams () %7B%0A        try %7B%0A            out = new ObjectOutputStream(outRaw);%0A            in = new ObjectInputStream(inRaw);%0A        %7D catch (IOException e) %7B%0A            System.out.println(%22Error when reinitializing streams: %22 + e.getMessage());%0A        %7D%0A    %7D%0A%0A
 %7D%0A

Add inRaw, outRaw, restartStreams to Display