* By depicting James as a strong and legitimate ruler. Macbeth is a play about the dangers of ambition and the importance of loyalty. By contrast, James is presented as a wise and benevolent monarch who is loved and respected by his subjects. This is in line with the popular image of James as a "Renaissance prince" who was a patron of the arts and sciences.
* By including references to James's personal history and accomplishments. For example, the play mentions the Battle of Flodden Field, in which James's father, King James IV of Scotland, was killed. This reference would have resonated with James and his audience, and would have reminded them of his family's history and legacy.
* By using language that is flattering to James. Shakespeare uses many flattering adjectives to describe James, such as "gracious," "majestic," and "virtuous." He also refers to James as "the king of kings," which is a title that was often used by medieval and Renaissance monarchs.
* By making James the ultimate victor of the play. In the end, Macbeth is defeated and James is crowned king. This is a clear indication that Shakespeare intended to compliment James and to show him as the rightful ruler of Scotland.
In addition to these specific ways in which Shakespeare compliments James, the play Macbeth as a whole can be seen as a celebration of James's reign. The play is a powerful reminder of the dangers of tyranny and the importance of loyalty, which were both important themes during James's time. By writing a play that was both entertaining and politically relevant, Shakespeare was able to please his monarch and gain favor at court.