0

I have added a JScrollPane to my JPanel because is too big, the bar appears correctly but when I press the arrows nothing happens.

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);
             jsp.setBounds(131, 167, 141, 100);
             jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);



        }
        {
            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 cannot understand what is missing, the bar is there, the arrows are there but it's just does not work. Thanks again.

Eduardo
  • 19,928
  • 23
  • 65
  • 73

0 Answers0