aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JScrollPane + JPanel + zooming probs" Watch "JScrollPane + JPanel + zooming probs" New topic
Author

JScrollPane + JPanel + zooming probs

chris ak
Greenhorn

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
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

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


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JScrollPane + JPanel + zooming probs