It's not a secret anymore!
The moose likes Swing / AWT / SWT and the fly likes JScrollPane + JPanel + zooming probs 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 + JPanel + zooming probs" Watch "JScrollPane + JPanel + zooming probs" New topic

JScrollPane + JPanel + zooming probs

chris ak

Joined: Nov 21, 2003
Posts: 1
hi, i have a problem combining JScrollPane + JPanel and adding a 'zoom' function. Right now i have a class that extends a JPanel with a paint() method and two methods which called can perform a zoom function - really just doubles the size of the JPanel and called to repaint with the new location of things.
All the above is also in a JScrollpane so if the JPanel gets to big, its scrollable - This bit works fine.
The problem when i want to zoom in/out i want it to zoom in at the point of where it was before clicking to zoom. Right now everytime i do a zoom, the viewable area focusese on the top left of the JPanel (i think maybe because it retains the last coords of the viewed area?) instead of zooming in on the area viewed before zoom.
Joe Ess

Joined: Oct 29, 2001
Posts: 9189

Check out javax.swing.JScrollPane.getViewport() and javax.swing.JViewport.setViewPosition()

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: JScrollPane + JPanel + zooming probs
It's not a secret anymore!