GroupLayout thisLayout = new GroupLayout(getContentPane());
thisLayout.setVerticalGroup(thisLayout.createSequentialGroup()
.addContainerGap(54, 54).addGroup(
thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(ipAddress,
GroupLayout.Alignment.BASELINE,
GroupLayout.PREFERRED_SIZE, 26,
GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1,
GroupLayout.Alignment.BASELINE,
GroupLayout.PREFERRED_SIZE, 23,
GroupLayout.PREFERRED_SIZE)
)
.addGap(25).addGroup(
thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2,
GroupLayout.Alignment.BASELINE,
GroupLayout.PREFERRED_SIZE, 20,
GroupLayout.PREFERRED_SIZE)
.addComponent(port,
GroupLayout.Alignment.BASELINE,
GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE)
)
.addGap(0, 20, Short.MAX_VALUE).addComponent(connect,
GroupLayout.PREFERRED_SIZE, 33,
GroupLayout.PREFERRED_SIZE).addContainerGap());
thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup()
.addContainerGap(17, 17).addGroup(thisLayout.createParallelGroup()
.addGroup(
GroupLayout.Alignment.LEADING,
thisLayout.createSequentialGroup()
.addComponent(jLabel2,
GroupLayout.PREFERRED_SIZE, 68,
GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
)
.addComponent(jLabel1,
GroupLayout.Alignment.LEADING,
GroupLayout.PREFERRED_SIZE,73,
GroupLayout.PREFERRED_SIZE))
.addGroup(thisLayout.createParallelGroup()
.addGroup(
GroupLayout.Alignment.LEADING,
thisLayout.createSequentialGroup()
.addComponent(connect,
GroupLayout.PREFERRED_SIZE,101,
GroupLayout.PREFERRED_SIZE)
.addGap(0,71,Short.MAX_VALUE))
.addGroup(
thisLayout .createSequentialGroup()
.addPreferredGap(connect,
port,
LayoutStyle.ComponentPlacement.INDENT)
.addGroup(thisLayout.createParallelGroup()
.addComponent(port,
GroupLayout.Alignment.LEADING,0,160,
Short.MAX_VALUE)
.addGroup(
thisLayout
.createSequentialGroup()
.addComponent(ipAddress,
GroupLayout.PREFERRED_SIZE, 160,
GroupLayout.PREFERRED_SIZE)
.addGap(0,0,Short.MAX_VALUE)))))
.addContainerGap());
这段代码大致是啥意思?初接触Java,请大侠指教。
------解决方案--------------------
网格布局管理(GridLayout)自己查查API