Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No methods executing on component

 
Derek Boring
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a class I created called picPanel that extends JPanel. Basically this class has a bufferedImage variable and in the paint event, it draws this image scaled down proportionally to fit inside the visible area of panel. The class contains only two methods: the constructor and paint. I added a mouseListener to the panel from it's container's class to open a window containing only the picPanel and functions for zoom. The problem I'm having is that once I added the mouseListener and changed the cursor to the hand, it stopped executing the panel's events, even the constructor. I tested it by putting System.out.println("constructor/paint") in the events. It even refuses to paint when I call repaint() from the container class. Eclipse keeps telling me there are errors in this file (the panel and it's container are in the same .java file) but it doens't show me where, the program runs just fine and there is no stack trace printed at any time. I've analyzed the code and tried commenting out and adding stuff dozens of times and I can't seem to get any different results.

Does anyone have an idea of what could be wrong?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49782
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure Eclipse is telling you there are errors? Eclipse won't usually compile a file with errors in.
There is the facility to view errors by using the tabs at the bottom of Eclipse; you need to look for view->problems.
If you can't find it out quickly please post some code so people can see what is going wrong.
 
Derek Boring
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fixed it. Thank you.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49782
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Derek Boring:
Fixed it. Thank you.
You're welcome.

Please tell us brifely how you fixed it.
 
Derek Boring
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Haha! it's actually a little embarrassing. I had two classes named PicPane wihtout realizing it and then what Campbell said made me realize it.

Thanks again. You guys rock!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic