aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes implement MouseWheelListener to Zoom-In Zoom-out a document on  document frame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "implement MouseWheelListener to Zoom-In Zoom-out a document on  document frame" Watch "implement MouseWheelListener to Zoom-In Zoom-out a document on  document frame" New topic
Author

implement MouseWheelListener to Zoom-In Zoom-out a document on document frame

Katherine Dhiman
Greenhorn

Joined: Jul 16, 2012
Posts: 4

Hi,
I'm trying to implement a MouseListener that listens the mouse wheel and according to the number of notches recorded zooms-in or out of the document on the documentFrame.


i'm not geting how to code to actually capture the scroll of the wheel...
Also, I want to implement this with ctrl key...so ctrl+scroll in zooms in..n likewise..
so VK_mouseWheelScroll maybe...something similar to that...

Can anyone please help me out with this?
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

Which component are you going to apply zoom to?

To listen for mouse scroll for zooming, you should have something like this:


Note that if you are working with graphics and want to add this functionality to canvas of some kind that you defined for displaying content, the best approach is to define finite state automata for manipulating actions user can perform on it (zoom, select, move, etc.).


The quieter you are, the more you are able to hear.
Katherine Dhiman
Greenhorn

Joined: Jul 16, 2012
Posts: 4

I'll try the above..thank you

I need to implement the zoom to a dumentFrame

Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

That's not standard Java class, so I can't give you any more details. But I see from the API (if I'm looking at the right one) that it extends JComponent, so I think the steps I gave you will do the job.
Katherine Dhiman
Greenhorn

Joined: Jul 16, 2012
Posts: 4

Ok, I'll just try with code you provided earlier..
thank you
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

Any time, feel free to ask if you come to an issue so we can try to resolve it.

And welcome to the Ranch!
Katherine Dhiman
Greenhorn

Joined: Jul 16, 2012
Posts: 4

Thank you!
(bow)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: implement MouseWheelListener to Zoom-In Zoom-out a document on document frame