Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JScrollPane setting scroll position

843806Mar 17 2009 — edited Sep 9 2010
I am having this problem with the JScrollPane where the scroll bar positions itself in the center, and not at the top and I can't figure out why.
Here is a code snippet:

JPanel userProfilePanel= new JPanel();
               userProfilePanel.setSize(new Dimension(600,800));
		userProfilePanel.setPreferredSize(new Dimension(600,800));
		
		JScrollPane  userProfileScrollPane=new JScrollPane(userProfilePanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		userProfileScrollPane.setSize(new Dimension(600,600));
		
		
		JTabbedPane tabbedPane=new JTabbedPane(); 
		tabbedPane.setSize(new Dimension(600,600));
		tabbedPane.addTab("Profile", null, userProfileScrollPane,"Does nothing");
 
               JDialog screen=new JDialog();
                screen.getContentPane().add(tabbedPane);
		userProfileScrollPane.getHorizontalScrollBar().setValue(0);
		userProfileScrollPane.getVerticalScrollBar().setValue(0);
		
		
		screen.repaint();
screen.setVisible(true);
Does anyone have an idea what it is doing this?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 7 2010
Added on Mar 17 2009
32 comments
2,327 views