在Java Swing中JScrollPane正确显示但箭头没有做任何事情

时间:2017-07-30 20:48:46

标签: java swing jscrollpane

我已经在我的JPanel中添加了一个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);
             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);
            }
        }       
    }

}

我无法理解缺少的东西,酒吧在那里,箭头在那里,但它只是不起作用。再次感谢。

0 个答案:

没有答案