Solved

passing events from (through) a glass pane?

Posted on 2001-07-25
13
461 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
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 

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

Technology Partners: 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!

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

687 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