Arrange the Label with its respective field Swing

前端 未结 6 1953
小鲜肉
小鲜肉 2021-01-20 18:06

I need to align all the fields with the respective labels,

\"enter

here is my

6条回答
  •  一个人的身影
    2021-01-20 19:05

    Thanks a lot for you help. I modified the code as follows and it worked..

    GroupLayout layout = new GroupLayout(getContentPane());
             getContentPane().setLayout(layout);
             layout.setAutoCreateGaps(true);
             layout.setAutoCreateContainerGaps(true);
    
             // Turn on automatically creating gaps between components that touch
             // the edge of the container and the container.
             layout.setAutoCreateContainerGaps(true);
    
             GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
             hGroup.addGroup(layout.createParallelGroup(Alignment.LEADING).
                     addComponent(ClientIP).addComponent(ClientPassword).addComponent(Videoname).addComponent(perccomplete).addComponent(PacketsSent).addComponent(Connectiontype).addComponent(noofvideossent));
    
             hGroup.addGroup(layout.createParallelGroup(Alignment.LEADING).
                     addComponent(ip).addComponent(pass).addComponent(vname).addComponent(percent).
                     addComponent(pacsent).addComponent(conntype).addComponent(videosend).addComponent(disconnect).addComponent(refresh).addComponent(ok));
             layout.setHorizontalGroup(hGroup);
    
    
             GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup();
    
             vGroup.addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(ClientIP).addComponent(ip)).addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(ClientPassword).addComponent(pass)).addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(Videoname).addComponent(vname)).addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(perccomplete).addComponent(percent)).addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(PacketsSent).addComponent(pacsent)).addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(Connectiontype).addComponent(conntype)).addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(noofvideossent).addComponent(videosend));
    
             vGroup.addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(disconnect)).addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(refresh)).addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(ok));
             layout.setVerticalGroup(vGroup);
    

提交回复
热议问题