0

I'm making a word processing app, I am using a text area as the area to be typed in and need to make a find button to find the location of a selected word in that text area.

I know I need to use either a while or for loop to cycle through the text to find a word, a .equals to see if it matches to what the user typed in the find word textfield and then the find word button will print the words index in another label.

I have an idea of what I need to do but just need some pointers to get it going

IMParasharG
  • 1,869
  • 1
  • 15
  • 26
CarmineA
  • 43
  • 6
  • Why use a for-loop through cycle through the text? Why not just use something from the String class? Maybe `string.contains();` or something similar. – SedJ601 Apr 02 '19 at 18:53
  • @Sedrick im unsure, thats why i was asking for advice, i figured a loop would work well since i recall using it before to cycle through files to search for words but wasnt sure, i was planning to look through oracle docs to see but didnt know where to start – CarmineA Apr 02 '19 at 18:56
  • Here is a demo app you can get some ideas from maybe? https://gist.github.com/zinch84/9186176 – SedJ601 Apr 02 '19 at 19:04
  • https://stackoverflow.com/questions/9128535/highlighting-strings-in-javafx-textarea – SedJ601 Apr 02 '19 at 19:06
  • 1
    @Sedrick thank you for the help i ended up using indexOf() and it worked great! – CarmineA Apr 02 '19 at 22:50
  • Possible duplicate of [JavaFX - get current word being typed in TextArea](https://stackoverflow.com/questions/32403650/javafx-get-current-word-being-typed-in-textarea) – Samuel Philipp Apr 03 '19 at 18:18

0 Answers0