public void paint(Graphics g)
    {
        if (pal == null)
            return;
        g.setColor(Color.BLACK);
        g.fillRect(0, 0, ((pal.length / rows) * squareSize) + 1,
            (rows * squareSize) + 1);
        if (pal == null)
        {
            g.setColor(Color.BLACK);
            for (int i = 0; i < (pal.length / rows); i++)
            {
                g.fillRect(i * squareSize, 0, squareSize - 1, squareSize - 1);
                g.fillRect(i * squareSize, squareSize, squareSize - 1,
                    squareSize - 1);
            }
        }
        else
        {
            for (int r = 0; r < rows; r++)
            {
                for (int c = 0; c < cols; c++)
                {
                    g.setColor(this.getColorOf(c + r * cols));
                    g.fillRect((c * squareSize) + 1, (r * squareSize) + 1,
                        squareSize - 1, squareSize - 1);
                    if (c + r * cols == this.getSelectedColorIndex())
                    {
                        g.setColor(Color.WHITE);
                        g.drawRect(c * squareSize, r * squareSize, squareSize,
                            squareSize);
                    }
                }
            }
        }

        Color col = this.getSelectedColor();
        g.setColor(col);
        g.fillRect((int) ((cols + 0.5) * squareSize),
            (int) (((rows - 1.0) / 2.0) * squareSize), squareSize, squareSize);
        g.setColor(Color.BLACK);
        g.drawRect((int) ((cols + 0.5) * squareSize),
            (int) (((rows - 1.0) / 2.0) * squareSize), squareSize, squareSize);
    }