D
D
ddark0082017-04-12 13:46:42
Java
ddark008, 2017-04-12 13:46:42

How to change MouseWheelListener with javassist?

There is a compiled java application without source codes. It is required to change the reaction of the program to the movement of the mouse wheel. Initially, there is an up / down movement, I want to zoom in / out, it is implemented using the interface buttons.

The obvious option is to use javassist. But there is one caveat - it does not work with inner and anonymous classes. Therefore, simply creating another MouseWheelListener will not work, like this:

this.removeMouseWheelListener(this.getMouseWheelListeners()[0]);
MouseWheelListener mwl = new MouseWheelListener(){
        @Override
        public void mouseWheelMoved(MouseWheelEvent mwe) {
                AbstractCanvas.this.setZoom(AbstractCanvas.this.getZoom() + mwe.getUnitsToScroll() * 20, null, mwe.getPoint());
                AbstractCanvas.this.refreshComponents();
        }
    };
this.addMouseWheelListener(mwl);


It is possible to create MouseWheelListener as a separate class, but how then is it appropriate to call the AbstractCanvas.this.setZoom() method?

This is where my modest knowledge of java ended and I came here.

What are the possible solutions to this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Denisenko, 2017-04-13
@kapioprok

Hello, pay attention to the abstractcanvas class.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question