?
Solved

passing events from (through) a glass pane?

Posted on 2001-07-25
13
Medium Priority
?
465 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 400 total points
ID: 6324708
Do u want to selectively pass event thru?
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

801 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