Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
Greenhorn
Posts: 4
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 825
5
Python Ruby Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.).
 
Katherine Dhiman
Greenhorn
Posts: 4
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll try the above..thank you

I need to implement the zoom to a dumentFrame

 
Kemal Sokolovic
Bartender
Posts: 825
5
Python Ruby Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I'll just try with code you provided earlier..
thank you
 
Kemal Sokolovic
Bartender
Posts: 825
5
Python Ruby Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you!
(bow)
 
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic