title: java swing aligning radiobuttons
body: <p>I want to center my radibuttons in the panel, but when I center it centers according to the lenght of the text of the button, so yes they are centered but not aligned each other and look very ugly. How can I fix my code?</p>
  
  <pre><code>radioButtonMenuPanel = new JPanel();
      radioButtonMenuPanel.setLayout(new BoxLayout(radioButtonMenuPanel,
              BoxLayout.PAGE_AXIS));
  
      ButtonGroup group = new ButtonGroup();
      for (String item : answerItems) {
          JRadioButton radioButton = new JRadioButton(item);
          radioButton.setAlignmentX(Component.Center_ALIGNMENT);
          radioButtonMenuPanel.add(radioButton);
          group.add(radioButton);
      }
  </code></pre>