• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JScrollPane with multiple JEditorPanes

 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Did Steve tell you that? Fuh - Steve. Just look at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic