private void initComponents() {

		JSplitPane splitPane = new JSplitPane();
		getContentPane().add(splitPane, BorderLayout.CENTER);

		rightPanel = new JPanel();
		rightPanel.setMinimumSize(new Dimension(this.getWidth() / 2, 30));
		rightPanel.setPreferredSize(new Dimension(this.getWidth() / 2, 30));
		splitPane.setLeftComponent(rightPanel);
		rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.Y_AXIS));

		Component verticalStrut = Box.createVerticalStrut(10);
		rightPanel.add(verticalStrut);

		JPanel filePanel = new JPanel();
		// filePanel.setPreferredSize(new Dimension(250, 30));
		// filePanel.setMinimumSize(new Dimension(250, 30));
		filePanel.setMaximumSize(new Dimension(32767, 30));
		rightPanel.add(filePanel);
		filePanel.setLayout(new BoxLayout(filePanel, BoxLayout.X_AXIS));

		Component horizontalStrut = Box.createHorizontalStrut(10);
		filePanel.add(horizontalStrut);

		browseButton = new JButton("Browse");
		browseButton.setPreferredSize(new Dimension(70, 25));
		browseButton.setMinimumSize(new Dimension(70, 25));
		browseButton.setMaximumSize(new Dimension(70, 25));
		filePanel.add(browseButton);

		Component horizontalStrut_2 = Box.createHorizontalStrut(10);
		filePanel.add(horizontalStrut_2);

		pathTextField = new JTextField();
		pathTextField.setPreferredSize(new Dimension(200, 25));
		pathTextField.setMinimumSize(new Dimension(150, 25));
		pathTextField.setMaximumSize(new Dimension(250, 25));
		pathTextField.setEditable(false);
		filePanel.add(pathTextField);

		Component verticalStrut_1 = Box.createVerticalStrut(10);
		rightPanel.add(verticalStrut_1);

		JScrollPane scrollPane = new JScrollPane();
		rightPanel.add(scrollPane);

		final Component verticalStrut_7 = Box.createVerticalStrut(10);
		rightPanel.add(verticalStrut_7);

		JPanel buttonsPanel = new JPanel();
		// buttonsPanel.setPreferredSize(new Dimension(250, 30));
		// buttonsPanel.setMinimumSize(new Dimension(250, 30));
		buttonsPanel.setMaximumSize(new Dimension(32767, 30));
		rightPanel.add(buttonsPanel);
		buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));

		Component horizontalStrut_1 = Box.createHorizontalStrut(20);
		buttonsPanel.add(horizontalStrut_1);

		preprocessingButton = new JButton("Preprocessing");
		preprocessingButton.setPreferredSize(new Dimension(120, 25));
		preprocessingButton.setMinimumSize(new Dimension(120, 25));
		preprocessingButton.setMaximumSize(new Dimension(120, 25));
		preprocessingButton.setEnabled(false);
		buttonsPanel.add(preprocessingButton);

		Component horizontalGlue = Box.createHorizontalGlue();
		buttonsPanel.add(horizontalGlue);

		binarizationButton = new JButton("Binarization");
		binarizationButton.setMinimumSize(new Dimension(120, 25));
		binarizationButton.setMaximumSize(new Dimension(120, 25));
		binarizationButton.setPreferredSize(new Dimension(120, 25));
		binarizationButton.setEnabled(false);
		buttonsPanel.add(binarizationButton);

		Component horizontalStrut_3 = Box.createHorizontalStrut(20);
		buttonsPanel.add(horizontalStrut_3);

		Component verticalStrut_3 = Box.createVerticalStrut(10);
		rightPanel.add(verticalStrut_3);

		leftPanel = new JPanel();
		splitPane.setRightComponent(leftPanel);
		leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.Y_AXIS));

		Component verticalStrut_2 = Box.createVerticalStrut(10);
		leftPanel.add(verticalStrut_2);

		JPanel updatePanel = new JPanel();
		// buttonsPanel.setPreferredSize(new Dimension(250, 30));
		// buttonsPanel.setMinimumSize(new Dimension(250, 30));
		updatePanel.setMaximumSize(new Dimension(32767, 30));
		leftPanel.add(updatePanel);
		updatePanel.setLayout(new BoxLayout(updatePanel, BoxLayout.X_AXIS));

		Component horizontalStrut_4 = Box.createHorizontalStrut(10);
		updatePanel.add(horizontalStrut_4);

		updateCheckBox = new JCheckBox();
		updateCheckBox.setText("Immediate Update ");
		updateCheckBox.setActionCommand("Immediate Update ");
		updatePanel.add(updateCheckBox);

		Component horizontalGlue_1 = Box.createHorizontalGlue();
		updatePanel.add(horizontalGlue_1);

		updateButton = new JButton("Update");
		updateButton.setMaximumSize(new Dimension(80, 25));
		updateButton.setMinimumSize(new Dimension(80, 25));
		updateButton.setPreferredSize(new Dimension(80, 25));
		updateButton.setEnabled(false);
		updatePanel.add(updateButton);

		Component horizontalStrut_5 = Box.createHorizontalStrut(10);
		updatePanel.add(horizontalStrut_5);

		Component verticalStrut_4 = Box.createVerticalStrut(10);
		leftPanel.add(verticalStrut_4);

		imageScrollPane = new JScrollPane();
		imageScrollPane.setBorder(null);
		leftPanel.add(imageScrollPane);

		Component verticalStrut_5 = Box.createVerticalStrut(10);
		leftPanel.add(verticalStrut_5);

		compareButton = new JButton("Compare");
		compareButton.setMaximumSize(new Dimension(80, 25));
		compareButton.setMinimumSize(new Dimension(80, 25));
		compareButton.setAlignmentX(Component.CENTER_ALIGNMENT);
		compareButton.setPreferredSize(new Dimension(80, 25));
		compareButton.setEnabled(false);
		leftPanel.add(compareButton);

		Component verticalStrut_6 = Box.createVerticalStrut(10);
		leftPanel.add(verticalStrut_6);

		imagePanel = new JPanel();
		scrollPane.setViewportView(imagePanel);
		newImgPanel = new JPanel();
		checkedImages = new ArrayList<JCheckBox>();

		compareButton.setEnabled(false);
		binarizationButton.setEnabled(false);
		preprocessingButton.setEnabled(false);
		updateButton.setEnabled(false);

		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setPreferredSize(new Dimension(820, 550));
		setMinimumSize(new Dimension(820, 550));

		addComponentListener(new ComponentAdapter() {
			public void componentResized(ComponentEvent evt) {

				formComponentResized(evt);
			}

			private void formComponentResized(ComponentEvent evt) {
			}
		});

		final JFileChooser fileChooser = new JFileChooser("poze de test");
		pathTextField.setEditable(false);
		browseButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {

				SwingUtilities.invokeLater(new Runnable() {
					public void run() {
						int returnVal = fileChooser.showOpenDialog(leftPanel);
						if (returnVal == JFileChooser.APPROVE_OPTION) {
							// facem enabled butoanele
							compareButton.setEnabled(true);
							binarizationButton.setEnabled(true);
							preprocessingButton.setEnabled(true);
							updateButton.setEnabled(true);

							// Setam calea catre fisier in textBox
							pathTextField.setText(fileChooser.getSelectedFile()
									.getAbsolutePath());
							// salvam calea catre imagine
							pathImage = pathTextField.getText();
							// Incarcam imaginea in panel

							// construieste imagine din calea "pathImage" cu
							// dimensiunile width si height
							Image image = ImageViewer.buildImage(pathImage);

							// facem imaginea greyscale in spate
							BufferedImage image_new = null;
							File outputBlack = null;
							try {
								image_new = ImageIO.read(new File(pathTextField
										.getText()));
								BufferedImage image2 = new BufferedImage(
										image_new.getWidth(), image_new
												.getHeight(),
										BufferedImage.TYPE_BYTE_GRAY);
								Graphics g = image2.getGraphics();
								g.drawImage(image, 0, 0, null);
								g.dispose();

								// Scriem noua imagine greyscale pe disc
								String delim = "\\.";
								String[] tokens = pathTextField.getText()
										.split(delim);
								inputPath = tokens[0] + "_input.png";
								outputBlack = new File(inputPath);
								outputBlack.createNewFile();
								ImageIO.write(image2, "png", outputBlack);
							} catch (Exception e) {
							}

							// Setam imaginea originala in stanga (pana la o
							// preprocesare)
							ImageIcon myPicture = new ImageIcon(image);
							JLabel picLabel = new JLabel(myPicture);
							picLabel.setSize(new Dimension(myPicture
									.getIconWidth(), myPicture.getIconHeight()));
							imagePanel.removeAll();
							imagePanel.add(picLabel);
							MainWindow.this.repaint();
						}
					}
				});
			}
		});

		// facem disable butonul de update daca checkboxul este true
		updateCheckBox.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				if (updateCheckBox.isSelected()) {
					updateButton.setEnabled(false);
				} else {
					updateButton.setEnabled(true);
				}

			}
		});

		/*
		 * La apasarea butonului Update: - se verifica daca exista cel putin un
		 * checkbox selectat in dreapta - se schimba imaginea de input al
		 * operatiilor corespunzatoare - se executa din nou operatia de
		 * binarizare cu noua imagine de input dar cu aceiasi parametri ca la
		 * inceput. - se updateaza Label-ul cu noua imagine.
		 */
		updateButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {

				/*
				 * Daca exista cel putin un checkbox selectat caut numarul de
				 * ordine al fiecarui checkbox selectat, astfel incat sa pot
				 * modifica operatia corespunzatoare din vectorul "operations"
				 */

				if (checkedImages.size() > 0) {

					for (int i = 0; i < checkedImages.size(); i++) {
						JCheckBox checked = checkedImages.get(i);
						for (int j = 0; j < allImages.size(); j++) {
							JCheckBox item = allImages.get(j);
							// numarul de ordine este j
							if (checked == item) {
								// modific operatia
								((ComplexTypeParameter) operations.get(j)
										.getParameter("inputFile"))
										.setAttribute("name", inputPath);
								// execut operatia pentru a obtine imaginea de
								// output
								operations.get(j).execute();

								// construiesc noua imagine din calea obtinuta
								String path = ((ComplexTypeParameter) operations
										.get(j).getParameter("outputFile"))
										.getAttribute("name").getValue();

								int width = 450;
								int height = 250;

								// Inlocuiesc Label-ul din dreapta
								JLabel label = labelList.get(checked);

								Image image = ImageViewer.buildImage(path);
								image = ImageViewer.resize(image,
										label.getWidth(), label.getHeight());
								ImageIcon myPicture = new ImageIcon(image);

								label.setIcon(myPicture);
							
								// fac refresh la JScrollPane
								imageScrollPane.revalidate();
								imageScrollPane.repaint();

								// inlocuiesc calea in imageList
								imageList.put(checked, path);
							}
						}
					}
				}
			}
		});

		imagePanel
				.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
		imagePanel.setForeground(new Color(255, 255, 255));

		imagePanel.setLayout(new BoxLayout(imagePanel, BoxLayout.Y_AXIS));
	
		binarizationButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent ae) {
				EventQueue.invokeLater(new Runnable() {
					@Override
					public void run() {
						binarizationWindow.setVisible(true);

					}
				});

			}
		});

		preprocessingButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				java.awt.EventQueue.invokeLater(new Runnable() {
					public void run() {
						preprocessingWindow.setVisible(true);
					}
				});

			}
		});

		binarizationButton.getAccessibleContext().setAccessibleName("");

		imageScrollPane.setBorder(BorderFactory.createLineBorder(Color.BLACK));
		imageScrollPane.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
	
		newImgPanel.setLayout(new BoxLayout(newImgPanel, BoxLayout.Y_AXIS));

		imageScrollPane.setViewportView(newImgPanel);

		updateCheckBox.setText("Immediate Update ");
		updateCheckBox.setActionCommand("Immediate Update ");

		compareButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {

				
				if (checkedImages.size() == 2) {
					try {
						compareWindow = new CompareImagesWindow(imageList
								.get(checkedImages.get(0)), imageList
								.get(checkedImages.get(1)));
						compareWindow.setVisible(true);
					}
				
					catch (IOException ex) {
						Logger.getLogger(MainWindow.class.getName()).log(
								Level.SEVERE, null, ex);
					}
				}

			}
		});

	}