Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JScrollPane Problem

 
Justyn Dooley
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a problem with a JScrollPane vertical scroll bar. This part of my program reads in questionnaire questions and responses from a file, and then places them on a screen with radio buttons for selection. Everything works fine other than the fact that on questionnaires in which the question and response panel is larger than the screen, the Vertical scroll bar starts scrolled to the bottom of the panel; I need it to start at the top of the page, always. I have tried setting the value of the scroll bar to zero, and setting the caret position of all the JTextAreas to zero, but to no avail. As a matter of fact, I printed out the value of the scroll bar when it was scrolled down, and it said it WAS zero. I really need some help, I cant figure this out.

 
Rob Camick
Ranch Hand
Posts: 2613
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code isn't executable to I can't see the problem.

1) never use updadeUI

2) make sure you create the GUI on the EDT.
 
Justyn Dooley
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It isn't executable due to the fact that I would have to upload a ton of resources for it to be. And what do you mean by EDT?
 
Maneesh Godbole
Saloon Keeper
Posts: 11092
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you need to do is post a sscce code so we can run it in our environment. Before posting any code, please do read the link to understand what SSCCE really means.

EDT means Event Dispatch Thread
To get an understanding of what Rob means by
2) make sure you create the GUI on the EDT.

check out this example. Notice the use of SwingUtilities in main() and the comments given there.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic