Hello,
I try to do a program that can search whatever the user typed.
But I kind of having a problem, which I cannot select everything matches.
For example, I type "Hi there hello, what is your name ? please say hello"
The I click on the search button.
It ask what to find.
For example I want to search "hello"
but in here my program only highlight the first word hello, the hello at the end was not highlighted. I use TextArea.
please take a look at my code :
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String search = javax.swing.JOptionPane.showInputDialog(this,"What do you want to search?");
int start = jTextArea1.getText().indexOf(search);
if (search != null)
{
jTextArea1.select(start, start + search.length());
jTextArea1.requestFocus();
}
}
Thank you