0
我試圖垂直設置JScroll窗格的位置,但它看起來像是在某一點上限。水平它工作得很好。JScrollPane設置垂直位置不可能
JPanel panel = new JPanel(null);
panel.setBorder(BorderFactory.createLineBorder(Color.red));
panel.setPreferredSize(new Dimension(800, 800));
JLabel l = new JLabel("test1");
l.setBounds(40,40,100,100); panel.add(l);
JLabel l2 = new JLabel("test2");
l2.setBounds(440,440,100,100);panel.add(l2);
JScrollPane scroll = new JScrollPane(panel);
scroll.getVerticalScrollBar().setValue(500);
scroll.getHorizontalScrollBar().setValue(500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new BorderLayout());
add(scroll, BorderLayout.CENTER);
setSize(300, 300);
setVisible(true);
圖片:http://i.imgur.com/nIqBlrv.png
我可以垂直數設置爲任何我想要的。它不會超越這個位置。
希望有人能幫助我。 Ty已經。
的可能的複製[如何調整在滾動滾動的位置(http://stackoverflow.com/questions/2544758 /如何對調節器位置的-渦旋內式滾動窗格) – McNets