@@ -0,0 +1,3163 @@
+package com.apixandru.games.rummikub.ui;%0A%0Aimport javax.swing.*;%0Aimport java.awt.*;%0Aimport java.util.prefs.Preferences;%0A%0Aimport static javax.swing.JOptionPane.OK_CANCEL_OPTION;%0Aimport static javax.swing.JOptionPane.QUESTION_MESSAGE;%0A%0A/**%0A * @author Alexandru-Constantin Bledea%0A * @since January 09, 2016%0A */%0Afinal class ServerData %7B%0A%0A    private static final String KEY_ADDRESS = %22address%22;%0A    private static final String KEY_USERNAME = %22username%22;%0A%0A    private static final String OPT_CONNECT = %22Connect%22;%0A    private static final String OPT_CANCEL = %22Cancel%22;%0A%0A    private static final String%5B%5D OPTIONS = %7B%22Connect%22, %22Cancel%22%7D;%0A%0A    /**%0A     *%0A     */%0A    private ServerData() %7B%0A    %7D%0A%0A    /**%0A     * @return%0A     */%0A    public static ConnectionData getConnectionData() %7B%0A        final Preferences prefs = Preferences.userNodeForPackage(ServerData.class);%0A%0A        final JTextField tfUsername = newField(prefs, KEY_USERNAME);%0A        final JTextField tfAddress = newField(prefs, KEY_ADDRESS);%0A%0A        final int option = JOptionPane.showOptionDialog(%0A                null,%0A                createLoginPanel(tfUsername, tfAddress),%0A                %22Rummikub Connector%22,%0A                OK_CANCEL_OPTION,%0A                QUESTION_MESSAGE,%0A                null,%0A                OPTIONS,%0A                OPT_CONNECT);%0A%0A        if (option == JOptionPane.CANCEL_OPTION) %7B%0A            return null;%0A        %7D%0A%0A        final String username = tfUsername.getText();%0A        final String address = tfAddress.getText();%0A%0A        prefs.put(KEY_ADDRESS, address);%0A        prefs.put(KEY_USERNAME, username);%0A%0A        return new ConnectionData(address, username);%0A    %7D%0A%0A    /**%0A     * @param tfUsername%0A     * @param tfAddress%0A     * @return%0A     */%0A    private static JPanel createLoginPanel(final JTextField tfUsername, final JTextField tfAddress) %7B%0A        final JPanel panel = new JPanel(new BorderLayout(5, 5));%0A        panel.add(createLabels(), BorderLayout.WEST);%0A        panel.add(newPanel(tfUsername, tfAddress), BorderLayout.CENTER);%0A        return panel;%0A    %7D%0A%0A    /**%0A     * @param components%0A     * @return%0A     */%0A    private static JPanel newPanel(final Component... components) %7B%0A        final JPanel controls = new JPanel(new GridLayout(0, 1, 2, 2));%0A        for (Component component : components) %7B%0A            controls.add(component);%0A        %7D%0A        return controls;%0A    %7D%0A%0A    /**%0A     * @param prefs%0A     * @param key%0A     * @return%0A     */%0A    private static JTextField newField(final Preferences prefs, final String key) %7B%0A        return new JTextField(prefs.get(key, %22%22));%0A    %7D%0A%0A    /**%0A     * @return%0A     */%0A    private static JPanel createLabels() %7B%0A        return newPanel(new JLabel(%22Server%22, SwingConstants.RIGHT), new JLabel(%22Name%22, SwingConstants.RIGHT));%0A    %7D%0A%0A    /**%0A     *%0A     */%0A    static final class ConnectionData %7B%0A%0A        final String ipAddress;%0A        final String username;%0A%0A        /**%0A         * @param ipAddress%0A         * @param username%0A         */%0A        ConnectionData(final String ipAddress, final String username) %7B%0A            this.ipAddress = ipAddress;%0A            this.username = username;%0A        %7D%0A%0A    %7D%0A%0A%7D%0A

add panel to connect to server