📄 tools.java
字号:
/* * Tools.java * * Created on 2008年4月17日, 上午10:03 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */package note;import javax.swing.JEditorPane;/** * * @author soft01 */public abstract class Tools { //传入参数的解释 //jEditorPane对象 string要查找的字符串 upOrLow大小写开启 danCi按单词模式 //upOrDown向上或向下查询 public static void find(JEditorPane jEditorPane, String string, boolean upOrLow, boolean danCi, boolean upOrDown, int start, int end) { String text = jEditorPane.getText (); int index = 0; //忽略大小写 if (upOrLow == true) { text = text.toLowerCase (); string = string.toLowerCase (); } //向上 if (upOrDown == true) { index = text.lastIndexOf (string, start - 1); } else { //向下 index = text.indexOf (string, end); } //如果没找到 if (index == -1) return; //匹配单词 if (danCi == true) { //单词的前一个字符 String CharStartOfDanCi; if (index != 0) CharStartOfDanCi = text.substring (index - 1, index); else CharStartOfDanCi = " "; //单词的后一个字符 String CharEndOfDanCi; if ((index + string.length () != text.length ())) CharEndOfDanCi = text.substring (index + string.length (), index + string.length () + 1); else CharEndOfDanCi = " "; //开始匹配 if (CharStartOfDanCi.matches ("\\w") || CharEndOfDanCi.matches ("\\w")) { if (upOrDown == true) Tools.find (jEditorPane, string, upOrLow, danCi, upOrDown, index - 1, index - 1); else Tools.find (jEditorPane, string, upOrLow, danCi, upOrDown, index + 1, index + 1); return; } } //显示找到的单词 jEditorPane.select (index, index + string.length ()); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -