This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JScrollPane Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JScrollPane Problem" Watch "JScrollPane Problem" New topic
Author

JScrollPane Problem

Justyn Dooley
Greenhorn

Joined: Aug 03, 2009
Posts: 9
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

Joined: Jun 13, 2009
Posts: 2156
    
    7
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

Joined: Aug 03, 2009
Posts: 9
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

Joined: Jul 26, 2007
Posts: 10172
    
    8

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.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
wood burning stoves
 
subject: JScrollPane Problem
 
Similar Threads
JScrollPane problem
Tally will not add up
Moving the scrollbar on tab to a specified field
Problem displaying JTable inside a JScrollPane
java io/reading from Disk file using RandomAccessFile class