Guest User

Untitled

a guest
Oct 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. public static void findBack(JTextArea TextArea, String searchText) {
  2. jTextArea = TextArea;
  3. text = searchText;
  4.  
  5. try
  6. {
  7. if (endIndex == 0) endIndex = jTextArea.getText().length();
  8. int select_end = jTextArea.getText().toLowerCase().indexOf(text.toLowerCase(), endIndex);
  9. int select_start = select_end > text.length() ? select_end - text.length() : jTextArea.getText().length();
  10. jTextArea.select(select_start, select_end);
  11. endIndex = select_end;
  12.  
  13. if(select_end == jTextArea.getText().toLowerCase().lastIndexOf(text.toLowerCase()))
  14. {
  15. endIndex = text.length();
  16. }
  17. }
  18. catch(NullPointerException e)
  19. {}
  20. }
Add Comment
Please, Sign In to add comment