Sanhedrin2: 2
הַמֶּלֶךְ לֹא דָן וְלֹא דָנִין אוֹתוֹ. לֹא מֵעִיד וְלֹא מְעִידִין אוֹתוֹ. לֹא חוֹלֵץ וְלֹא חוֹלְצִין לְאִשְׁתּוֹ. לֹא מְיַבֵּם וְלֹא מְיַבְּמִין לְאִשְׁתּוֹ. רַבִּי יְהוּדָה אוֹמֵר: אִם רָצָה לַחֲלוֹץ אוֹ לְיַבֵּם, זָכוּר לְטוֹב. אָמְרוּ לוֹ: אֵין שׁוֹמְעִין לוֹ. וְאֵין נוֹשְׂאִין אַלְמְנָתוֹ. רַבִּי יְהוּדָה אוֹמֵר: נוֹשֵׂא הַמֶּלֶךְ אַלְמְנָתוֹ שֶׁל מֶלֶךְ, שֶׁכֵּן מָצִינוּ בְדָוִד שֶׁנָּשָׂא אַלְמְנָתוֹ שֶׁל שָׁאוּל, שֶׁנֶּאֱמַר: ,,וָאֶתְּנָה לְךָ אֶת בֵּית אֲדֹנֶיךָ וְאֶת נְשֵׁי אֲדֹנֶיךָ בְּחֵיקֶךָ”.
The king may not judge nor be judged. He may not testify nor be testified against. He does not perform chalitzah, nor is chalitzah performed with his wife. He does not perform yibum, nor is yibum performed with his wife. R’ Yehudah says: If he wishes to perform chalitzah or yibum, the is remembered favorably. They said to him: They do not listen to him. No one may marry his widow. R’ Yehudah says: A king may marry the widow of [another] king, as we find that David married the widow of Saul, as it is stated: And I gave you the house of your master and the wives of your master in your bosom.
Sanhedrin2: 3
מֵת לוֹ מֵת, אֵינוֹ יוֹצֵא מִפֶּתַח פַּלְטְרִין שֶׁלּוֹ. רַבִּי יְהוּדָה אוֹמֵר: אִם רוֹצֶה לָצֵאת אַחַר הַמִּטָּה יוֹצֵא, שֶׁכֵּן מָצִינוּ בְדָוִד שֶׁיָּצָא אַחַר מִטָּתוֹ שֶׁל אַבְנֵר, שֶׁנֶּאֱמַר: ,,וְהַמֶּלֶךְ דָּוִד הֹלֵךְ אַחֲרֵי הַמִּטָּה”. אָמְרוּ לוֹ: לֹא הָיָה הַדָּבָר אֶלָּא לְפַיֵּס אֶת הָעָם. וּכְשֶׁמַּבְרִין אוֹתוֹ, כָּל הָעָם מְסֻבִּין עַל הָאָרֶץ וְהוּא מֵסֵּב עַל הַדַּרְגָּשׁ.
[If] someone [close] to him dies, he does not leave the entrance of his palace. R’ Yehudah says: If he wishes to go out after the bier he may go out, for so we find concerning David that he went out after the bier of Abner, as it is stated: And King Da-vid followed the bier. They said to him: This was only to placate the people. When they feed him the mourner’s meal, all the people sit on the floor and he sits on the dargash.