Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JScrollPane with multiple JEditorPanes

 
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
 
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
 
Barry's not gonna like this. Barry's not gonna like this one bit. What is Barry's deal with tiny ads?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic