swing - Add MouseListener to java.awt.Image -


is there way can add mouselistener image? took @ this stackoverflow question, didn't answer how java.awt.image, there no graphics2d image class. or @ least 1 i've found.


edit:

to clarify, let me try explain:

with ellipse2d, can say:

if(ellipse2d.contains(mousex, mousey) {     ...do } 

is possible java.awt.image (i.e. image.contains())

also, how image gets added jpanel:

image image = item.geticon().getimage(); //item.geticon() returns javax.swing.imageicon g.drawimage(image, imagex, imagey, null); 

you can put image in jlabel , add listener jlabel

imageicon image = item.geticon(); jlabel labelwithimage = new jlabel(image); labelwithimage.addmouselistener(new mouseadapter() {     @override     public void mouseentered(mouseevent e) {         system.out.println("mouse entered on image");     } }); panel.add(labelwithimage); 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -