Reputation: 3150
I am trying to code the search functionality in JTextArea
. I did it for find, but find next is where i am stuck. The JOptionPane
should not get closed until all the words are found in the JTextArea
.
private void findActionPerformed(java.awt.event.ActionEvent evt) {
findString = JOptionPane.showInputDialog(null, "Find What", "Find", JOptionPane.INFORMATION_MESSAGE);
text = editorTextArea.getText();
index = text.indexOf(findString, 0);
editorTextArea.setCaretPosition(index);
editorTextArea.setSelectionStart(index);
editorTextArea.setSelectionEnd(index + findString.length());
}
Upvotes: 0
Views: 798
Reputation: 1781
Use non-modal JDialog and dispose it manually when you are done with the last find. For more details on JDialog check at http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html
Upvotes: 1