Solved

mouselistener for images

Posted on 2003-12-01
8
298 Views
Last Modified: 2012-06-27
hi there

iwant to set mouse listener for the images
i know as image is not a component its not possbile but is there any other way to do that

basically i want to add a popup menu to the image when a image is right clicked a popup should be displayed

thanx
0
Comment
Question by:starter79
  • 4
  • 2
8 Comments
 
LVL 92

Expert Comment

by:objects
ID: 9856281
If you are using Swing then use a JLabel with an image icon.
0
 
LVL 92

Expert Comment

by:objects
ID: 9856284
for awt create component subclass that displays your image and add your mouse listener to that component.
0
 

Author Comment

by:starter79
ID: 9856399
thanx objects

actually wut iam doing is tht iam using some other API ok
it's bbn's  openmap application

in that they have there own methods to plot an image on the screen (map) and tht too using Lat Lon

so in tht case i can only plot an instance of ImageIcon class
i havent seen any mehtod tht plots the component

can u guide some other way pls
i know it's tricky or may be difficult also
but then also i have to do it anyhow
thanx for taknig interest
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 92

Expert Comment

by:objects
ID: 9856412
hard to see without knowing the api u are using.
What can you add a mouse listener to?
0
 

Author Comment

by:starter79
ID: 9856733
i can add mouse listeners only to the components but iam plotting a ImageIcon
0
 
LVL 92

Accepted Solution

by:
objects earned 40 total points
ID: 9861973
Then simply have your componant paint the ImageIcon. JLabel already supports this.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unable to open debugger port in Intellij idea 6 140
eclipse compiler vs Installed JREs option 3 75
Java passing arguments (type error) 2 48
replace a word with other 1 40
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now