• Post Reply Bookmark Topic Watch Topic
  • New Topic

CaretListener is abstract; cannot be instantiated  RSS feed

 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to stick this somewhere that I don't get an error
CaretListener caretListener = new CaretListener();

CaretListener is abstract; cannot be instantiated
CaretListener caretListener = new CaretListener();

I put it along with the ActionListener menuCommandProcessor = new UNTFuserGuiCommand(); and I get the error, I put inside the class or inside the method and I get the same error.

not sure why, but when this was not a class and it was just a method of the main class it worked fine.
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's what the code looks like



I get Cannot Find Symbol at textInput.addCaretListener(caretListener);
[ November 26, 2007: Message edited by: James Hambrick ]
 
Henry Wong
author
Sheriff
Posts: 23284
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get Cannot Find Symbol at textInput.addCaretListener(caretListener);


caretListener is a local variable of the LineColumnCount() method. It is not in scope in the constructor. Hence, why you get a can't find symbol error.

Henry
 
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 Henry Wong:


caretListener is a local variable of the LineColumnCount() method.


Actually it's a member variable in the LineColumnCount inner class; otherwise Henry's argument holds.
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay where would I put it to make it work??? If I put it ouside that class I get the error about it being abstract and cannot be instiantiated.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This should work:

 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was wanting to put the CaretUpdate in the LineColumnCount class. It was outside the class originally and it worked. I was just wanting to put it in a class by itself.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!