Solved

doublt abt panels

Posted on 2003-12-05
4
325 Views
Last Modified: 2010-05-18
hi there

i have some problem n hope u ppl cud guide me

wut  iam trying to do is

my application has a frame and on to tht frame there is a panel of same size as tht of from and on that panel iam i am plotting some images(ImageIcon)

firstly wut i wanted tht i should be able to add a popupmenu on the image on right click on that image
but as it's not a component so it's not possible

so wut i did firstly i added a panel of same size as that of image at a specified location into main panel and then i added the image at the same location into the main panel ok

so now i can add the Mouse Events so a pop up is displayed on the right click


the problem part is tht i want tht when i left click on the (image+panel) then tht should be shown selected same as it happens when we click on the Desktop icons etc


how can we do this
if didnt get the question then ask for clarification
pls try to help
thanxx
0
Comment
Question by:starter79
4 Comments
 
LVL 4

Expert Comment

by:vk33
ID: 9881460
You can set the border of the panel, containing your Image:

panel.addMouseListener(new MouseInputAdapter() {
   mouseClicked(MouseEvent e) {
      if (e.getButton() == MouseEvent.BUTTON1) {
         JComponent source = (JComponent)e.getComponent();
         source.setBorder(new LineBorder(Color.BLACK));
      }
   }
}

Regards!
0
 
LVL 92

Accepted Solution

by:
objects earned 30 total points
ID: 9884907
> but as it's not a component so it's not possible

anything (in your app) you can click on is a component.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to parse custom JSON to POJO java 4 83
jar file executable 12 58
diffSum example 4 50
how to add new optional parameter to JSP 1 49
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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.

808 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