java客户端布局 GroupLayout 控件、按钮等布局
javax.swing.GroupLayout jHisDataPanelLayout = new javax.swing.GroupLayout(this.jHisDataPanel);
this.jHisDataPanel.setLayout(jHisDataPanelLayout);
jHisDataPanelLayout.setHorizontalGroup(//水平
jHisDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)//水平并行添加三个子面板
.addGroup(jHisDataPanelLayout.createSequentialGroup()//子面板1——top面板(之所以要用addGrop,是因为该面板里面又包含控件;子面板水平串行放置)
.addContainerGap()//容器间隔
.addComponent(jlblHisTitle)//添加title控件,
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)//设置title大小和位置
.addComponent(jlblHisDate)//添加
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSpnDateFrom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)//添加
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jlblHisLevel)//添加
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jCbxHisLevel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jHisTxtName)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbtnHisSearch)
.addGap(18)
)
.addGroup(jHisDataPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(this.jHisScrollPane)
.addContainerGap()
)
.addGroup(jHisDataPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(this.jTablePaggerEx2)
.addContainerGap()
)
.addGroup(jHisDataPanelLayout.createSequentialGroup()
.addContainerGap()
.addGap(760)////水平间隙
.addComponent(this.jbtnCloseAllSound, 120, 120, 120)//.addComponent(jbtnCloseAll, 120, 120, 120)
.addContainerGap()
)
);
jHisDataPanelLayout.setVerticalGroup(
jHisDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jHisDataPanelLayout.createSequentialGroup()
.addGroup(jHisDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jlblHisTitle)
.addComponent(jlblHisDate, 24, 24, 24)
.addComponent(jlblHisLevel, 24, 24, 24)
.addComponent(jCbxHisLevel, 24, 24, 24)
.addComponent(jHisTxtName, 25, 25, 25)
.addComponent(jbtnHisSearch, 24, 24, 24)
.addComponent(jSpnDateFrom, 26, 26, 26)
)
.addGap(5)
.addGroup(jHisDataPanelLayout.createSequentialGroup()
.addComponent(this.jHisScrollPane))
.addGap(5)
.addGroup(jHisDataPanelLayout.createSequentialGroup()
.addComponent(this.jTablePaggerEx2))
.addGap(5)
.addGroup(jHisDataPanelLayout.createParallelGroup()
.addGap(18)//垂直间隙
.addComponent(this.jbtnCloseAllSound, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap()
//jbtnCloseAll, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE
)
);
一下是参考的控件和位置