Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 332
  • Last Modified:

doublt abt panels

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
starter79
Asked:
starter79
1 Solution
 
vk33Commented:
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
 
objectsCommented:
> 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now