title: How to center elements in the BoxLayout using center of the element?
body: <p>I use <code>outputPanel.setLayout(new BoxLayout(outputPanel, BoxLayout.Y_AXIS));</code> and then I add elements (for example JLabels, JButtons) to the <code>outputPanel</code>. For example: <code>outputPanel.add(submitButton);</code>.</p>
  
  <p>I see that all added elements are "centered". It is good, because I do want my elements to be in the center. When I write "center" I mean "equal distance from left and right". But the problem is that the left part of the element is put into the center. And I want to have center of elements to be put into the center. How can I get this behavior? </p>