Solved

passing events from (through) a glass pane?

Posted on 2001-07-25
13
445 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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 “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

776 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