wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes JScrollPane with multiple JEditorPanes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JScrollPane with multiple JEditorPanes" Watch "JScrollPane with multiple JEditorPanes" New topic
Author

JScrollPane with multiple JEditorPanes

Steve Wood
Ranch Hand

Joined: Jan 08, 2003
Posts: 137
Hi guys,

I have a scroll pane with a number of editor panes. The trouble is, the scroll pane always scrolls to the last editor pane - despite my best efforts. So, the net result is that the scrollpane always ends up and the bottom, not at the top.

If I replace the editor panes with JTextFields of similar size, the scrolling works fine (i.e. it scrolls to the top, not the bottom). Though, if I use a JTextArea, the problem is the same as before.

Any suggestions? Basically, I want the scroll pane to scroll to the top when loaded, not be scrolled to the bottom and the editor pane doesn't seem to want this to happen!

Any help is much appreciated.

Cheers,

Steve
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1449
You may want to post your code to show people how you have things set up.


The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
Steve Wood
Ranch Hand

Joined: Jan 08, 2003
Posts: 137
Hi John,

I'd post some code, but I've just realised that if I strip it back to the situation I describe, it works fine.

I've gone through the code and I can't see anything that calls setCaretPosition, etc, so I'm completely at a loss.

Any suggestions how to debug things like this? I use eclipse.

Any help is much appreciated.

Cheers,

Steve
Steve Wood
Ranch Hand

Joined: Jan 08, 2003
Posts: 137
Sorry, let me add to that - except where I'm telling it to set the scrollpane to the top.

pneHost.getViewport().setViewPosition(new Point(0, 0));
pneHost.scrollRectToVisible(new Rectangle(0, 0, 0, 0));

Again, any help most appreciated on how to debug this.

Cheers,

Steve
 
Don't get me started about those stupid light bulbs.
 
subject: JScrollPane with multiple JEditorPanes