Solved

passing events from (through) a glass pane?

Posted on 2001-07-25
13
437 Views
Last Modified: 2012-06-27
how can I cause events to pass through the glass pane to the underlying content panes in a Swing component?

0
Comment
Question by:glow060197
  • 4
  • 3
  • 2
  • +3
13 Comments
 
LVL 7

Expert Comment

by:tomboshell
ID: 6321340
Eh? I'm missing something. But, as I understand it the glass pane is more of an interface that is there to trap the keyboard events and send them on to the listeners.  Then something like an actionhandler is used to deal with the events.  But, this may be a new method that I don't know about and would glady like to learn.

So, this is me eagerly listening...  :)
Tom
0
 
LVL 7

Expert Comment

by:Sasha_Mapa
ID: 6321464
I'm guessing that overriding the contains(int, int) method and returning true for locations where you don't want events to pass and false for locations where you want them to go through should do the trick.

Sasha Maryanovsky.
0
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
ID: 6324708
Do u want to selectively pass event thru?
0
 

Author Comment

by:glow060197
ID: 6328682
objects: no i want to pass them all through, but still use the glass pane to display graphics.  the glass pane is always present but until you actually do something with it, the events go to the content pane, and i can't seem to figure how to route them through, after a lot of hacking.
0
 
LVL 92

Expert Comment

by:objects
ID: 6329069
One option would be to simply use your own glass pane (via setGlassPane()) which doesn't consume events.
0
 
LVL 7

Expert Comment

by:Sasha_Mapa
ID: 6329362
glow, did you try my suggestion?

Sasha Maryanovsky.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:glow060197
ID: 6333412
i did try my own glasspane and couldn't make it work, objects.  but i'm not an expert on how the "multicaster" and all those methods in Component (etc.) interact...

Sasha, i did not get to that yet but will shortly.  be back to you then.
0
 
LVL 92

Expert Comment

by:objects
ID: 6333506
If you're not interested in blocking events then you can just leave them alone.

Try something like:

public class MyGlassPanel extends JPanel
{
   public MyGlassPanel()
   {
      setOpaque(false);
   }

   public void paintComponent(Graphics g)
   {
     // do your painting here
   }
}


Then use:

MyGlassPane pane = new MyGlassPane();
frame.setGlassPane(pp);
pane.setVisible(true);
0
 

Author Comment

by:glow060197
ID: 6333522
ok, i'll try that again, but i really think i did just that last week...hmmm...
0
 
LVL 92

Expert Comment

by:objects
ID: 6333533
I've used the above w/out problem.
If it doesn't work post your code and I'll have a look :)
0
 

Expert Comment

by:CleanupPing
ID: 9061961
glow:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9208304
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:


[points to objects]


Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.

759 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

20 Experts available now in Live!

Get 1:1 Help Now