private JComponent drawDialogPane() {

		// Create the panel
		JPanel panel = new JPanel();
		panel.setLayout(new GridLayout(5, 2));
		panel.setBorder(BorderFactory.createTitledBorder("Product"));

		// Combo items
		JComboBox<String> combo = new JComboBox<String>();
		combo.addItem("Select one");
		// System.out.println(model.getWarehouseTableModel().getRowCount());
		for (StockItem x : model.getWarehouseTableModel().getTableRows()) {
			combo.addItem(x.getName());
		}

		// Initialize the textfields

		items = combo;
		barCodeField = new JTextField();
		quantityField = new JTextField("1");
		priceField = new JTextField();

		// Fill the dialog fields if the bar code text field loses focus
		items.addItemListener(new ItemListener() {
			int q;

			public void itemStateChanged(ItemEvent event) {
				if (event.getStateChange() == ItemEvent.SELECTED)

				{
					q = Integer.parseInt(quantityField.getText()); // saan teada
																	// mitu seda
																	// toodet
																	// tellitakse
					StockItem stockItem = getStockItemByName();

					if (stockItem != null) {

						priceField.setText(String.valueOf(stockItem.getPrice()
								* q));
						barCodeField.setText(String.valueOf(stockItem.getId()));

					} else {
						reset();
					}
				}

			}
		});

		priceField.setEditable(false);
		barCodeField.setEditable(false);//

		// == Add components to the panel

		// -items
		panel.add(new JLabel("Items"));
		panel.add(items);

		// - bar code
		panel.add(new JLabel("Bar code:"));
		panel.add(barCodeField);

		// - amount
		panel.add(new JLabel("Amount:"));
		panel.add(quantityField);

		// - price
		panel.add(new JLabel("Price:"));
		panel.add(priceField);

		// Create and add the button
		addItemButton = new JButton("Add to cart");

		addItemButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getAllQuantities();
				// add chosen item to the shopping cart.
				StockItem stockItem = getStockItemByBarCode();

				if (stockItem != null) {

					try {
						// System.out.println(stockItem.getQuantity());
						quantity = Integer.parseInt(quantityField.getText());

						if (quantity > stockItem.getQuantity()) {

							JOptionPane.showMessageDialog(null,
									"There isn't enough " + stockItem.getName()
											+ " in the stock.");

						} else {
							stockItem.setQuantity(stockItem.getQuantity()
									- quantity);
							model.getCurrentPurchaseTableModel().addItem(
									new SoldItem(stockItem, quantity));
						}
					} catch (NumberFormatException ex) {
						quantity = 1;

					}

				} else
					try {
						model.getCurrentPurchaseTableModel().addItem(
								new SoldItem(stockItem, quantity));

					} catch (NullPointerException ee) {
						System.out.println(ee.getMessage());
					}
			}

		});

		panel.add(addItemButton);

		return panel;
	}