• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Events from inner components.

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there...
Im having a problem, let me explain it by example:

I have some JInternalFrames on JLayeredPane... and i want every of them to go to front when selected. The problem is, that if my JInternalFrame has any focusable component in it and user clicks on that component, JInternalFrame loses focus and is not getteing focus events any more - even if i click on its bar. I tried also listening for mouse events, but it also doesnt notify my JInternalFrame when inner component is clicked.

So is there any way I can know about any mouse/focus event on anything in my JInternalFrame or I have to add focus/mouse listeners to every component in it?
 
Jarosław Piotrowski
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, i did it like this:
Every JInternalFrame has custom glasspane on it. this glass pane captures every mouse event and redispatch for component which is under the point of event (x,y) - if current component is different than last, additionaly mouseexit and mouseenter events are called.

If anyone wants to know more, ask here or e-mail me.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
not sure I'm reading the problem right, but one possible way to do it:

add an AWTEventListener, listening for mousePressed
use SwingUtilities.getAncestorOfClass(..) to check for a JInternalFrame
if not null, set that JInternalFrame to selected(true)

[EDIT]
probably better to use mouseReleased
 
The harder you work, the luckier you get. This tiny ad brings luck - just not good luck or bad luck.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic