7buju方式中完整代码:
java.awt.GridBagConstraints gridBagConstraints;
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new java.awt.GridBagLayout());
jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
java.awt.GridBagLayout jPanel1Layout = new java.awt.GridBagLayout();
jPanel1Layout.columnWidths = new int[] {0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0};
jPanel1Layout.rowHeights = new int[] {0, 5, 0, 5, 0, 5, 0};
jPanel1.setLayout(jPanel1Layout);
jLabel1.setText("姓名");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
jPanel1.add(jLabel1, gridBagConstraints);
jTextField1.setText("abc");
jTextField1.setPreferredSize(new java.awt.Dimension(6, 21));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
jPanel1.add(jTextField1, gridBagConstraints);
jLabel2.setText("性别");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 4;
gridBagConstraints.gridy = 0;
jPanel1.add(jLabel2, gridBagConstraints);
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "男", "女" }));
jComboBox1.setMinimumSize(new java.awt.Dimension(6, 21));
jComboBox1.setPreferredSize(new java.awt.Dimension(6, 21));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 6;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
jPanel1.add(jComboBox1, gridBagConstraints);
jLabel3.setText("出生日期");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 8;
gridBagConstraints.gridy = 0;
jPanel1.add(jLabel3, gridBagConstraints);
jTextField2.setText("2000-01-01");
jTextField2.setPreferredSize(new java.awt.Dimension(6, 21));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 10;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
jPanel1.add(jTextField2, gridBagConstraints);
jLabel4.setText("国籍");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 12;
gridBagConstraints.gridy = 0;
jPanel1.add(jLabel4, gridBagConstraints);
jTextField3.setText("中国");
jTextField3.setPreferredSize(new java.awt.Dimension(6, 21));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 14;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
jPanel1.add(jTextField3, gridBagConstraints);
jLabel5.setText("证件名称");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
jPanel1.add(jLabel5, gridBagConstraints);
jTextField4.setText("身份证");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = 5;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
jPanel1.add(jTextField4, gridBagConstraints);
jLabel6.setText("号码");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 8;
gridBagConstraints.gridy = 2;
jPanel1.add(jLabel6, gridBagConstraints);
jTextField5.setText("123456789");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 10;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = 5;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
jPanel1.add(jTextField5, gridBagConstraints);
jLabel7.setText("代号");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 4;
jPanel1.add(jLabel7, gridBagConstraints);
jTextField6.setText("A1");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 4;
gridBagConstraints.gridwidth = 5;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
jPanel1.add(jTextField6, gridBagConstraints);
jLabel8.setText("档案编号");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 8;
gridBagConstraints.gridy = 4;
jPanel1.add(jLabel8, gridBagConstraints);
jTextField7.setText("123456789");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 10;
gridBagConstraints.gridy = 4;
gridBagConstraints.gridwidth = 5;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
jPanel1.add(jTextField7, gridBagConstraints);
jLabel9.setText("邮寄地址");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 6;
jPanel1.add(jLabel9, gridBagConstraints);
jTextField8.setText("ABC-123");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 6;
gridBagConstraints.gridwidth = 5;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
jPanel1.add(jTextField8, gridBagConstraints);
jLabel10.setText("联系德律风");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 8;
gridBagConstraints.gridy = 6;
jPanel1.add(jLabel10, gridBagConstraints);
jTextField9.setText("852963");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 10;
gridBagConstraints.gridy = 6;
gridBagConstraints.gridwidth = 5;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
jPanel1.add(jTextField9, gridBagConstraints);
jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
jPanel2.setOpaque(false);
jPanel2.setPreferredSize(new java.awt.Dimension(80, 100));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 16;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridheight = 7;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
jPanel1.add(jPanel2, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
getContentPane().add(jPanel1, gridBagConstraints);
setSize(new java.awt.Dimension(541, 334));
setLocationRelativeTo(null);