Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Swing / AWT / SWT
Not able to receive mouse events on JPanel
P Goel
Greenhorn
Posts: 12
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I've a JPanel which is added in a JScrollPane. I'm adding a mouseListener on my JPanel but mouse events are not coming.
My code is as following
JScrollPane js = new JScrollPane(myPanel); myFrame.getContentPane().add(js); public class myPanel extends JPanel implements MouseListener{ void setMouseListener(){ addMouseListener(this); } public void mouseEntered(MouseEvent e) { System.out.println(":::::: MouseEntered"); } .... public void mouseClicked(MouseEvent e) { System.out.println(":::::: mouseClicked"); }; }
Please let me know why I'm not getting mouse events on JPanel???
Thanks,
Pulkit
Rob Camick
Rancher
Posts: 3324
32
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Either you never add the listener to the panel or other components are interception the mouse events.
If you need further help then you need to create a
SSCCE (Short, Self Contained, Compilable and Executable, Example Program)
, that demonstrates the incorrect behaviour.
P Goel
Greenhorn
Posts: 12
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks for replying...
Actually i've solved my issue, it was experienced because getPreferredSize() method was overridden in my Jpanel class. After removing it now it is working properly.
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
How do I capture a mouseClicked event from a JTable within a JScrollPane
newbie project problems
how to detect click on panel
problem with mouseMoved method
Correct this code for event handling.
More...