請各位幫幫忙...
findWord = JOptionPane.showInputDialog("Find:");
if (findWord == null) {
JOptionPane.showMessageDialog(null, "find error");
} else {
fingWordLength = findWord.length();
currentTextInTextArea = textPane[getTextPaneNum()].getText();
findIndex = currentTextInTextArea.indexOf(findWord);
if (findIndex < 0){
JOptionPane.showMessageDialog(null,"not find!");
} else {
textPane[getTextPaneNum()].select(findIndex, findIndex + fingWordLength);
}
}這個可以做到用textPane搜字但當使用者換行後就會因為換行而令搜索出現問題,
請問要如何才不會因為換行而改變select出來的位置?
萬分感激~
findWord = JOptionPane.showInputDialog("Find:");
if (findWord == null) {
JOptionPane.showMessageDialog(null, "find error");
} else {
fingWordLength = findWord.length();
currentTextInTextArea = textPane[getTextPaneNum()].getText();
findIndex = currentTextInTextArea.indexOf(findWord);
if (findIndex < 0){
JOptionPane.showMessageDialog(null,"not find!");
} else {
textPane[getTextPaneNum()].select(findIndex, findIndex + fingWordLength);
}
}這個可以做到用textPane搜字但當使用者換行後就會因為換行而令搜索出現問題,
請問要如何才不會因為換行而改變select出來的位置?
萬分感激~
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货