我在调整组合框时遇到问题,使其更接近“乐队目录”标签。我如何将组合框向左移动,距离标签仅 5px。我已经尝试为我的标签设置水平插图和为我的组合框设置负插图,但这仍然不起作用。
这是我的代码:
public void createGUI()
{
main_panel = new JPanel();
main_panel.setLayout(new GridBagLayout());
GridBagConstraints gc = new GridBagConstraints();
label = new JLabel("Band Directory:");
band_combobox = new JComboBox();
members_panel = new JPanel();
members_panel.setBorder(title);
members_list = new JLabel();
members_panel.add(members_list);
gc.fill = GridBagConstraints.HORIZONTAL;
gc.gridx = 0;
gc.gridy = 0;
gc.insets = new Insets(0, 0, 10, 0);
main_panel.add(label, gc);
gc.fill = GridBagConstraints.HORIZONTAL;
gc.gridx = 1;
gc.gridy = 0;
gc.insets = new Insets(0, 0, 10, 0);
main_panel.add(band_combobox, gc);
gc.fill = GridBagConstraints.HORIZONTAL;
gc.gridx = 0;
gc.gridy = 1;
gc.insets = new Insets(0, 0, 10, 0);
main_panel.add(members_panel, gc);
//more code
}