Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JScrollbar / JScrollpane programatical scrolling

E. Perry
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!
I am new to Java (although a seasoned .NET developer) and my guess is that the issue I'm having has a lot to do with the way Swing works, or, to be exact, my lack of knowledge regarding how it works.

I have Implemented a user control / component that allows zooming in and out of a displayed BufferedImage, for discussion's sake, 3rd party libraries are excluded and everything must be from scratch.

I have an image rendered on a JPanel, the JPanel is contained within a scrollbar.

Zooming in\out etc works perfectly.

The Scrollbars are rendered correctly on Zoom In and disappear when I zoom out.

I want to add the functionality of focusing on a specific quarter of the displayed image

via four dedicated buttons, each send an int (1-4) to a method, that controls the scrollbars.

A click on one of the four buttons immediately propagates to this method

And resizes the image whilst scrolling the scrollbars accordingly,
The method works as expected, and the scrollbars go to the desired location,
But there's a catch:
The first click on any of the above buttons does not work, but from the second click and on, everything works great!
Why? Please help me..
Rob Camick
Ranch Hand
Posts: 2637
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic