对话框排版示例

/**
  * This method initializes jAttributeScrollPane 
  *  创建相应的在窗口中的控件
  * @return javax.swing.JScrollPane 
  */
 private JScrollPane getJAttributeScrollPane() {
  if (jAttributeScrollPane == null) {
   jAttributeScrollPane = new JScrollPane();
   jAttributeScrollPane.setLayout(new ScrollPaneLayout());

   jPoNorthPane = new JPanel();
   jPoNorthPane.setLayout(new GridBagLayout());
   
   // 表示起始位置的参数
   int posX = 0;
   int posY = 0;
   // paraId
   posX = posX + 1;
   jParaIdLabel = new JLabel("abcId");
   jPoNorthPane.add(jParaIdLabel, new GridBagConstraints(posX, posY, 1, 1, 0.0, 0.0
              ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
   posX = posX + 1;
   jParaIdTextField = new JTextField();
   jParaIdTextField.setPreferredSize(new Dimension(300, 20));
   jPoNorthPane.add(jParaIdTextField, new GridBagConstraints(posX, posY, 1, 1, 1.0, 0.0
              ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 1, 0));   
   
   //ParaClmnName
   posX = 0;
   posY = posY + 1;
   jParaClmnNameLabel = new JLabel("ParaClmnName");
   jPoNorthPane.add(jParaClmnNameLabel, new GridBagConstraints(posX, posY, 1, 1, 0.0, 0.0
              ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
   posX = posX + 1;
   jParaClmnNameTextField = new JTextField();
   jParaClmnNameTextField.setPreferredSize(new Dimension(300, 20));
   jPoNorthPane.add(jParaClmnNameTextField, new GridBagConstraints(posX, posY, 1, 1, 1.0, 0.0
              ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 1, 0));
   posX = posX + 1;
   jParaDataTypeLabel = new JLabel("DataType");
   jPoNorthPane.add(jParaDataTypeLabel, new GridBagConstraints(posX, posY, 1, 1, 0.0, 0.0
              ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
   posX = posX + 1;
   jParaDataTypeComboBox = new JComboBox();
   jParaDataTypeComboBox.setFont(jParaIdTextField.getFont());
   jParaDataTypeComboBox.setPreferredSize(new Dimension(300, 20));
   jPoNorthPane.add(jParaDataTypeComboBox, new GridBagConstraints(posX, posY, 1, 1, 1.0, 0.0
              ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 1, 0));
   }

你可能感兴趣的:(对话框排版示例)