1.ebiaoԴ??
2.使ç¨javaå¼å代ç ç¼è¾å¨(使ç¨javaå¼å代ç ç¼è¾å¨ç好å¤)
ebiaoԴ??
import java.util.Scanner;public class Wuziqi {
/
*** 棋盘
*/
private final int[][] qipan;
/
*** 步数
*/
private int bushu;
/
*** 构造方法,设置棋盘规格
* @param x
* @param y
*/
public Wuziqi(int x, int y) {
if (x < 1 || y < 1) {
System.out.println("棋盘规格应不小于1,使用默认规格");
qipan = new int[9][9];
} else {
qipan = new int[y][x];
}
}
/
*** 游戏开始
*/
public void play() {
int[] zuobiao = null;
//如果游戏没有结束
while (!end(zuobiao)) {
//落子,海思监控源码并取得坐标
zuobiao = luozi();
//输出棋盘
out();
}
}
/
*** 输出棋盘和棋子
*/
private void out() {
for (int i = 0; i < qipan.length; i++) {
for (int j = 0; j < qipan[i].length; j++) {
if (qipan[i][j] == 0) {
System.out.print(" +");
}else if (qipan[i][j] == -1) {
System.out.print(" 白");
}else if (qipan[i][j] == 1) {
System.out.print(" 黑");
}
}
System.out.println(" ");
}
}
/
*** 落子
*/
private int[] luozi() {
int[] zuobiao;
bushu++;
if (bushu % 2 == 1) {
System.out.println("请黑方落子");
zuobiao = input();
qipan[zuobiao[1]][zuobiao[0]] = 1;
}else {
System.out.println("请白方落子");
zuobiao = input();
qipan[zuobiao[1]][zuobiao[0]] = -1;
}
return zuobiao;
}
/
*** 输入坐标
* @return
*/
private int[] input() {
Scanner sc = new Scanner(System.in);
System.out.println("请输入x轴坐标");
String x = sc.next();
System.out.println("请输入y轴坐标");
String y = sc.next();
//如果没有通过验证,则再次执行input(),钓鱼源码怎么获得递归算法
if (!validate(x,什么是lsb源码 y)) {
return input();
}
int int_x = Integer.valueOf(x);
int int_y = Integer.valueOf(y);
return new int[] { int_x, int_y};
}
/
*** 校验数据
* @param x
* @param y
* @return
*/
private boolean validate(String x, String y) {
Integer int_x = null;
Integer int_y = null;
//异常处理的方式判断字符串是否是一个整数
try {
int_x = Integer.valueOf(x);
int_y = Integer.valueOf(y);
} catch (NumberFormatException e) {
System.out.println("坐标格式错误,坐标应为整数");
return false;
}
if (int_x < 0 || int_y < 0 || int_x >= qipan[0].length || int_y >= qipan.length) {
System.out.println("坐标越界");
return false;
}
if (qipan[int_y][int_x] == 0) {
return true;
} else {
System.out.println("坐标上已有棋子");
}
return false;
};
/
*** 结束条件
* @return
*/
private boolean end(int[] zuobiao) {
if (zuobiao == null) {
return false;
}
//计数器
//表示棋盘上经过最近落子坐标的4条线上的连续(和最近落子颜色相同的)棋子的个数
//如果某条线上连续的棋子大于等于4(加上最近落子本身,大于等于5),则游戏结束,符合五子棋规则
int[] jieguo = new int[4];
int x = zuobiao[0];
int y = zuobiao[1];
//定义八个方向
final int[][] fangxiang = { { -1, 0}, { -1, 1}, { 0, 1}, { 1, 1}, { 1, 0}, { 1, -1}, { 0, -1}, { -1, -1}};
//最近落子的坐标上的棋子颜色
int number = qipan[y][x];
//搜索最近落子坐标为中心最远4的距离
for (int i = 1; i <= 4; i++) {
//每次搜索不同的距离都搜索八个方向
for (int j = 0; j < fangxiang.length; j++) {
//约定如果某个方向为null时,不再搜索这个方向。关键字continue是跳过本次(一次)循环的意思
if (fangxiang[j] == null) {
continue;
}
int mubiao_x = x + i * fangxiang[j][0];
int mubiao_y = y + i * fangxiang[j][1];
//如果搜索坐标相对于棋盘越界,则不再搜索这个方向
if (mubiao_y >= qipan.length || mubiao_y < 0 || mubiao_x >= qipan[0].length || mubiao_x < 0) {
fangxiang[j] = null;
continue;
}
//如果最近落子坐标上的ubuntu的源码在哪值等于目标坐标上的值(颜色相同),则计数器上某条线加1
//否则认为这个方向没有棋子或有别的颜色的棋子,不再搜索这个方向
if (number == qipan[mubiao_y][mubiao_x]) {
jieguo[j % 4]++;
}else {
fangxiang[j] = null;
}
}
}
//查看计数器上是zlib源码包作用否有比3更大的数(查看是否有一方胜出)
for (int i : jieguo) {
if (i > 3) {
System.out.println("游戏结束");
if (bushu % 2 == 1) {
System.out.println("黑方胜");
} else {
System.out.println("白方胜");
}
return true;
}
}
//没有胜出者的情况下,查看棋盘上是否还有空位置,如果有,则游戏可以继续
for (int[] arr : qipan) {
for (int i : arr) {
if (i == 0) {
return false;
}
}
}
//如果没有空位置,则平局
System.out.println("游戏结束,平局");
return true;
}
}
使ç¨javaå¼å代ç ç¼è¾å¨(使ç¨javaå¼å代ç ç¼è¾å¨ç好å¤)
javaç¼ç¨å¸¸ç¨ç软件æåªäº
æ³è¦å好Javaå¼åï¼æ²¡æ常ç¨çå¼åå·¥å ·å¯ä¸è¡ãèJavaåå¦è å¾å¾å¤äºå¯¹Javaè¿ä¸ç¥å解çç¶æï¼å¯¹äºJavaå¼åå·¥å ·çäºè§£ä¹ä¸ä¼å¤ªå¤ï¼å¸¸å¸¸ä¼ä¸ºäºæ¾å¼åå·¥å ·è浪费大éçæ¶é´ãç»å¤§å®¶ä»ç»ä¸Javaå¼åå·¥ç¨å¸å¸¸ç¨çå¼åå·¥å ·æåªäºã
第ä¸ä¸ªJava常ç¨çå¼åå·¥å ·ä¸ºJDKï¼ä¹å«Java软件å¼åå·¥å ·å ï¼æ¯ä¸ä¸ªç¼åJavaçAppletå°ç¨åºååºç¨ç¨åºçç¨åºå¼åç¯å¢ï¼JDKä¸è¿å æ¬äºJavaçå¼åç¯å¢ï¼æ以ä¸è½½äºJDKå°±å å«äºJavaå¼åç¯å¢ãèä¸JDKä¹æ以被å«åJava软件å¼åå·¥å ·å ï¼æ¯å 为å®å å«äºå ¶å®Javaå¼åå·¥å ·ï¼å¦ï¼ç¼è¯å·¥å ·(javac.exe)ãæå å·¥å ·(jar.exe)çã
第äºä¸ªæ¯JavaIDEï¼Eclipseï¼Eclipseæ¯ä¸ä¸ªå¼æ¾æºä»£ç çãåºäºJavaçå¯æ©å±å¼åå¹³å°ãå°±å ¶æ¬èº«èè¨ï¼å®åªæ¯ä¸ä¸ªæ¡æ¶åä¸ç»æå¡ï¼ç¨äºéè¿æ件ç»ä»¶æ建å¼åç¯å¢ãèä¸ç±äºå®çå¹³çåä¸è´æ§ï¼ä½¿å¾å ¶å®å¼åè¯è¨ä¹å¯ä»¥å¨eclipseä¸ä½¿ç¨ã
第ä¸ä¸ªæ¯notepad++ï¼notepad++æ¯ä¸ä¸ªç¼è¯å·¥å ·ï¼å®çä¼ç¹æ¯å³ä½¿ä½ ææ件å æäºï¼å¦æånotepad++ä¸æå¼è¿ï¼é£ä¹é£éå°±ä¼ä¿çï¼æ以对ä¸äºå®¹æ误å ç人æ¥è¯´æ¯è¾å好ï¼notepad++å¯ä»¥ç¨æ¥æ¿ä»£notepadã
第å个æ¯VisualStudioCodeï¼å®æ¯ä¸ä¸ªè¿è¡äºMacOSXãWindowsåLinuxä¹ä¸ç跨平å°æºä»£ç ç¼è¾å¨ãèä¸è¿ä¸ªç¼è¾å¨æ¯æå¤ç§è¯è¨åæ ¼å¼çç¼åã
以ä¸å°±æ¯æ¯è¾å¸¸ç¨ç4ç§Javaå¼åå·¥å ·ï¼Javaçåå¦è å¨å¯¹å¼åå·¥å ·ä¸äºè§£çæ åµä¸ï¼å¯ä»¥æ ¹æ®ä¸è¿°ä»ç»æ¥éæ©éåèªå·±çå¼åå·¥å ·ï¼è¿æ ·å¯ä»¥åå°èªå·±å°å¤æ¾å¼åå·¥å ·è¿å¯è½æ¾å°ä¸éåçæ浪费çæ¶é´ã
å¦ä½ç¨javaç¼åä¸ä¸ªç®åçææ¬ç¼è¾å¨ï¼
importjava.awt.*;\x0d\importjava.awt.event.*;\x0d\importjavax.swing.*;\x0d\importjava.io.*;\x0d\\x0d\publicclassf1extendsFrameimplementsActionListener\x0d\{ \x0d\privateMenuBarmenubar=newMenuBar();\x0d\privateMenufilemenu=newMenu("æ件");\x0d\privateMenueditmenu=newMenu("ç¼è¾");\x0d\privateMenuformmenu=newMenu("æ ¼å¼");\x0d\privateMenuItem[]itemf=newMenuItem[4];\x0d\privateMenuItem[]iteme=newMenuItem[6];\x0d\privateMenuItem[]items=newMenuItem[2];\x0d\privateTextAreatf=newTextArea();\x0d\\x0d\publicinta=0,b=0,c=0,style=Font.PLAIN,size=;\x0d\publicStrings1="red:"+a+""+"green:"+b+""+"blue"+c,\x0d\s2="å®ä½";\x0d\\x0d\publicString[]sz1={ "","","","","",""},\x0d\sz2={ "å®ä½","é»ä½","å¹¼å","é¶ä¹¦","è¡æ¥·","Arial","Georgia"},\x0d\sz3={ "ç²ä½","å¾æ","常è§","ç²æ"};\x0d\\x0d\JDialogdialog=newJDialog(this,"åä½",true);\x0d\Containercp=dialog.getContentPane();\x0d\JLabel[]lb=newJLabel[8];\x0d\JLabellb1=newJLabel(s1,JLabel.LEFT);\x0d\JButtonb1=newJButton("ç¡®å®"),\x0d\b2=newJButton("åæ¶");\x0d\JComboBoxjc1=newJComboBox(),\x0d\jc2=newJComboBox(),\x0d\jc3=newJComboBox();\x0d\JScrollBarjb1=newJScrollBar(JScrollBar.HORIZONTAL,,5,0,);\x0d\JScrollBarjb2=newJScrollBar(JScrollBar.HORIZONTAL,,5,0,);\x0d\JScrollBarjb3=newJScrollBar(JScrollBar.HORIZONTAL,,5,0,);
javaæºä»£ç ç¼è¾å¨è®¾è®¡ç¨äºç¼åJavaæºä»£ç çç¼è¾å¨ï¼åºæ¬è¦æ±ï¼å¯ä»¥å®ææºç¨åºçæ件æå¼ï¼ç¼è¾åæ件ä¿åä¸.é«äº®çå 容:
éè¦é«äº®çå 容æ:
1.å ³é®å,å¦public,int,trueç.
2.è¿ç®ç¬¦,å¦+,-,*,/ç
3.æ°å
4.é«äº®å符串,å¦"exampleofstring"
5.é«äº®åè¡æ³¨é
6.é«äº®å¤è¡æ³¨é
äº.å®ç°é«äº®çæ ¸å¿æ¹æ³:
StyledDocument.setCharacterAttributes(intoffset,intlength,AttributeSets,booleanreplace)
ä¸.ææ¬ç¼è¾å¨éæ©.
Javaä¸æä¾çå¤è¡ææ¬ç¼è¾å¨æ:JTextComponent,JTextArea,JTextPane,JEditorPaneç,é½å¯ä»¥ä½¿ç¨.ä½æ¯å 为è¯æ³çè²ä¸ææ¬è¦ä½¿ç¨å¤ç§é£æ ¼çæ ·å¼,æ以è¿äºææ¬ç¼è¾å¨çdocumentè¦ä½¿ç¨StyledDocument.
JTextArea使ç¨çæ¯PlainDocument,æ¤documentä¸è½è¿è¡å¤ç§æ ¼å¼ççè².
JTextPane,JEditorPane使ç¨çæ¯StyledDocument,é»è®¤å°±å¯ä»¥ä½¿ç¨.
为äºå®ç°è¯æ³çè²,å¯ä»¥ç»§æ¿èªDefaultStyledDocument,è®¾ç½®å ¶ä¸ºè¿äºææ¬ç¼è¾å¨çdocumet,æè ä¹å¯ä»¥ç´æ¥ä½¿ç¨JTextPane,JEditorPaneæ¥å.为äºæ¹ä¾¿,è¿éå°±ç´æ¥ä½¿ç¨JTextPaneäº.
å.ä½æ¶è¿è¡çè².
å½ææ¬ç¼è¾å¨ä¸æå符被æå ¥æè å é¤æ¶,ææ¬çå 容就åçäºåå,è¿æ¶æ£æ¥,è¿è¡çè².
为äºçè§å°ææ¬çå 容åçäºåå,è¦ç»documentæ·»å ä¸ä¸ªDocumentListenerçå¬å¨,å¨ä»çremoveUpdateåinsertUpdateä¸è¿è¡çè²å¤ç.
èchangedUpdateæ¹æ³å¨ææ¬çå±æ§ä¾å¦åæ¯è²,èæ¯è²,åä½çé£æ ¼æ¹åæ¶æä¼è¢«è°ç¨.
@Override
publicvoidchangedUpdate(DocumentEvente){
}
@Override
publicvoidinsertUpdate(DocumentEvente){
try{
colouring((StyledDocument)e.getDocument(),e.getOffset(),e.getLength());
}catch(BadLocationExceptione1){
e1.printStackTrace();
}
}
@Override
publicvoidremoveUpdate(DocumentEvente){
try{
//å 为å é¤åå æ ç´§æ¥çå½±åçåè¯ä¸¤è¾¹,æ以é¿åº¦å°±ä¸éè¦äº
colouring((StyledDocument)e.getDocument(),e.getOffset(),0);
}catch(BadLocationExceptione1){
e1.printStackTrace();
}
}
äº.çè²èå´:
pos:æåååå æ çä½ç½®.
len:æååçå符æ°.
ä¾å¦æå ³é®åpublic,int
åè¯"publicint",å¨"public"å"int"ä¸æå ¥ä¸ä¸ªç©ºæ ¼ååæ"publicint",ä¸ä¸ªåè¯åæäºä¸¤ä¸ª,è¿æ¶å¯¹"public"å"int"è¿è¡çè².
çè²èå´æ¯publicä¸pçä½ç½®åintä¸tçä½ç½®å 1,å³æ¯posåé¢åè¯å¼å§çä¸æ åpos+lenå¼å§åè¯ç»æçä¸æ .æ以ä¸ä¾ä¸è¦çè²çèå´æ¯"publicint".
æä¾äºæ¹æ³indexOfWordStartæ¥åå¾posååè¯å¼å§çä¸æ ,æ¹æ³indexOfWordEndæ¥åå¾posååè¯ç»æçä¸æ .
publicintindexOfWordStart(Documentdoc,intpos)throwsBadLocationException{
//ä»poså¼å§ååæ¾å°ç¬¬ä¸ä¸ªéåè¯å符.
for(;pos0isWordCharacter(doc,pos-1);--pos);
returnpos;
}
publicintindexOfWordEnd(Documentdoc,intpos)throwsBadLocationException{
//ä»poså¼å§ååæ¾å°ç¬¬ä¸ä¸ªéåè¯å符.
for(;isWordCharacter(doc,pos);++pos);
returnpos;
}
ä¸ä¸ªå符æ¯åè¯çææå符:æ¯åæ¯,æ°å,ä¸å线.
publicbooleanisWordCharacter(Documentdoc,intpos)throwsBadLocationException{
charch=getCharAt(doc,pos);//åå¾å¨ææ¡£ä¸posä½ç½®å¤çå符
if(Character.isLetter(ch)||Character.isDigit(ch)||ch=='_'){ returntrue;}
returnfalse;
}
æ以çè²çèå´æ¯[start,end]:
intstart=indexOfWordStart(doc,pos);
intend=indexOfWordEnd(doc,pos+len);
å .å ³é®åçè².
ä»çè²èå´çå¼å§ä¸æ èµ·è¿è¡å¤æ,å¦ææ¯ä»¥åæ¯å¼æè ä¸å线å¼å¤´,å说ææ¯åè¯,é£ä¹å åå¾è¿ä¸ªåè¯,å¦æè¿ä¸ªåè¯æ¯å ³é®å,å°±è¿è¡å ³é®åçè²,å¦æä¸æ¯,å°±è¿è¡æ®éççè².çè²å®è¿ä¸ªåè¯å,继ç»åé¢ççè²å¤ç.å·²ç»çè²è¿çå符,å°±ä¸åè¿è¡çè²äº.
publicvoidcolouring(StyledDocumentdoc,intpos,intlen)throwsBadLocationException{
//åå¾æå ¥æè å é¤åå½±åå°çåè¯.
//ä¾å¦"public"å¨båæå ¥ä¸ä¸ªç©ºæ ¼,å°±åæäº:"public",è¿æ¶å°±æ两个åè¯è¦å¤ç:"pub"å"lic"
//è¿æ¶è¦åå¾çèå´æ¯pubä¸påé¢çä½ç½®ålicä¸cåé¢çä½ç½®
intstart=indexOfWordStart(doc,pos);
intend=indexOfWordEnd(doc,pos+len);
charch;
while(startend){
ch=getCharAt(doc,start);
if(Character.isLetter(ch)||ch=='_'){
//å¦ææ¯ä»¥åæ¯æè ä¸å线å¼å¤´,说ææ¯åè¯
//pos为å¤çåçæåä¸ä¸ªä¸æ
start=colouringWord(doc,start);
}else{
//SwingUtilities.invokeLater(newColouringTask(doc,pos,wordEnd-pos,normalStyle));
++start;
}
}
}
publicintcolouringWord(StyledDocumentdoc,intpos)throwsBadLocationException{
intwordEnd=indexOfWordEnd(doc,pos);
Stringword=doc.getText(pos,wordEnd-pos);//è¦è¿è¡çè²çåè¯
if(keywords.contains(word)){
//å¦ææ¯å ³é®å,å°±è¿è¡å ³é®åççè²,å¦å使ç¨æ®éççè².
//è¿éæä¸ç¹è¦æ³¨æ,å¨insertUpdateåremoveUpdateçæ¹æ³è°ç¨çè¿ç¨ä¸,ä¸è½ä¿®æ¹docçå±æ§.
//ä½æ们åè¦è¾¾å°è½å¤ä¿®æ¹docçå±æ§,æ以ææ¤ä»»å¡æ¾å°è¿ä¸ªæ¹æ³çå¤é¢å»æ§è¡.
//å®ç°è¿ä¸ç®ç,å¯ä»¥ä½¿ç¨æ°çº¿ç¨,ä½æ¾å°swingçäºä»¶éåéå»å¤çæ´è½»ä¾¿ä¸ç¹.
SwingUtilities.invokeLater(newColouringTask(doc,pos,wordEnd-pos,keywordStyle));
}else{
SwingUtilities.invokeLater(newColouringTask(doc,pos,wordEnd-pos,normalStyle));
}
returnwordEnd;
}
å 为å¨insertUpdateåremoveUpdateæ¹æ³ä¸ä¸è½ä¿®æ¹documentçå±æ§,æ以çè²çä»»å¡æ¾å°è¿ä¸¤ä¸ªæ¹æ³å¤é¢,æ以使ç¨äºSwingUtilities.invokeLateræ¥å®ç°.
privateclassColouringTaskimplementsRunnable{
privateStyledDocumentdoc;
privateStylestyle;
privateintpos;
privateintlen;
publicColouringTask(StyledDocumentdoc,intpos,intlen,Stylestyle){
this.doc=doc;
this.pos=pos;
this.len=len;
this.style=style;
}
publicvoidrun(){
try{
//è¿éå°±æ¯å¯¹å符è¿è¡çè²
doc.setCharacterAttributes(pos,len,style,true);
}catch(Exceptione){ }
}
}
ä¸:æºç
å ³é®åçè²çå®æ代ç å¦ä¸,å¯ä»¥ç´æ¥ç¼è¯è¿è¡.对äºæ°å,è¿ç®ç¬¦,å符串çççè²å¤çå¨ä»¥åçæç¨ä¸ä¼ç»§ç»è¿è¡è¯¦è§£.
importjava.awt.Color;
importjava.util.HashSet;
importjava.util.Set;
importjavax.swing.JFrame;
importjavax.swing.JTextPane;
importjavax.swing.SwingUtilities;
importjavax.swing.event.DocumentEvent;
importjavax.swing.event.DocumentListener;
importjavax.swing.text.BadLocationException;
importjavax.swing.text.Document;
importjavax.swing.text.Style;
importjavax.swing.text.StyleConstants;
importjavax.swing.text.StyledDocument;
publicclassHighlightKeywordsDemo{
publicstaticvoidmain(String[]args){
JFrameframe=newJFrame();
JTextPaneeditor=newJTextPane();
editor.getDocument().addDocumentListener(newSyntaxHighlighter(editor));
frame.getContentPane().add(editor);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(,);
frame.setVisible(true);
}
}
/
***å½ææ¬è¾å ¥åºçæå符æå ¥æè å é¤æ¶,è¿è¡é«äº®.
*
*è¦è¿è¡è¯æ³é«äº®,ææ¬è¾å ¥ç»ä»¶çdocumentè¦æ¯styleddocumentæè¡.æ以ä¸è¦ç¨JTextArea.å¯ä»¥ä½¿ç¨JTextPane.
*
*@authorBiao
*
*/
classSyntaxHighlighterimplementsDocumentListener{
privateSetStringkeywords;
privateStylekeywordStyle;
privateStylenormalStyle;
publicSyntaxHighlighter(JTextPaneeditor){
//åå¤çè²ä½¿ç¨çæ ·å¼
keywordStyle=((StyledDocument)editor.getDocument()).addStyle("Keyword_Style",null);
normalStyle=((StyledDocument)editor.getDocument()).addStyle("Keyword_Style",null);
StyleConstants.setForeground(keywordStyle,Color.RED);
StyleConstants.setForeground(normalStyle,Color.BLACK);
//åå¤å ³é®å
keywords=newHashSetString();
keywords.add("public");
keywords.add("protected");
keywords.add("private");
keywords.add("_int9");
keywords.add("float");
keywords.add("double");
}
publicvoidcolouring(StyledDocumentdoc,intpos,intlen)throwsBadLocationException{
//åå¾æå ¥æè å é¤åå½±åå°çåè¯.
//ä¾å¦"public"å¨båæå ¥ä¸ä¸ªç©ºæ ¼,å°±åæäº:"public",è¿æ¶å°±æ两个åè¯è¦å¤ç:"pub"å"lic"
//è¿æ¶è¦åå¾çèå´æ¯pubä¸påé¢çä½ç½®ålicä¸cåé¢çä½ç½®
intstart=indexOfWordStart(doc,pos);
intend=indexOfWordEnd(doc,pos+len);
charch;
while(startend){
ch=getCharAt(doc,start);
if(Character.isLetter(ch)||ch=='_'){
//å¦ææ¯ä»¥åæ¯æè ä¸å线å¼å¤´,说ææ¯åè¯
//pos为å¤çåçæåä¸ä¸ªä¸æ
start=colouringWord(doc,start);
}else{
SwingUtilities.invokeLater(newColouringTask(doc,start,1,normalStyle));
++start;
}
}
}
/
***对åè¯è¿è¡çè²,并è¿ååè¯ç»æçä¸æ .
*
*@paramdoc
*@parampos
*@return
*@throwsBadLocationException
*/
publicintcolouringWord(StyledDocumentdoc,intpos)throwsBadLocationException{
intwordEnd=indexOfWordEnd(doc,pos);
Stringword=doc.getText(pos,wordEnd-pos);
if(keywords.contains(word)){
//å¦ææ¯å ³é®å,å°±è¿è¡å ³é®åççè²,å¦å使ç¨æ®éççè².
//è¿éæä¸ç¹è¦æ³¨æ,å¨insertUpdateåremoveUpdateçæ¹æ³è°ç¨çè¿ç¨ä¸,ä¸è½ä¿®æ¹docçå±æ§.
//ä½æ们åè¦è¾¾å°è½å¤ä¿®æ¹docçå±æ§,æ以ææ¤ä»»å¡æ¾å°è¿ä¸ªæ¹æ³çå¤é¢å»æ§è¡.
//å®ç°è¿ä¸ç®ç,å¯ä»¥ä½¿ç¨æ°çº¿ç¨,ä½æ¾å°swingçäºä»¶éåéå»å¤çæ´è½»ä¾¿ä¸ç¹.
SwingUtilities.invokeLater(newColouringTask(doc,pos,wordEnd-pos,keywordStyle));
}else{
SwingUtilities.invokeLater(newColouringTask(doc,pos,wordEnd-pos,normalStyle));
}
returnwordEnd;
}
/
**