Solved

passing events from (through) a glass pane?

Posted on 2001-07-25
13
453 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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 learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This video teaches viewers about errors in exception handling.

726 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