I hope you can help me to solve my Problem.
I have two Strings and both are nearly equal.
String A is like: "Hello my friend"
String B is like: "Hello! my! friend"
Now I want to compare both Strings and write the result into another String. The result must be the String B with all diffent characters from String A in blue Color.
The "!" is for example. "!" could be any Kind of text including whitespaces.
I have to realize this with a JTextPane/StyledDocument.
Can you give me some examples or ideas to get this?
Thank you.
Have you tried writing chars one by one, applying a new style to every single char? That might be dirty but it's easy and that kinda solves your problem.
If it's an algorithmic problem - I don't think it is, but still - you should use a third string in which you add every character of
String Aand when you encounter a difference, you add the character fromBand decrease your iterator onA.Hope this helps.