File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes How align a knob in a JScrollPane -> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How align a knob in a JScrollPane ->" Watch "How align a knob in a JScrollPane ->" New topic
Author

How align a knob in a JScrollPane ->

Dominic Steng�rd
Ranch Hand

Joined: Feb 05, 2001
Posts: 186
Hello!
I have put a JPanel inside a JScrollPane. What happens when I open the frame is that the knob(slider) in the scroll pane is set to the middle of the track, which means that instead of seeing the header of my panel the first thing you see is the middle of the panel. The reason for this seams to be that I have used the escape sequence \n inside the panel.
I thought there might be some method called something like setInitialKnobX(int i), but after searching through the JScrollPane API several times I have found nothing what so ever!
Do you understand my problem, if so please help me out!
Regards
------------------
Dominic Steng�rd
Sun Certified Java 2 Programmer
------------------
[This message has been edited by Dominic Steng�rd (edited February 08, 2001).]


Dominic Steng�rd<br />Sun Certified Java 2 Programmer
sakshi
Greenhorn

Joined: Feb 07, 2001
Posts: 2
I am also facing the similiar problem. I have also taken the instance of scrollbar from the view of scroll pane. there exist methods for setting the nob for a scrollbar such as setValue(int). But in case of JScrollPane these methods are not working.
In your case also there may be chance that when you will take instance of JScrollBar from JViewPort of JScrollPane, then you can set its value.
regards,
sakshi
Dominic Steng�rd
Ranch Hand

Joined: Feb 05, 2001
Posts: 186
Hi, I still have the problem listed above...
Could someone please help me out!
Thanks in advance!
Regards
Dominis
Chris Shepherd
Ranch Hand

Joined: Jun 27, 2000
Posts: 286
I think you need to deal with the viewport. Try
yourScrollPane.getViewPort.reshape(int x,int y,int w,int h)
where x and y =0 should move the view to the upper left corner of your panel
or maybe
yourScrollPane.getViewPort.setViewPosition(new Point(0,0))
the viewport should take care of moving the scrollbars for you.
Good Luck!
Ron Lewis
Greenhorn

Joined: Jul 08, 2004
Posts: 2
This didn't work for me with a JScrollPane
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How align a knob in a JScrollPane ->
 
Similar Threads
Second time answer please 3Drect
Thanks Every One!!!
Passed by the skin of my teeth
Scored 93%
How to read properties files from outside Container?