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