It seems that the problem is with the alignment of certain characters in the center of BoxLayout along the y axis in Java. I do not know what can cause this, and I created SSCCE to demonstrate the effect. In the example, I use only the "a" character, and I draw a line down the straight middle of each JPanel to demonstrate how far away from each case is the center. The bold case seems to work well, but normal formatting and italics are too far from the center, despite using setAlignmentX and setHorizontalAlignment. Any help in understanding this effect is appreciated.
In the case where the problem is with Java on my particular computer, this is an image of what is displayed on my screen when I run SSCCE, which loads three different JPanels with BoxLayouts along the y axis and puts a centered JLabel with only the “a” character in each : 
& here is the code for SSCCE:
import javax.swing.*; import java.awt.*; import javax.swing.border.*; public class AlignmentTest extends JPanel { public AlignmentTest(char label, int style) { JLabel l = new JLabel(Character.toString(label)); setBorder(BorderFactory.createLineBorder(Color.BLACK,1)); setBackground(Color.WHITE); setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); setPreferredSize(new Dimension(300,50)); add(Box.createVerticalGlue()); add(l); l.setFont(l.getFont().deriveFont(style)); l.setAlignmentX(CENTER_ALIGNMENT); l.setHorizontalAlignment(JLabel.CENTER); add(Box.createVerticalGlue()); } public static void main(String[] args) { JFrame f = new JFrame("Alignment Test"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLayout(new GridLayout(1,0,5,5)); f.add(new AlignmentTest('a',Font.PLAIN)); f.add(new AlignmentTest('a',Font.BOLD)); f.add(new AlignmentTest('a',Font.ITALIC)); f.pack(); f.setVisible(true); } public void paintComponent(Graphics g) { super.paintComponent(g); g.drawLine(getWidth()/2,0,getWidth()/2,getHeight()); } }
source share