Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

"Error cannot find symbol" "throws BadLocationException"  RSS feed

 
Andre Rossi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting the error that it is the thread title when running this code:

The error began to show up when I added this three lines related to the Highlighter. I think it might be related to the index that I am passing to addHighlight but I am not sure.
Anyone has an idea about what can be?
 
m Korbel
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
- for better help sooner post an http://sscce.org/, short, runnable, compilable with hardcode value for Document as local variable,

- no idea if Highlighter is applied on runtime or on apps startup (quite doesn't matter is required an SSCCE)
 
Andre Rossi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting the error that it is the thread title when running this code:




The error began to show up when I added this three lines related to the Highlighter. I think it might be related to the index that I am passing to addHighlight but I am not sure.

I made I self-contained version of the error here:

But with this code I don't get the same error.....what I am getting now it is a nullPointerException in line 24 the one
The frame is created shows the two first words before generating the error.

Anyone has an idea about what can be?

I also would appreciate if someone can provide me a few tips, links or whatever about how I can advance in text using the keyboard. In another words, if I press right it advances until a certain occurrence of a certain word, then if I press again, it advances to the next one until I reach the last occurrence of a word.
 
Andre Rossi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Shall I edit the first post and put these links there?

I received this suggestion in one of the forums

I have not used the Highlighter class before. But I suggest you move the hilit and painter definitions outside the loop. I believe they can be allocated once for subsequent highlighting ahead of time. Then you need to set the highlighter in your JTextArea object using ta.setHighLighter(hilit). I believe there will still be problems with the coordinates you are highlighting but the exceptions go away.


And I tried this

But this is leaving to this:

error: cannot find symbol
ta.setHighLighter(hilit);
>
 
Rob Spoor
Sheriff
Posts: 21052
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java is case sensitive, and there is a wrong case somewhere in that method name.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!