aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JEditorPane and 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 "JEditorPane and JScrollPane" Watch "JEditorPane and JScrollPane" New topic
Author

JEditorPane and JScrollPane

friso dejonge
Ranch Hand

Joined: Jul 11, 2002
Posts: 162
Hi all,
when i add an html file to a editorpane and then add that to a jscrollpane, the scrollbar is completely at the bottom, while i want to have it at the top.
I looked at scrollbar methods, but can find the right method to do it.
Anyone have ideas ?
thanks


swimming certificate (A & B), shoelaces diploma, and some useless java ones.
Rene Liebmann
Ranch Hand

Joined: May 02, 2002
Posts: 196
Hi,
have you tried the scrollRectToVisible method?
This method takes a Rectangle as Argument. There you could create simply a new Rectangle(0,0,0,0).
I have never tried this, but it should work.
Good Luck

Rene
friso dejonge
Ranch Hand

Joined: Jul 11, 2002
Posts: 162
thanks rene,

but this does not seem to work either. maybe i am doing something wrong.
Rene Liebmann
Ranch Hand

Joined: May 02, 2002
Posts: 196
Can you try to call scrollRectToVisible after your dialog is visible. If this doesn't work, then maybe you should add an empty JEditorPane, then you show your dialog and then you add the content. The last two steps you can change if you don't like it that way. In a normal case scrollRectToVisible is not needed.
Hope that helps

Rene
friso dejonge
Ranch Hand

Joined: Jul 11, 2002
Posts: 162
no does not work either.
anything i am doing wrong ?
Rene Liebmann
Ranch Hand

Joined: May 02, 2002
Posts: 196
Hi
I wrote a little sample. At least for me it works fine. Can you test it please. It is very simple. If you press the button, then you can choose an HTML file, which will be displayed.
If this doesn't work for you at all, then maybe your JDK has a bug???
John Smith
Ranch Hand

Joined: Jul 20, 2001
Posts: 84
You may also want to try adding the line:

This should cause the scroll pane to be moved all the way up to the top.
friso dejonge
Ranch Hand

Joined: Jul 11, 2002
Posts: 162
both ways work,
thanks very much
friso
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JEditorPane and JScrollPane