为此创建一个新的JPanel
并使用组布局。
像这样 http://img163.imageshack.us/img163/1403/capturadepantalla201001bo.png
使用组布局允许您指定将进入水平组的组件和将进入垂直组的组件。
c1, c2, c3
c4, c5, c6
panel[ c7, c8, c9 ]
这是我布局上面的图像的方式:
// Layout Horizontal components
layout.setHorizontalGroup(
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent( c1 )
.addComponent( c4 )
).addGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent( c2 )
.addComponent( c5)
).addGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent( c3 )
.addComponent( c6 )
)
);
// Layout vertical components
layout.setVerticalGroup(
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent( c1 )
.addComponent( c2 )
.addComponent( c3 )
).addGroup(
layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent( c4 )
.addComponent( c5 )
.addComponent( c6 )
)
);
southPanel.add( panel ); // the start-end dates
southPanel.add( bookIt, BorderLayout.SOUTH ); // the enter your name...
试试看。