protected void paintComponent(Graphics g) {
		super.paintComponent(g);
		if(width!=this.getWidth() || height!=this.getHeight()) {
			width = this.getWidth();
			height = this.getHeight();
			displayBuffer = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
			dBufferG = displayBuffer.createGraphics();
		}
        int side = Math.min((getWidth()- gridStroke)/(horizontalPages* PAGE_SIZE)- gridStroke, (getHeight()- gridStroke)/(verticalPages*PAGE_SIZE)- gridStroke);
        int offsetX = (getWidth()-systemPaint[0].length*(gridStroke+side)-gridStroke)/2; // beräknas för centrering
        int offsetY = (getHeight()-systemPaint.length*(gridStroke+side)-gridStroke)/2; // beräknas för centrering
		dBufferG.setColor(displayGrid);
		dBufferG.fillRect(0, 0, getWidth(), getHeight());
		for (int row = 0; row < systemPaint.length; row++) {
			for (int col = 0; col < systemPaint[row].length; col++) {
				dBufferG.setColor(displayBackground);
				dBufferG.fillRect(offsetX + gridStroke + col * (side + gridStroke), offsetY + gridStroke + row * (side + gridStroke), side, side);
				dBufferG.setColor(systemPaint[row][col]);
				dBufferG.fillRect(offsetX + gridStroke + col * (side + gridStroke), offsetY + gridStroke + row * (side + gridStroke), side, side);
			}
		}
		g.drawImage(displayBuffer, 0, 0, null);
	}