I used CSS to place and style the text in the menu. style="text-align:center;" is the CSS used to center text in the example image below. In my case, I encapsulated the JMenu header in the paragraph tags <p> ;
clientFilter = new JMenu("<html><p style='text-align:center;'>Client</p></html>"); siteFilter = new JMenu("<html><p style='text-align:center;'>Site</p></html>"); employeeFilter = new JMenu("<html><p style='text-align:center;'>Employee</p></html>"); jobtypeFilter = new JMenu("<html><p style='text-align:center;'>Job Type</p></html>");
Which looks like this:

It is worth noting that in the image above, I also used width:90px;color:blue; in the style attribute, but I removed these two styles from the above code example for simplicity. Hope this helps.
This answer is more or less a copy of my original answer here .
source share