Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JScrollPane + JPanel + zooming probs

 
chris ak
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9319
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out javax.swing.JScrollPane.getViewport() and javax.swing.JViewport.setViewPosition()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic