Question: I am trying to achieve the following effect in Java:

![input panel](https://i.imgur.com/cXgdxG6.jpg)

However, I am not sure what layout to use and how. `FlowLayout` obviously doesn't work. `GridLayout` won't work either because the first 4 rows are supposed to be 1 column rows, but the 5th row needs to have 2 columns.

This is my code so far:

```
public class DepositPanel extends JPanel
{
    private JLabel cashL, checksL;
    private JTextField cashTF, checksTF;
    private JButton ok, cancel;

    DepositPanel()
    {
        JPanel depositP = new JPanel();
        depositP.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 2));
        depositP.setPreferredSize(new Dimension(250, 85));

        JTextField cashTF = new JTextField(22);
        JTextField checksTF = new JTextField(22);

        JLabel cashL = new JLabel("Cash:");
        JLabel checksL = new JLabel("Checks:");

        ok = new JButton("OK");
        cancel = new JButton("CANCEL");

        depositP.add(cashL);
        depositP.add(cashTF);
        depositP.add(checksL);
        depositP.add(checksTF);
        depositP.add(ok);
        depositP.add(cancel):
    }
}

```

Answer: 
There are many ways to achieve a layout like this. The first thing you need to get used to, is that its often *simpler* to split up different requirements into different containers using different layout managers.

If you separate the two buttons into their own panel and treat that panel with the buttons as "just another line" in the window, you can basically just use a GridLayout with a single column. The panel with the buttons could then use a FlowLayout to place the buttons side by side.
Try this:

```
public class Window extends JFrame{
....
}

JLabel example;
//Constructor
public Window(){
    example = new JLabel("Sample text");
    example.setBounds(x,y,width,height)
    //JComponent...
    setLayout(null);
    setSize(width,height);
    setVisible(true);
}

```

Without the JPanel you can specify the x and y coordinates