唉,这个东西,搞了半天,最后发现就三句话就能搞定,伤不起…… Dimension d = box.getPreferredSize(); box.setMaximumSize(d); bar.add(box);