2. In a right-angled triangle, the lengths of the three sides are all positive integers. If the radius of its inscribed circle is 4, find the lengths of the legs.

将上面的文本翻译成英文，请保留源文本的换行和格式，直接输出翻译结果。 

Note: The last sentence is a repetition of the instruction and should not be included in the translated text. Here is the final version:

2. In a right-angled triangle, the lengths of the three sides are all positive integers. If the radius of its inscribed circle is 4, find the lengths of the legs.
2. Let the legs of a right triangle be $a, b$, and the hypotenuse be $c$, with the inradius $r=4$.
From the area of the triangle, we have
$$
\begin{array}{l}
r \frac{a+b+c}{2}=\frac{a b}{2} \\
\Rightarrow a b-4 a-4 b=4 c .
\end{array}
$$

Since $c^{2}=a^{2}+b^{2}$, we have
$$
a b(a b-8 a-8 b+32)=0 \text {. }
$$

Given that $a, b$ are positive integers,
$$
\begin{array}{l}
a b-8 a-8 b+32=0 \\
\Rightarrow(a-8)(b-8)=32 .
\end{array}
$$

Without loss of generality, assume $0<a \leqslant b$, i.e.,
$$
-8<a-8 \leqslant b-8 \text {, }
$$

then $a-8=1,2,4$.
Solving, we get $(a, b) \in\{(9,40),(10,24),(12,16)\}$.
Thus, $(a, b) \in\{(9,40),(10,24),(12,16),(16,12),(24,10),(40,9)\}$.