/**
 * 
 */
package mathsquared.resultswizard2;

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);
        Socket sock = cdf.call();

        // Don't allow the user to specify a null network connection (even though we disallow remote, 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
    }

}

@@ -42,16 +42,77 @@
 zard2;%0A%0A
+import java.awt.DisplayMode;%0Aimport java.awt.GraphicsDevice;%0A
 import j
@@ -2580,10 +2580,1640 @@
 %0A    %7D%0A%0A
+    public GraphicsDevice selectGraphicsDevice (GraphicsDevice%5B%5D gds) %7B%0A        // Create Strings%0A        String%5B%5D gdStrings = new String%5Bgds.length%5D;%0A        for (int i = 0; i %3C gds.length; i++) %7B%0A            // We use the index to convert the String from JOptionPane back into an index into gds in the future, and to make the user's choices unique%0A            gdStrings%5Bi%5D = i + %22: %22 + graphicsDeviceToString(gds%5Bi%5D);%0A        %7D%0A%0A        String selection = null;%0A        while (selection == null) %7B%0A            selection = (String) JOptionPane.showInputDialog(null, %22Select a screen on which to display the projection%22, %22Screen Selection%22, JOptionPane.PLAIN_MESSAGE, null, gdStrings, gdStrings%5B0%5D);%0A        %7D%0A        int index = Integer.parseInt(selection.split(%22:%22)%5B0%5D);%0A        return gds%5Bindex%5D;%0A    %7D%0A%0A    /**%0A     * Creates a String representation of a %3Ccode%3EGraphicsDevice%3C/code%3E, including information about its current %3Ccode%3EDisplayMode%3C/code%3E.%0A     * %0A     * @param gd the %7B@link GraphicsDevice%7D to examine%0A     * @return a String in the format %3Ccode%3E%22%5B &lt;IDstring%3E %5D &lt;width%3Ex&lt;height%3E, &lt;bitDepth%3E-bit @ &lt;refreshRate%3E Hz%22%3Ccode%3E, where %3Ccode%3EIDstring = gd.getIDstring()%3C/code%3E, %3Ccode%3Ewidth = gd.getDisplayMode().getWidth()%3C/code%3E, etc. (All values are obtained from the %7B@link DisplayMode%7D except for the %3Ccode%3EIDstring%3C/code%3E.)%0A     */%0A    public String graphicsDeviceToString (GraphicsDevice gd) %7B%0A        DisplayMode dm = gd.getDisplayMode();%0A        return %22%5B %22 + gd.getIDstring() + %22 %5D %22 + dm.getWidth() + %22x%22 + dm.getHeight() + %22, %22 + dm.getBitDepth() + %22-bit @ %22 + dm.getRefreshRate() + %22 Hz%22;%0A    %7D%0A%0A
 %7D%0A

Implement a GraphicsDevice selection system