pack();函数调用PreferedSize();
所以对于组件要setPreferedSize();
转载于:https://www.cnblogs.com/ppCola/p/10178446.html