import java.awt.*;
import java.awt.Font.*;
import java.awt.event.*;
import java.util.Date;
import javax.swing.*;
import java.sql.*;
import javax.swing.border.*;public class HIMSDBA  extends JFrame  {
    public int  IDint2;
    public String YH_Name;
        public  String Sex1;
        public  int age;
         public String  JG;
          public  String DZ;
           public  String phone;
               public  String bm;
               public  String zw;
                    public  String gj;
           public  String E_Mail;
             public  String nowTime1;    Label lable10=new Label("公司员工注册界面");
      Label lable1=new Label("员工名称");
        Label lable11=new Label("性别");
Choice sex=new Choice();
        Label lable2=new Label("籍贯");
        Label lable3=new Label("地址");
        Label lable4=new Label("联系方式");
        Label lable5=new Label("所在部门");
        Label lable6=new Label("所在职位");
        Label lable7=new Label("E_Mail");
         Label lable8=new Label("年龄");
               Label lable9=new Label("国籍");
        JButton Button1=new JButton("注册");
              JButton Button2=new JButton("查看");
              TextField text1=new     TextField ();
               TextField text2=new     TextField ();
               TextField text3=new     TextField ();
               TextField text4=new     TextField ();
             TextField text5=new     TextField ();
                TextField text6=new     TextField ();
                TextField text7=new     TextField ();
                TextField text8=new     TextField ();
                TextField text9=new     TextField ();
                   public HIMSDBA (){
                       Box baseBox ,baseBox0 ,boxV0,boxV1,boxV2,boxV3,boxV5,boxV4;
    boxV0=Box.createVerticalBox();
      boxV0.add(lable10);
        lable10.setFont(new java.awt.Font("SansSerif",1,20));
               lable10.setForeground(Color.red);
       boxV1=Box.createVerticalBox();
      boxV1.add(lable1);
       boxV1.add(Box.createVerticalStrut(28));
      boxV1.add(lable11);
      boxV1.add(Box.createVerticalStrut(28));
      boxV1.add(lable2);
      boxV1.add(Box.createVerticalStrut(28));
       boxV1.add(lable8);
      boxV1.add(Box.createVerticalStrut(28));
      boxV1.add(lable9);      boxV2=Box.createVerticalBox();
      boxV2.add(text1);
             boxV2.add(Box.createVerticalStrut(48));
      boxV2.add(sex);
           boxV2.add(Box.createVerticalStrut(48));
      boxV2.add(text2);
      boxV2.add(Box.createVerticalStrut(48));
      boxV2.add(text3);
      boxV2.add(Box.createVerticalStrut(48));
      boxV2.add(text4);      boxV3=Box.createVerticalBox();
      boxV3.add(lable4);
       boxV3.add(Box.createVerticalStrut(28));
      boxV3.add(lable5);
        boxV3.add(Box.createVerticalStrut(28));
      boxV3.add(lable6);
          boxV3.add(Box.createVerticalStrut(28));
      boxV3.add(lable3);
      boxV3.add(Box.createVerticalStrut(28));
      boxV3.add(lable7);
      //boxV1.add(Box.createVerticalStrut(138));
     // boxV1.add(button1);
       boxV4=Box.createVerticalBox();
      boxV4.add(text5);
             boxV2.add(Box.createVerticalStrut(18));
      boxV4.add(text6);
             boxV2.add(Box.createVerticalStrut(18));
      boxV4.add(text7);
           boxV2.add(Box.createVerticalStrut(18));
      boxV4.add(text8);
                boxV2.add(Box.createVerticalStrut(18));
      boxV4.add(text9);         boxV5=Box.createHorizontalBox();
      boxV5.add(Button1);
      boxV5.add(Box.createHorizontalStrut(60));
     boxV5.add(Button2);      baseBox=Box.createHorizontalBox();
      baseBox.add(boxV1);
      baseBox.add(Box.createHorizontalStrut(22));
      baseBox.add(boxV2);
 baseBox.add(Box.createHorizontalStrut(22));
      baseBox.add(boxV3);
       baseBox.add(Box.createHorizontalStrut(22));
      baseBox.add(boxV4);
       baseBox0=Box.createVerticalBox();
      baseBox0.add(boxV0);
      baseBox0.add(Box.createVerticalStrut(38));
       baseBox0.add( baseBox);
       baseBox0.add(Box.createVerticalStrut(38));
       baseBox0.add(  boxV5);
      setLayout(new FlowLayout());      add(baseBox0);
      sex.add("男");
            sex.add("女");
    
       }
      public static void main(String[] args) {
          HIMSDBA HIMSDBA1=new HIMSDBA ();
          HIMSDBA1.setBounds(0, 0,760, 660);
          HIMSDBA1.setVisible(true);
        
    }
         }

解决方案 »

  1.   

    可以用null布局自己排列
    或者用GridLayout
      

  2.   

    下载 https://designgridlayout.dev.java.net/files/documents/4350/153962/designgridlayout-1.5.jarimport java.awt.*;
    import javax.swing.*;
    import net.java.dev.designgridlayout.DesignGridLayout;public class HIMS extends JFrame {
        private JTextField nameField = new JTextField(8);
        private JTextField contactField = new JTextField(12);
        private JComboBox sexCombo = new JComboBox();
        private JTextField departmentField = new JTextField();
        private JTextField birthplaceField = new JTextField();
        private JTextField jobsField = new JTextField();
        private JTextField ageField = new JTextField();
        private JTextField addressField = new JTextField();
        private JTextField countryField = new JTextField();
        private JTextField emailField = new JTextField();
        private JButton regButton = new JButton("注册");
        private JButton viewButton = new JButton("查看");    public HIMS(){
    super("HIMS"); DesignGridLayout layout = new DesignGridLayout(getContentPane());
    JLabel title = new JLabel("公司员工注册界面");
    title.setFont(new Font("SansSerif",Font.BOLD,20));
    title.setForeground(Color.RED);
    layout.row().center().add(title);
    layout.row().grid(new JLabel("员工名称")).add(nameField).grid(new JLabel("联系方式")).add(contactField);
    sexCombo.addItem("男");
    sexCombo.addItem("女");
    layout.row().grid(new JLabel("性别")).add(sexCombo).grid(new JLabel("所在部门")).add(departmentField);
    layout.row().grid(new JLabel("籍贯")).add(birthplaceField).grid(new JLabel("所在职位")).add(jobsField);
    layout.row().grid(new JLabel("年龄")).add(ageField).grid(new JLabel("地址")).add(addressField);
    layout.row().grid(new JLabel("国籍")).add(countryField).grid(new JLabel("电邮")).add(emailField);
    layout.row().bar().center(regButton,viewButton); setDefaultCloseOperation(EXIT_ON_CLOSE);
    pack();
        }    public static void main(final String[] args) {
    java.awt.EventQueue.invokeLater(new Runnable(){
    public void run(){
        new HIMS().setVisible(true);
    }
        });
        }
    }