我不知道到底出了什么问题,看看它们看起来怎么样
请注意,最后3个窗格在对齐方面不正确,但它们使用与前两个相同的代码。这是代码。
import javax.swing.BorderFactory;
public class View_RegisterMember extends JDialog {
private static final long serialVersionUID = -4610105372782292470L;
private JDialog dialog;
// Panels
private JPanel pdPanel;
private JPanel addressPanel;
private JPanel cdpanel;
private JPanel memDetails;
private Border blackline;
private JLabel lblTitle;
private JLabel lblFirstName;
private JLabel lblSurname;
private JLabel lblStreetNo;
private JLabel lblStreetName;
private JLabel lblCity;
private JLabel lblPostcode;
private JLabel lblPhoneNo;
private JLabel lblEmail;
private JLabel lblMembershipType;
private JLabel lblPrice;
private JLabel lblpriceData;
private JLabel lblDob;
// textfields
private JTextField textphoneData;
private JTextField textFieldEmailData;
@SuppressWarnings("rawtypes")
private JComboBox comboBoxTitle;
private JTextField textFieldfName;
private JTextField textFieldlName;
private JTextField textFieldNumber;
private JTextField textFieldStreetName;
private JTextField textFieldCity;
private JTextField textFieldPostCode;
private JTextField textFieldDOB;
private JComboBox<String> comboBoxMemType;
private JButton btnSave;
private JPanel bdPanel;
private JLabel lblAccountName;
private JTextField textFieldAccName;
private JLabel labelSortCode;
private JTextField textFieldSortCode;
private JLabel lblAccNo;
private JTextField textFieldAccNo;
public View_RegisterMember(final JFrame frame) {
dialog = this;
blackline = BorderFactory.createLineBorder(Color.black);
dialog.setTitle("Member Registration");
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent arg0) {
frame.setEnabled(true);
}
});
GridBagLayout gridBagLayout = new GridBagLayout();
createBagLayouts(gridBagLayout);
getContentPane().setLayout(gridBagLayout);
createPersonalDetailsPane();
createAddressDetailsPane();
createContactDetailsPane();
createBankDetailsPane();
createMemberTypeDetailsPane();
// createAppointmentsPane();
// frame.setSize(new Dimension(335, 650));
btnSave = new JButton("Register");
btnSave.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
}
});
btnSave.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
gbc_btnNewButton.fill = GridBagConstraints.HORIZONTAL;
gbc_btnNewButton.insets = new Insets(0, 0, 5, 5);
gbc_btnNewButton.gridx = 1;
gbc_btnNewButton.gridy = 10;
getContentPane().add(btnSave, gbc_btnNewButton);
dialog.setResizable(true);
dialog.pack();
dialog.validate();
dialog.repaint();
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private void createPersonalDetailsPane() {
pdPanel = new JPanel();
GridBagConstraints gbc_dpPanel = new GridBagConstraints();
gbc_dpPanel.fill = GridBagConstraints.HORIZONTAL;
gbc_dpPanel.insets = new Insets(0, 0, 5, 5);
gbc_dpPanel.gridx = 1;
gbc_dpPanel.gridy = 1;
getContentPane().add(pdPanel, gbc_dpPanel);
GridBagLayout gbl_panel = new GridBagLayout();
gbl_panel.columnWeights = new double[]{0.0, 1.0};
pdPanel.setBorder(new TitledBorder(blackline, "Personal Details",
TitledBorder.LEADING, TitledBorder.ABOVE_TOP, null,
SystemColor.inactiveCaptionText));
pdPanel.setLayout(gbl_panel);
lblTitle = new JLabel("Title:");
//lblTitle.setHorizontalAlignment(SwingConstants.LEFT);
GridBagConstraints gbc_lblTitle = new GridBagConstraints();
gbc_lblTitle.anchor = GridBagConstraints.WEST;
gbc_lblTitle.insets = new Insets(0, 0, 5, 5);
gbc_lblTitle.gridx = 0;
gbc_lblTitle.gridy = 0;
pdPanel.add(lblTitle, gbc_lblTitle);
lblTitle.setFont(new Font("Dialog", Font.PLAIN, 18));
try {
comboBoxTitle = new JComboBox(Controller_Registration.GetTitles());
} catch (Exception_Database e) {
utilities.DisplayError(e.getMessage(), dialog);
}
comboBoxTitle.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_comboBoxTitle = new GridBagConstraints();
gbc_comboBoxTitle.anchor = GridBagConstraints.EAST;
//gbc_comboBoxTitle.fill = GridBagConstraints.BOTH;
gbc_comboBoxTitle.insets = new Insets(0, 0, 5, 0);
gbc_comboBoxTitle.gridx = 1;
gbc_comboBoxTitle.gridy = 0;
// Minus the one to match up the SQL ids with the index
comboBoxTitle.setSelectedIndex(1);
pdPanel.add(comboBoxTitle, gbc_comboBoxTitle);
lblFirstName = new JLabel("Name:");
//lblFirstName.setHorizontalAlignment(SwingConstants.LEFT);
GridBagConstraints gbc_lblFirstName = new GridBagConstraints();
gbc_lblFirstName.anchor = GridBagConstraints.WEST;
gbc_lblFirstName.insets = new Insets(0, 0, 5, 5);
gbc_lblFirstName.gridx = 0;
gbc_lblFirstName.gridy = 1;
pdPanel.add(lblFirstName, gbc_lblFirstName);
lblFirstName.setFont(new Font("Dialog", Font.PLAIN, 18));
textFieldfName = new JTextField();
textFieldfName.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_textFieldfName = new GridBagConstraints();
gbc_textFieldfName.anchor = GridBagConstraints.EAST;
gbc_textFieldfName.insets = new Insets(0, 0, 5, 0);
gbc_textFieldfName.gridx = 1;
gbc_textFieldfName.gridy = 1;
pdPanel.add(textFieldfName, gbc_textFieldfName);
textFieldfName.setColumns(10);
lblSurname = new JLabel("Surname:");
//lblSurname.setHorizontalAlignment(SwingConstants.LEFT);
GridBagConstraints gbc_lblSurname = new GridBagConstraints();
gbc_lblSurname.anchor = GridBagConstraints.WEST;
gbc_lblSurname.insets = new Insets(0, 0, 5, 5);
gbc_lblSurname.gridx = 0;
gbc_lblSurname.gridy = 2;
pdPanel.add(lblSurname, gbc_lblSurname);
lblSurname.setFont(new Font("Dialog", Font.PLAIN, 18));
textFieldlName = new JTextField();
textFieldlName.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_textFieldlName = new GridBagConstraints();
gbc_textFieldlName.anchor = GridBagConstraints.EAST;
gbc_textFieldlName.insets = new Insets(0, 0, 5, 0);
gbc_textFieldlName.gridx = 1;
gbc_textFieldlName.gridy = 2;
pdPanel.add(textFieldlName, gbc_textFieldlName);
textFieldlName.setColumns(10);
lblDob = new JLabel("D.O.B:");
//lblDob.setHorizontalAlignment(SwingConstants.LEFT);
lblDob.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_lblDob = new GridBagConstraints();
gbc_lblDob.anchor = GridBagConstraints.WEST;
gbc_lblDob.insets = new Insets(0, 0, 5, 5);
gbc_lblDob.gridx = 0;
gbc_lblDob.gridy = 3;
pdPanel.add(lblDob, gbc_lblDob);
textFieldDOB = new JTextField();
textFieldDOB.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_textFieldDOB = new GridBagConstraints();
gbc_textFieldDOB.anchor = GridBagConstraints.EAST;
gbc_textFieldDOB.gridx = 1;
gbc_textFieldDOB.gridy = 3;
pdPanel.add(textFieldDOB, gbc_textFieldDOB);
textFieldDOB.setColumns(10);
}
private void createAddressDetailsPane() {
addressPanel = new JPanel();
GridBagConstraints gbc_addressPanel = new GridBagConstraints();
gbc_addressPanel.fill = GridBagConstraints.HORIZONTAL;
gbc_addressPanel.insets = new Insets(0, 0, 5, 5);
gbc_addressPanel.gridx = 1;
gbc_addressPanel.gridy = 3;
getContentPane().add(addressPanel, gbc_addressPanel);
GridBagLayout gbl_panel1 = new GridBagLayout();
gbl_panel1.columnWeights = new double[] { 0.0, 1.0 };
addressPanel.setBorder(new TitledBorder(blackline, "Address",
TitledBorder.LEADING, TitledBorder.ABOVE_TOP, null,
SystemColor.inactiveCaptionText));
createBagLayouts(gbl_panel1);
addressPanel.setLayout(gbl_panel1);
lblStreetNo = new JLabel("Street No:");
//lblStreetNo.setVerticalAlignment(SwingConstants.TOP);
//lblStreetNo.setHorizontalAlignment(SwingConstants.LEFT);
lblStreetNo.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_lblStreetNo = new GridBagConstraints();
gbc_lblStreetNo.anchor = GridBagConstraints.WEST;
gbc_lblStreetNo.gridx = 0;
gbc_lblStreetNo.insets = new Insets(0, 0, 5, 5);
gbc_lblStreetNo.gridy = 0;
addressPanel.add(lblStreetNo, gbc_lblStreetNo);
textFieldNumber = new JTextField();
textFieldNumber.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_textFieldNumber = new GridBagConstraints();
gbc_textFieldNumber.anchor = GridBagConstraints.EAST;
gbc_textFieldNumber.insets = new Insets(0, 0, 5, 0);
gbc_textFieldNumber.gridx = 1;
gbc_textFieldNumber.gridy = 0;
addressPanel.add(textFieldNumber, gbc_textFieldNumber);
textFieldNumber.setColumns(10);
lblStreetName = new JLabel("Street Name:");
//lblStreetName.setHorizontalAlignment(SwingConstants.CENTER);
lblStreetName.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_lblStreetName = new GridBagConstraints();
gbc_lblStreetName.anchor = GridBagConstraints.WEST;
gbc_lblStreetName.insets = new Insets(0, 0, 5, 5);
gbc_lblStreetName.gridx = 0;
gbc_lblStreetName.gridy = 1;
addressPanel.add(lblStreetName, gbc_lblStreetName);
textFieldStreetName = new JTextField();
textFieldStreetName.setFont(new Font("Dialog", Font.PLAIN, 18));
textFieldStreetName.setColumns(10);
GridBagConstraints gbc_textFieldStreetName = new GridBagConstraints();
gbc_textFieldStreetName.anchor = GridBagConstraints.EAST;
gbc_textFieldStreetName.insets = new Insets(0, 0, 5, 0);
gbc_textFieldStreetName.gridx = 1;
gbc_textFieldStreetName.gridy = 1;
addressPanel.add(textFieldStreetName, gbc_textFieldStreetName);
lblCity = new JLabel("City:");
//lblCity.setHorizontalAlignment(SwingConstants.LEFT);
lblCity.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_lblCity = new GridBagConstraints();
gbc_lblCity.anchor = GridBagConstraints.WEST;
gbc_lblCity.insets = new Insets(0, 0, 5, 5);
gbc_lblCity.gridx = 0;
gbc_lblCity.gridy = 2;
addressPanel.add(lblCity, gbc_lblCity);
textFieldCity = new JTextField();
textFieldCity.setFont(new Font("Dialog", Font.PLAIN, 18));
textFieldCity.setColumns(10);
GridBagConstraints gbc_textFieldCity = new GridBagConstraints();
gbc_textFieldCity.anchor = GridBagConstraints.EAST;
gbc_textFieldCity.insets = new Insets(0, 0, 5, 0);
gbc_textFieldCity.gridx = 1;
gbc_textFieldCity.gridy = 2;
addressPanel.add(textFieldCity, gbc_textFieldCity);
lblPostcode = new JLabel("Postcode:");
lblPostcode.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_lblPostcode = new GridBagConstraints();
gbc_lblPostcode.anchor = GridBagConstraints.WEST;
gbc_lblPostcode.insets = new Insets(0, 0, 5, 5);
gbc_lblPostcode.gridx = 0;
gbc_lblPostcode.gridy = 3;
addressPanel.add(lblPostcode, gbc_lblPostcode);
textFieldPostCode = new JTextField();
textFieldPostCode.setFont(new Font("Dialog", Font.PLAIN, 18));
textFieldPostCode.setColumns(10);
GridBagConstraints gbc_textFieldPostCode = new GridBagConstraints();
gbc_textFieldPostCode.anchor = GridBagConstraints.EAST;
gbc_textFieldPostCode.gridx = 1;
gbc_textFieldPostCode.gridy = 3;
addressPanel.add(textFieldPostCode, gbc_textFieldPostCode);
}
private void createContactDetailsPane() {
cdpanel = new JPanel();
GridBagConstraints gbc_cdpanel = new GridBagConstraints();
gbc_cdpanel.fill = GridBagConstraints.HORIZONTAL;
gbc_cdpanel.insets = new Insets(0, 0, 5, 5);
gbc_cdpanel.gridx = 1;
gbc_cdpanel.gridy = 5;
getContentPane().add(cdpanel, gbc_cdpanel);
GridBagLayout gbl_cdpanel = new GridBagLayout();
gbl_cdpanel.columnWeights = new double[] { 0.0, 1.0 };
cdpanel.setBorder(new TitledBorder(blackline, "Contact Details",
TitledBorder.LEADING, TitledBorder.ABOVE_TOP, null,
SystemColor.inactiveCaptionText));
createBagLayouts(gbl_cdpanel);
cdpanel.setLayout(gbl_cdpanel);
lblPhoneNo = new JLabel("Phone No:");
//lblPhoneNo.setHorizontalAlignment(SwingConstants.LEFT);
lblPhoneNo.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_lblPhoneNo = new GridBagConstraints();
gbc_lblPhoneNo.anchor = GridBagConstraints.WEST;
gbc_lblPhoneNo.insets = new Insets(0, 0, 5, 5);
gbc_lblPhoneNo.gridx = 0;
gbc_lblPhoneNo.gridy = 0;
cdpanel.add(lblPhoneNo, gbc_lblPhoneNo);
textphoneData = new JTextField();
textphoneData.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_textFieldEmailData = new GridBagConstraints();
gbc_textFieldEmailData.anchor = GridBagConstraints.EAST;
gbc_textFieldEmailData.insets = new Insets(0, 0, 5, 0);
gbc_textFieldEmailData.gridx = 1;
gbc_textFieldEmailData.gridy = 0;
cdpanel.add(textphoneData, gbc_textFieldEmailData);
textphoneData.setColumns(10);
lblEmail = new JLabel("Email:");
//lblEmail.setHorizontalAlignment(SwingConstants.LEFT);
lblEmail.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_lblEmail = new GridBagConstraints();
gbc_lblEmail.anchor = GridBagConstraints.WEST;
gbc_lblEmail.insets = new Insets(0, 0, 5, 5);
gbc_lblEmail.gridx = 0;
gbc_lblEmail.gridy = 1;
cdpanel.add(lblEmail, gbc_lblEmail);
textFieldEmailData = new JTextField();
textFieldEmailData.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_textFieldEmailData1 = new GridBagConstraints();
gbc_textFieldEmailData1.anchor = GridBagConstraints.EAST;
gbc_textFieldEmailData1.gridx = 1;
gbc_textFieldEmailData1.gridy = 1;
cdpanel.add(textFieldEmailData, gbc_textFieldEmailData1);
textFieldEmailData.setColumns(10);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private void createBankDetailsPane() {
bdPanel = new JPanel();
GridBagConstraints gbc_bdPanel = new GridBagConstraints();
gbc_bdPanel.fill = GridBagConstraints.HORIZONTAL;
gbc_bdPanel.insets = new Insets(0, 0, 5, 5);
gbc_bdPanel.gridx = 1;
gbc_bdPanel.gridy = 7;
getContentPane().add(bdPanel, gbc_bdPanel);
GridBagLayout gbl_bdPanel = new GridBagLayout();
gbl_bdPanel.columnWeights = new double[] { 0.0, 1.0 };
bdPanel.setBorder(new TitledBorder(blackline, "Payment Details",
TitledBorder.LEADING, TitledBorder.ABOVE_TOP, null,
SystemColor.inactiveCaptionText));
createBagLayouts(gbl_bdPanel);
bdPanel.setLayout(gbl_bdPanel);
lblAccountName = new JLabel("Acc Name:");
lblAccountName.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_lblAccountName = new GridBagConstraints();
gbc_lblAccountName.anchor = GridBagConstraints.WEST;
gbc_lblAccountName.insets = new Insets(0, 0, 5, 5);
gbc_lblAccountName.gridx = 0;
gbc_lblAccountName.gridy = 0;
bdPanel.add(lblAccountName, gbc_lblAccountName);
textFieldAccName = new JTextField();
textFieldAccName.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_textFieldAccName = new GridBagConstraints();
gbc_textFieldAccName.anchor = GridBagConstraints.EAST;
gbc_textFieldAccName.insets = new Insets(0, 0, 5, 0);
gbc_textFieldAccName.gridx = 1;
gbc_textFieldAccName.gridy = 0;
bdPanel.add(textFieldAccName, gbc_textFieldAccName);
textFieldAccName.setColumns(10);
labelSortCode = new JLabel("Sortcode:");
labelSortCode.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_labelSortCode = new GridBagConstraints();
gbc_labelSortCode.anchor = GridBagConstraints.WEST;
gbc_labelSortCode.insets = new Insets(0, 0, 5, 5);
gbc_labelSortCode.gridx = 0;
gbc_labelSortCode.gridy = 1;
bdPanel.add(labelSortCode, gbc_labelSortCode);
textFieldSortCode = new JTextField();
textFieldSortCode.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_textFieldSortCode = new GridBagConstraints();
gbc_textFieldSortCode.anchor = GridBagConstraints.EAST;
gbc_textFieldSortCode.insets = new Insets(0, 0, 5, 0);
gbc_textFieldSortCode.gridx = 1;
gbc_textFieldSortCode.gridy = 1;
bdPanel.add(textFieldSortCode, gbc_textFieldSortCode);
textFieldSortCode.setColumns(10);
lblAccNo = new JLabel("Acc No:");
lblAccNo.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_lblAccNo = new GridBagConstraints();
gbc_lblAccNo.anchor = GridBagConstraints.WEST;
gbc_lblAccNo.insets = new Insets(0, 0, 5, 5);
gbc_lblAccNo.gridx = 0;
gbc_lblAccNo.gridy = 2;
bdPanel.add(lblAccNo, gbc_lblAccNo);
textFieldAccNo = new JTextField();
textFieldAccNo.setFont(new Font("Dialog", Font.PLAIN, 18));
textFieldAccNo.setColumns(10);
GridBagConstraints gbc_textFieldAccNo = new GridBagConstraints();
gbc_textFieldAccNo.anchor = GridBagConstraints.EAST;
gbc_textFieldAccNo.gridx = 1;
gbc_textFieldAccNo.gridy = 2;
bdPanel.add(textFieldAccNo, gbc_textFieldAccNo);
}
private void createMemberTypeDetailsPane() {
memDetails = new JPanel();
GridBagConstraints gbc_memDetails = new GridBagConstraints();
gbc_memDetails.fill = GridBagConstraints.HORIZONTAL;
//gbc_memDetails.anchor = GridBagConstraints.NORTH;
gbc_memDetails.insets = new Insets(0, 0, 5, 5);
gbc_memDetails.gridx = 1;
gbc_memDetails.gridy = 9;
getContentPane().add(memDetails, gbc_memDetails);
GridBagLayout gbl_memDetails = new GridBagLayout();
gbl_memDetails.columnWeights = new double[] { 0.0, 1.0 };
memDetails.setBorder(new TitledBorder(blackline, "Membership Type",
TitledBorder.LEADING, TitledBorder.ABOVE_TOP, null,
SystemColor.inactiveCaptionText));
createBagLayouts(gbl_memDetails);
memDetails.setLayout(gbl_memDetails);
lblMembershipType = new JLabel("Type:");
lblMembershipType.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_lblMembershipType = new GridBagConstraints();
gbc_lblMembershipType.insets = new Insets(0, 0, 5, 5);
gbc_lblMembershipType.anchor = GridBagConstraints.WEST;
gbc_lblMembershipType.gridx = 0;
gbc_lblMembershipType.gridy = 0;
memDetails.add(lblMembershipType, gbc_lblMembershipType);
comboBoxMemType = new JComboBox(Controller_Member.getMemberTypes(null));
comboBoxMemType.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_comboBoxMemType = new GridBagConstraints();
gbc_comboBoxMemType.anchor = GridBagConstraints.EAST;
gbc_comboBoxMemType.insets = new Insets(0, 0, 5, 0);
gbc_comboBoxMemType.gridx = 1;
gbc_comboBoxMemType.gridy = 0;
memDetails.add(comboBoxMemType, gbc_comboBoxMemType);
lblPrice = new JLabel("Price:");
lblPrice.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_lblPrice = new GridBagConstraints();
gbc_lblPrice.anchor = GridBagConstraints.WEST;
gbc_lblPrice.insets = new Insets(0, 0, 0, 5);
gbc_lblPrice.gridx = 0;
gbc_lblPrice.gridy = 1;
memDetails.add(lblPrice, gbc_lblPrice);
lblpriceData = new JLabel("");
lblpriceData.setFont(new Font("Dialog", Font.PLAIN, 18));
GridBagConstraints gbc_lblpriceData = new GridBagConstraints();
gbc_lblpriceData.anchor = GridBagConstraints.EAST;
gbc_lblpriceData.gridx = 1;
gbc_lblpriceData.gridy = 1;
memDetails.add(lblpriceData, gbc_lblpriceData);
DecimalFormat ob = new DecimalFormat("0.00");
String price = "£"
+ ob.format(Controller_Member.getMembershipTypes()[0]
.GetPrice());
lblpriceData.setText(price);
comboBoxMemType.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
double price = Controller_Member.updatePrice(comboBoxMemType
.getSelectedIndex());
DecimalFormat ob = new DecimalFormat("0.00");
String priceLabel = "£" + ob.format(price);
lblpriceData.setText(priceLabel);
}
});
}
private void createBagLayouts(GridBagLayout gridBagLayout) {
gridBagLayout.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0 };
gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0 };
gridBagLayout.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, Double.MIN_VALUE };
gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
}
}
我错过了这么简单的事吗?
答案 0 :(得分:0)
删除对方法private void createBagLayouts(GridBagLayout gridBagLayout)
的所有调用,除了第一个(在对话框构造函数内)
这些调用会覆盖您窗格中的columnWeights
设置并搞砸了
请注意,第一个窗格没有调用createBagLayouts
方法,这就是它工作的原因。调用在第二个窗格上工作的唯一原因是因为它是最大的窗格,因此是确定整个对话框宽度的窗格。