• Post Reply Bookmark Topic Watch Topic
  • New Topic

GlassPane not redirecting events to deeper components

 
Brady Diggs
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all -
Thanks in advance for taking a look at this.

I am trying to create a little app that will show me what component I click on with the mouse.
The reason behind this is to get familiarity with my Swing application as I am new to it.
I am using a glassPane to cover the JFrame of my app and grab the mouse events, detect what component underneath the glass pane was clicked,
then send that component name to System.out.
I read the How to use RootPanes at http://java.sun.com/docs/books/tutorial/uiswing/components/rootpane.html
and structured my code like the glass pane demo.

First question is: Is there a better way to determine the names of the components graphically?

Second question is: Why is this little app not working?
Seems like it should at least return the applicationFrame when I call SwingUtilties.getDeepestComponentAt(), but it is just returning the ComponentGlassPane.
Am I missing something obvious here?

I could use a little help here if anyone has time. Thanks!

 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Seems like it should at least return the applicationFrame when I call SwingUtilties.getDeepestComponentAt(), but it is just returning the ComponentGlassPane.

//ComponentGlassPane glass = new ComponentGlassPane(applicationFrame);
ComponentGlassPane glass = new ComponentGlassPane(applicationFrame.getContentPane());
 
Brady Diggs
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That worked Michael. Thanks a lot!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!