Solved

doublt abt panels

Posted on 2003-12-05
4
322 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
hash value 2 38
copyEndy  challenge 15 55
Java and GPO 11 47
Java JRE greater than 1.6 5 21
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
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:

706 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

12 Experts available now in Live!

Get 1:1 Help Now