posted 12 years ago
Dear pros.
I have a Netbeans origin JFrame class OknoAdm with the main method and some other methods. It manages checkroom tags.
The tag class birka3D draws rectangle and manages its dragging and exiting jpanel:
In OknoAdm class - pressing a Button registers a tag to a name in Combobox:
In OknoAdm class - dragging a visual rectangle out of its Component should unregister the tag:
And here my coding has stuck. I tried it two ways:
1. Currently in b3d class I used a reference to OknoAdm object. This way I try to use in birka3D methods from OknoAdm - udalitBirki that remove tags and obnovitBirki that renews the display. But I doubt that I refer to that same object of OknoAdm that is run from main method, and not create a separate duplicate. Its the first time I try references - maybe I do smth wrong. Compiling this results no compile errors, but wrong behavior: adding new tag replaces existing tag and it is not removed while dragging it outside b3d panel.
2. Before that I tried to add MouseAdapter and MouseListener inside sozdatBirki method and run udalitBirki and obnovitBirki methods from inside of sozdatBirki method. But it resulted in error, because udalitBirki changed map contents while iterating it in sozdatBirki. Using ConcurrentHashmap removed the error but didn't provide the right behavior. Using 2nd way added tags and removed them while dragging outside the panel, but could remove more than needed when dragging or even adding.
Please advice.