After some years working in Java in the back end I ended up working in a project to build a GUI and Java Swing is driving me crazy.
So I am doing some tests with the JScrollPane, because I have a JPanel that is too big to fit in the screen. In the following example I am adding couple buttons to a JPanel and then creating a JScrollPane with the JPanel, but nothing appears in the screen.
import java.awt.Container;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
public class TestScrollPane extends JDialog {
    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        try {
            TestScrollPane dialog = new TestScrollPane();
            dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            dialog.setVisible(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * Create the dialog.
     */
    public TestScrollPane() {
        setBounds(100, 100, 857, 541);
        getContentPane().setLayout(null);
        {
            JPanel panel = new JPanel();
            panel.setBounds(131, 167, 141, 221);
            getContentPane().add(panel);
            panel.setLayout(null);
            {
                JButton btnNewButton = new JButton("New button");
                btnNewButton.setBounds(0, 0, 115, 29);
                panel.add(btnNewButton);
            }
            {
                JButton btnNewButton_1 = new JButton("New button");
                btnNewButton_1.setBounds(26, 192, 115, 29);
                panel.add(btnNewButton_1);
            }
             JScrollPane jsp = new JScrollPane(panel);
             getContentPane().add(jsp);
        }
        {
            JPanel buttonPane = new JPanel();
            buttonPane.setBounds(0, 446, 835, 39);
            buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
            getContentPane().add(buttonPane);
            {
                JButton okButton = new JButton("OK");
                okButton.setActionCommand("OK");
                buttonPane.add(okButton);
                getRootPane().setDefaultButton(okButton);
            }
            {
                JButton cancelButton = new JButton("Cancel");
                cancelButton.setActionCommand("Cancel");
                buttonPane.add(cancelButton);
            }
        }       
    }
}
I don't understand why is not appearing. I create the JPanel I add the buttons, and the the JScrollPane, which I add to the window. I am using WindwBuilder Pro that's why the code looks so weird.
Thanks.
 
     
     
    