4. The lengths of four line segments are $9, 5, x, 1$ (where $x$ is a positive real number), and they are used to form two right triangles, with $AB$ and $CD$ being two of the line segments (Figure 2). The number of possible values for $x$ is ( ) .
(A) 2
(B) 3
(C) 4
(D) 6
4.D.

Obviously, $AB$ is the longest, so $AB=9$ or $AB=x$.
(1) If $AB=9$, when $CD=x$,
$$
9^{2}=x^{2}+(1+5)^{2}, x=3 \sqrt{5};
$$

When $CD=5$,
$$
9^{2}=5^{2}+(x+1)^{2}, x=2 \sqrt{14}-1;
$$

When $CD=1$,
$$
9^{2}=1^{2}+(x+5)^{2}, x=4 \sqrt{5}-5;
$$
(2) If $AB=x$, when $CD=9$,
$$
x^{2}=9^{2}+(1+5)^{2}, x=3 \sqrt{13};
$$

When $CD=5$,
$$
x^{2}=5^{2}+(1+9)^{2}, x=5 \sqrt{5};
$$

When $CD=1$,
$$
x^{2}=1^{2}+(5+9)^{2}, x=\sqrt{197};
$$

Therefore, the number of possible values for $x$ is 6.