public ClientFrame() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 1000, 500);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		JScrollPane scrollPane = new JScrollPane();
		contentPane.add(scrollPane, BorderLayout.CENTER);
		
		console = new JTextArea();
		scrollPane.setViewportView(console);
		
		JPanel panel = new JPanel();
		contentPane.add(panel, BorderLayout.SOUTH);
		panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
		
		JLabel lblPortNumber = new JLabel("Ports:");
		panel.add(lblPortNumber);
		
		textNodes = new JTextField();
		textNodes.setText("localhost:6001, localhost:6002, localhost:6003, localhost:6004, localhost:6005");
		panel.add(textNodes);
		textNodes.setColumns(80);
		
		JButton btnRunFile = new JButton("Run from file ...");
		panel.add(btnRunFile);
		
		JButton btnStop = new JButton("Stop");
		btnStop.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if(client != null){
					client.kill();
				}
			}
		});
		panel.add(btnStop);
		
		btnRunFile.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {

				// clear console
				console.setText("");
				
				JFileChooser chooser = new JFileChooser();
                chooser.setCurrentDirectory(new File(".\\sqlscripts"));
                chooser.setSelectedFile(new File("Unnamed"));
                chooser.setFileFilter(new FileFilter()
                {
                        public boolean accept(File f)
                        {
                            return f.isDirectory() || f.getName().toLowerCase().endsWith(".txt") || f.getName().toLowerCase().endsWith(".txt");
                        }
                        public String getDescription()
                        {
                            return "SQL script";
                        }

                });
                int returnVal = chooser.showOpenDialog(ClientFrame.this);
                if(returnVal == JFileChooser.APPROVE_OPTION) {
                    String filename = chooser.getSelectedFile().getPath();
                    
                    // read the file and prepare a command list
                    List<String> inputs = new ArrayList<String>();
                    
                    BufferedReader br;
					try {
						br = new BufferedReader(new FileReader(filename));
						String line = null;
	                    while ((line = br.readLine()) != null) {
	                    	inputs.add(line);
	                    }
	                    br.close();
	                    console.append("SQL script " + filename + " loaded sucessfully\n");
	                    
	                    String[] commands = inputs.toArray(new String[inputs.size()]);
	                    
	                    // create nodes names
	                    String[] parts = textNodes.getText().split(", ");
	                    NodeName[] nodes = new NodeName[parts.length];
	                    for(int i=0; i!=parts.length; ++i){
	                    	nodes[i] = NodeName.parse(parts[i]);
	                    	if(nodes[i] == null){
	                    		console.append("Error in node name: " + parts[i] + "\n");
	                    	}else{
	                    		console.append("Node " + i + ": " + nodes[i] + "\n");
	                    	}
	                    }
	                    
	                    // run client
	                    client = new Client(console);
	    				client.setParam(nodes, commands);
	    				client.start();
	    				
	    				/**
	    				 * 
	    				 * We run the tests we want. We need to uncoment or coment this lane
	    				 * if we want to test them or not
	    				 * 
	    				 * @author Alvar Viana
	    				 */
	    				//client.runTests();
	                    
					} catch (FileNotFoundException e) {
						console.append(e.getMessage() + "\n");
					} catch (IOException e) {
						console.append(e.getMessage() + "\n");
					}
                }
			}
		});
	}