So I have the following Java Code which produces what you see in the image. The layout is pretty much what I wanted except that the buttons are stretched to be equal size and fill. Is there anyway to avoid this without using GridBagLayout like other answers suggest? I tried setting the size of the panel inside to something smaller but it got stretched anyway.
Code:
    //Set-up main window
    JFrame mainwindow = new JFrame();
    mainwindow.setSize(500, 500);
    mainwindow.setTitle("Example");
    //Add components
    JTabbedPane tabs = new JTabbedPane();
    GridLayout experimentLayout = new GridLayout(0,2,0,5);
    JPanel pnl_Logon = new JPanel();
    pnl_Logon.setLayout(experimentLayout);
    JLabel lbl_Username = new JLabel("Username: ");
    JLabel lbl_Password = new JLabel("Password: ");
    JTextField txt_Username = new JTextField(10);
    JPasswordField psw_Password = new JPasswordField(10);
    JButton btn_Logon = new JButton("Logon");
    JButton btn_Clear = new JButton("Clear");
    pnl_Logon.add(lbl_Username);
    pnl_Logon.add(txt_Username);
    pnl_Logon.add(lbl_Password);
    pnl_Logon.add(psw_Password);
    pnl_Logon.add(btn_Logon);
    pnl_Logon.add(btn_Clear);
    tabs.addTab("Logon", pnl_Logon);
    //Draw window
    mainwindow.add(tabs);
    mainwindow.show();
Result:

 
     
    
 
     
    
