Help trying to understand why the matrix representation of $J^2$ is what it is

Say we a basis of kets such as$$\beta ~ := ~\left\{\left|j=1,\, m=-1\right> , ~ \left|j=1, \, m=0\right>, ~ \left|j=1, \, m=1\right>\right\} \,.$$