解决方法
是的,在容器标签中使用带有BoxLayout的嵌套JLabel:
JLabel container = new JLabel(); container.setLayout(new BoxLayout(container,BoxLayout.X_AXIS)); JLabel icon1Label = new JLabel(); JLabel icon2Label = new JLabel(); icon1Label.setIcon(icon1); icon2Label.setIcon(icon2); container.add(icon1Label); container.add(icon2Label);