Java的新手和全新的站点。我有一个JLabel添加到BorderLayout的中心面板。我希望JLabel位于面板的中央;setAlignmentX似乎有效,但setAlignmentY无效(标签显示在面板顶部)。这是代码:centerPanel=newJPanel();centerPanel.setLayout(newBoxLayout(centerPanel,BoxLayout.Y_AXIS));JLabellabel=newJLabel("Thisshouldbecentered");label.setAlignmentX(Component.CENTER_ALIGNMENT)