Hi.. I have 3 JPanels. (one) JPanel contains the scrollpane and the (two) JPanel contains a JButton. I am adding (one) + (two) into (combine) JPanel and then adding to the frame.Now I am really having a hard time align the scrollpane and the Jbutton. scroll pane is coming squeezed in the center and the Jbutton is squeezing it by staying on the right hand side alongwith it. I tried many methods below commented but not able to set the location of JButton and size and position of scrollpane.
I want the scrollpane in the center and button on the buttom.

Can anybody suggest whats going wrong ?

JScrollPane scroll = new JScrollPane(table);
    Container contentPane = getContentPane();
    JButton button1 = new JButton("MyButton");
    JPanel one = new JPanel();
    JPanel two = new JPanel();
    //two.setSize(new Dimension(800,200));
    //two.setPreferredSize(new Dimension(800, 200));
    //two.setBounds(0, 0, 0, 0);

    JPanel combine = new JPanel();


Are you wanting to stick with a certain layout? Or are you willing to try out other layouts? If you are, you could use a gridBagLayout and set the x and y weight to how you are wanting it to adjust.

I believe that will do what you are looking for, if I read you correctly