public FieldPainter (int winWidth, int winHeight) {
        super();
        setSize(winWidth, winHeight);

        fieldWidth = (getWidth() - 200) / cellSize;
        fieldHeight = (getHeight() - 40) / cellSize;

        alg = new AStar(fieldWidth, fieldHeight, Integer.valueOf(dTextField.getText()));
        alg.setDelay(600000);
        lengthFromStartToEnd = getLength(alg.getStartCell(), alg.getEndCell());

        setLayout(null);
        setFocusable(true);
        requestFocus();

        addMouseListener(this);
        addMouseMotionListener(this);
        addKeyListener(new KeyAdapter() {
            @Override
            public void keyReleased (KeyEvent e) {
                if (e.getKeyChar() == KeyEvent.VK_ENTER) {
                    startSolution();

                } else if (e.getKeyChar() == KeyEvent.VK_SPACE) {
                    alg.reset();
                }
            }
        });

        int textX = winWidth - 180;
        JLabel dLabel = new JLabel("Weight:");
        dLabel.setLocation(textX, 130);
        dLabel.setSize(45, 20);
        add(dLabel);

        dTextField.setLocation(textX + dLabel.getWidth() + 5, 130);
        dTextField.setSize(60, 20);
        dTextField.addKeyListener(new KeyAdapter() {
            @Override
            public void keyReleased (KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                    startSolution();
                    grabFocus();

                } else if (e.getKeyCode() == KeyEvent.VK_SPACE) {
                    dTextField.setText(dTextField.getText().replace(" ", ""));
                    alg.reset();
                    grabFocus();
                }
            }
        });
        add(dTextField);

        initPainter();
    }