• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JScrollPane with multiple JEditorPanes

 
Steve Wood
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want to post your code to show people how you have things set up.
 
Steve Wood
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic