Link to home
Start Free TrialLog in
Avatar of Sumir
Sumir

asked on

Swing JViewport and zooming

I am using a JScrollPane to display some graphical objects for my application.  I'm trying to allow the ability to zoom in and out.  I decided to use the JViewport class but I can't seem to figure out which methods to use, or how to do it.  The web had nothing on this topic.  I bought an advanced Swing book, but it hasn't arrived yet.  HELPPPPP!!!!!

Has anyone done this before?  Any help would be greatly appreciated
Avatar of yongsing
yongsing

I was asking a similar question just the other day:

https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=java&qid=20169876

objects suggested using one of the drawImage() methods in the Graphics class to scale the image.
Avatar of Sumir

ASKER

Thanks yongsing, but I really do not want to increase the size of each object on my panel when I am trying to zoom.  It is like looking at a cell under a microscope.  When you want to zoom in you don't expand the cell, you expand your view of the cell.  

That is why I want to use the JViewport class, but I can't seem to get it to work.  Has anyone used it successfully?
Avatar of Mick Barry
I don't think JViewport is designed for zooming.
It merely provides a window onto a larger canvas, it provides no support for zooming in or out of that canvas.

To implement what you want you will need to develop your own class.
Avatar of Sumir

ASKER

objects,

Your comment is very insightful.  No wonder I couldn't get it to do zooming.  So do you suggest any way I can do the zooming?
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Sumir,
You've requested to delete this question, but its status has remained as 'Pending Delete' because one or more comments have been added.  Normally, the only way to fully delete such a Question is to post a message to Community Support and ask for assistance.

EE is making a one-time database sweep to purge the Pending Delete Questions automatically.  During this sweep:

    Sumir -- To allow the deletion to proceed:  Do nothing.
    EXPERTS -- Please DON'T POST a comment except to contest this deletion.

In the future, please refer to https://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp#8 for instruction on deleting questions.

DanRollins -- EE database cleanup volunteer
Hmm, I explained why the JViewport was not suitable and offered an alternative.
Thank you, finalized today by Moondancer - EE Moderator