• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I wrap propertyChanged code into an event dispatch thread?  RSS feed

 
Phil Powell
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This code fails to compile producing the error message:



Bluntly put, how do I fix this?

Thanks
Phil
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As the error message suggests, declare the method parameter final:

public void propertyChange(final PropertyChangeEvent evt) {
...

That'll do it.
 
Phil Powell
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and it did, thank you! But how on earth was I allowed to do that one?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Phil Powell:
But how on earth was I allowed to do that one?


Final method arguments? IIRC, that's been in the language since JDK 1.1 . Not used as often as it should be, in my opinion.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Final tells the compiler the value will never change, so the inner class is safe to get the value later or get the value now and use it later. I never remember to put it in until I see that compiler message.
 
Phil Powell
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand what "final" means, but I don't understand why I am allowed to put "final" within the parameter; I've never seen syntax like that before!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!