for (int i = 0; i < 4; i++) {
GridLayout gridLayout = new GridLayout(4, 1);
thisPanel.setLayout(gridLayout);
Box outerBox = Box.createVerticalBox();
final Box innerBox = Box.createHorizontalBox();
final JLabel prefixLabel = new JLabel();
final JLabel suffixInfoLabel = new JLabel();
outerBox.add(Box.createHorizontalStrut(10));
innerBox.add(Box.createHorizontalStrut(10));
innerBox.add(prefixLabel);
innerBox.add(Box.createHorizontalStrut(10));
innerBox.add(suffixInfoLabel);
innerBox.add(Box.createHorizontalStrut(10));
thisPanel.add(innerBox);
thisPanel.add(outerBox);
}
现在由于suffixInfoLabel长度不同,prefixLabel 的大小被不同程度的扩大了,最后出来的效果变成了右对齐,怎样才能左对齐呢
GridLayout gridLayout = new GridLayout(4, 1);
thisPanel.setLayout(gridLayout);
Box outerBox = Box.createVerticalBox();
final Box innerBox = Box.createHorizontalBox();
final JLabel prefixLabel = new JLabel();
final JLabel suffixInfoLabel = new JLabel();
outerBox.add(Box.createHorizontalStrut(10));
innerBox.add(Box.createHorizontalStrut(10));
innerBox.add(prefixLabel);
innerBox.add(Box.createHorizontalStrut(10));
innerBox.add(suffixInfoLabel);
innerBox.add(Box.createHorizontalStrut(10));
thisPanel.add(innerBox);
thisPanel.add(outerBox);
}
现在由于suffixInfoLabel长度不同,prefixLabel 的大小被不同程度的扩大了,最后出来的效果变成了右对齐,怎样才能左对齐呢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货