C
C
cld3332017-09-20 01:19:11
Java
cld333, 2017-09-20 01:19:11

Java swing. How to resize an image or a drawn primitive using the mouse?

The project should allow to apply infrastructural engineering objects (window, radiator, valve, etc.) to the floor plan (minimum rectangular shape). Mandatory functions: adding a given object, deleting a selected object, changing the size and location of an object.

Drawing a infrastructure object is easy, how do you make it resize and reposition on mouse click?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zhorius, 2017-09-21
@zhorius

it is necessary to hang on the MouseListener object, create the mousePressed flag, when the mouse button is pressed, the flag is set to true, when the button is released, the value is set to false. While our flag is true, we change the position of our object to the position of the cursor. In short, something like this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question