@Override
    public void paintComponent(Graphics g) {
        g.setColor(Color.WHITE);
        g.fillRect(0, 0, getBounds().width, getBounds().height);
        
        if(nonogram != null) {
        
        int xMax = LABEL_WIDTH + nonogram.getColumnHeaders().size() * SQ_WIDTH;
        int yMax = LABEL_HEIGHT + nonogram.getRowHeaders().size() * SQ_WIDTH;

        int x = LABEL_WIDTH;
        int y = LABEL_HEIGHT;

        if (solution != null) {
            g.setColor(Color.BLACK);
            for (int i = 0; i < nonogram.getColumnHeaders().size(); i++) {

                for (int j = 0; j < nonogram.getRowHeaders().size(); j++) {

                    if (solution.getArray()[j][i]) {
                        g.fillRect(x + 2, y + 2, SQ_WIDTH - 3, SQ_WIDTH - 3);
                    }
                    y += SQ_WIDTH;
                }

                x += SQ_WIDTH;
                y = LABEL_HEIGHT;
            }
        }

        x = LABEL_WIDTH;
        y = LABEL_HEIGHT;

        g.setColor(Color.GRAY);
        for (ArrayList<Integer> header : nonogram.getColumnHeaders()) {
            g.setColor(Color.GRAY);
            g.drawLine(x, 0, x, yMax);

            int step = 15;
            int yLabel = 15;

            for (Integer number : header) {
                g.drawString(number.toString(), x + 6, yLabel);
                yLabel += step;
            }

            x += SQ_WIDTH;
        }
        g.drawLine(x, 0, x, yMax);

        for (ArrayList<Integer> header : nonogram.getRowHeaders()) {
            g.drawLine(0, y, xMax, y);
            y += SQ_WIDTH;

            String label = "";

            for (Integer number : header) {
                label += number.toString() + " ";
            }

            g.drawString(label, 5, y - 5);
        }
        g.drawLine(0, y, xMax, y);
        }
    }